How to Change Default Firewall Policy on UFW Ubuntu Firewall

In This Tutorial We are going to learn how to change the default Firewall Policy on Ubuntu Firewall UFW.

By default UFW Default Policies are

  • Deny incoming traffic
  • Allow outgoing traffic

View UFW Default Policy

We can find the default firewall policy on our Ubuntu server using ufw status command.

ufw status verbose | grep -i default

Change Default Firewall Policy

We can change the default ufw policy using the following command format.

ufw default allow|deny|reject [incoming|outgoing|routed]

Example : Set default policy to allow incoming traffic

ufw default allow incoming

Example : Set default policy to deny outgoing traffic

ufw default deny outgoing

You can override default rules using individual firewall rules. For Example, you can set both incoming and outgoing policy to deny all traffic, but then you can allow ssh connection by adding a firewall rule to allow ssh port 22.

submit to reddit