How to check if firewall is blocking a port

Assume you want to check if port 2222 is running fine. Type the following: lsof -ni tcp:2222
You will get an ouput like:
COMMAND    PID   USER   FD   TYPE DEVICE SIZE NODE NAME
directadm 4132 nobody    0u  IPv4  12402       TCP *:rockwell-csp2 (LISTEN)
directadm 4377 nobody    0u  IPv4  12402       TCP *:rockwell-csp2 (LISTEN)
directadm 4378 nobody    0u  IPv4  12402       TCP *:rockwell-csp2 (LISTEN)
directadm 4379 nobody    0u  IPv4  12402       TCP *:rockwell-csp2 (LISTEN)
directadm 4380 nobody    0u  IPv4  12402       TCP *:rockwell-csp2 (LISTEN)
directadm 4381 nobody    0u  IPv4  12402       TCP *:rockwell-csp2 (LISTEN)

That means that port 2222 is running fine on your server. No firewall is blocking this.

You can also double check with netstat as well, type:

netstat -nat | grep :2222
tcp        0      0 0.0.0.0:2222                0.0.0.0:*                   LISTEN

If you've got an ouput like the above the service is running fine. If not disable your firewall. Under Redhat Enterprise Server or CentOS you will need to disable iptables from starting up during the boot. Type the following:

chkconfig --del iptables
chkconfig --del ip6tables

and then /etc/init.d/iptables stop.

Check that no firewall rules are running:

[root@devil~]# iptables -L
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
 

Posted on: 16/06/2010








0 Comments
If you want to leave a comment please Login or Register