Linux – Check if ports are allowed in Firewall ubuntu

dockerfirewalllinuxUbuntu

Currently I'm trying to setup my ssl in docker instance. I'm trying to check if these ports are allowed in my firewall

Port: 443 and 4021

I've searched that allowing specific port for firewall using this terminal command

sudo ufw allow 4021

But how can I check and see all the ports allowed in my firewall?

Best Answer

If you configure all your firewall setting with ufw, then ufw status would show you the ports. But sometimes (in my experience) this doesn't show all configured firewall ports and options.

You would get a general output with: iptables -L -v -n

-L = list all ports
-v = make the output verbose
-n = do print port numbers instead of servicenames (otherwise it would print "http" or "ssh" instead of "80" or "22".

The command is faster when using the -n option an also can be `grep`ped or `ack`ed (https://beyondgrep.com/) for the port number
Related Topic