Showing posts with label iptables. Show all posts
Showing posts with label iptables. Show all posts

Wednesday, February 29, 2012

How to check if ports have got open after IPTables rules


Verify that port is open

Run following command:
netstat -tulpn | less
Make sure iptables is allowing port 80 / 110 / 143 connections:
iptables -L -n
Refer to iptables man page for more information about iptables usage and syntax:
man iptables

IPTables CentOS5.6 - port 80, 143, 443 allowed or open


I had my webserver setup perfectly and it was working fine but it was not accessible from outside. It was IPtables blocking the same. I read on internet about the rules for IpTables to allow access to port 80,443,143. below mentioned are the rules.

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT

But even after applying these rules things were not working because I was appending these rules after the rule

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited


-------------------------------------------------------------------------------
I think (I don't know for sure) the rule for icmp shall always be at the last. Any rule after that to allow access to network resources will not get effective.

If I am wrong please correct.

You can refer to http://www.cyberciti.biz/faq/howto-rhel-linux-open-port-using-iptables/ for more information on IPTables.

Tuesday, February 28, 2012

IPtables the play is dangerous and frustrating...yet find the way how to enable outbound traffic for port 3306 mysql

1. vi /etc/sysconfig/iptables 
To allow inbound traffic add this rule:  -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
To allow outbound traffic add this rule:  -A OUTPUT -p tcp -m tcp --dport 3306 -j ACCEPT 

Now restart IPtables:  /etc/init.d/iptables restart