How to view firewall rules in Ubuntu?

To view firewall rules on Ubuntu, you can use the following command:

  1. Check the IPv4 firewall rules using the iptables command.
sudo iptables -L
  1. Check the IPv6 firewall rules using the ip6tables command.
sudo ip6tables -L

The above command will display the current firewall rules list, including input, output, and forwarding rules. If there are many firewall rules, you can use the pipe symbol (|) and the grep command to filter out specific rules.

For example, to search for rules containing a specific port number, you can use the following command:

sudo iptables -L | grep 80

If you are using ufw (Uncomplicated Firewall), you can use the following command to view the firewall rules:

sudo ufw status

The command above will display the current status and rules list of the ufw firewall.

Note: The above command needs to be run in a terminal with administrative privileges.

bannerAds