Ufw

From Bashlinux
Jump to: navigation, search

How to enable/disable the firewall

# ufw <enable|disable>

How to allow/deny traffic on a particular port

# ufw <allow|deny> 80/tcp

How to delete a rule

# ufw delete <allow|deny> 80/tcp

How to allow traffic from a particular IP

# ufw allow from 1.2.3.4

How to allow traffic on eth1

# ufw allow in on eth1

How to allow traffic from a particular IP on a specific port

# ufw allow from 1.2.3.4 to any port 80 proto tcp

How to allow traffic on bridge interface

  • Edit the file /etc/ufw/before.rules
  • Add the following command before the line that starts with don't delete the 'COMMIT' line or these rules ...
-I FORWARD -m physdev --physdev-is-bridged -j ACCEPT

How to reset ufw to its initial state

  • Make sure all the custom rules are flushed
  • Make sure all the "ufw-*" chains are present
# ufw reset