UFW

The default firewall configuration tool for Ubuntu is UFW. Developed to ease IPTables firewall configuration, UFW provides a user friendly way to create an IPv4 or IPv6 host-based firewall.

For more information, see: https://help.ubuntu.com/community/UFW

Enable UFW

To enable UFW with the default set of rules, run:

$ sudo ufw enable

To check the status of UFW:

$ sudo ufw status verbose

Disable UFW

To disable UFW run:

$ sudo ufw disable

Example Rules

Allow service HTTPS

You can use service names to define allow rules:

$ sudo ufw allow https

Allow TCP port 8080

You can also specify port number and protocol:

$ sudo ufw allow 8080/tcp

Allow VXLAN UDP/4789 from LAN Network

Let us assume that we have a LAN subnet 192.168.0.0/24 configured on eth0.10 (eth0 VLAN 10). We can define a specific rule to allow VXLAN (4789/udp) traffic from this network:

$ sudo ufw allow in on eth0.10 from 192.168.0.0/24 to any port 4789 proto udp

Deleting rules

To delete a rule, you can just specify delete in the beginning of the command. Let us try to delete the previously created rule as an example:

$ sudo ufw delete allow in on eth0.10 from 192.168.0.0/24 to any port 4789 proto udp

Logging

Enable logging

To enable UFW logging.

$ sudo ufw logging on

Logs will be located in /var/logs/ufw.

Log levels can be set by running sudo ufw logging low|medium|high. The default setting is low.