Ways to create a firewall are described in the article "Networks, Subnetworks, Floating IPs, Firewalls".
The firewall work is based on the rules that describe what traffic can get in and out of the virtual machine. If there are no rules — all traffic will be blocked.
By default, the firewall creates rules that allow incoming traffic for ICMP and SSH protocols and outgoing traffic for any other protocol. You can change these firewall rules or configure another one.
Rules are configured for incoming and outgoing traffic separately.
You can create a rule from a template (SSH, HTTP, All TCP, and others) or make your own by clicking on "New rule" → "Custom". Select the data transfer protocol, specify a port and IP addresses to which this rule will apply, in the CIDR format, click "Save". If you want the rule to apply to all addresses, leave the "Sources"/"Destinations" fields blank.