How Do You Tell if There is a Firewall on Linux?

Problem scenario
You want to see if there is an operating system, software or host-based firewall on your Linux machine.  What do you do?

Solution
Run the following six commands for clues:

sudo ps -ef | grep firewalld
sudo systemctl status firewalld
sudo ps -ef | grep ufw
sudo ufw status
sudo iptables -L   #*
sudo nmap -P0 127.0.0.1

If you are running the server in a public cloud, remember that there are Security Groups in AWS, Network Security Groups (NSGs) in Azure, and firewall rules in GCP that could block connectivity.  The above is mostly for determining if there is a running an OS-level, software firewall.

* Here is an example of output of the iptables -L command when iptables is not blocking anything:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Leave a comment

Your email address will not be published. Required fields are marked *