Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't access site if firewall turn on

Status
Not open for further replies.

akgta

Programmer
Jul 18, 2007
42
CA
We have a CentOS 5.3 server, we have tried opening ports 80 and 53 on the iptables firewall by placing the following code lines in /etc/sysconfig/iptables above the reject and commit lines and restarted it, still can't access the website.

Code:
-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 53 -j ACCEPT

If we turn the iptables firewall off we can see the website on a client browser.

Please help, thanks in advance.
 

Try moving the lines BELOW the reject lines and restart iptables.

 
If the above doesn't work....flush iptables and then add each rule line one at a time and then test. This is assuming that you have relatively few lines.
 
I've always defined an interface to "bind" my rule to. And I think removing "-m state --state NEW -m tcp" won't hurt either.
Code:
-A RH-Firewall-1-INPUT -p tcp --dport 80 -j ACCEPT
Unless you want to do something like this. Which is just as good as the first line. I like the first one better.
Code:
-A RH-Firewall-1-INPUT -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 80 -j ACCEPT
And don't forget the outbound rules too.

 
Woops!

Those previous code lines should read (assuming your interface is eth0)
Code:
-A RH-Firewall-1-INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
and
Code:
-A RH-Firewall-1-INPUT -i eth0 -m state --state NEW,ESTABLISHED,RELATED -p tcp --dport 80 -j ACCEPT

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top