0

In my CentOS 6 i added a IPtables rules like DROP all the policy like

iptables -P INPUT DROP

Then I allow Port NO 22,80,443 with this command,

iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT

iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT

iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT

Now can access SSH with putty. But i can't access Internet. I have to know the exact problem of this.? Please help me.

  • You allow incoming traffic to local ports 80, 443, 22 but are you allowing the return traffic from your outgoing connections (which are different from what you show) back in? (You need a rule similar to iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT for this. In most situations that should be among the first rules in the chain.) – a CVn Aug 21 '15 at 7:58
0

In order to diagnose this accurately we would need to see your IPTables rules - which you can provide using 'iptables -vnL'

IPTables rules are order specific.

Most likely you have a "DENY" rule before the -A rules you just added. I'm pretty sure that by default Redhat/CentOS allow port 22 in the default configuration, but not the other ports - which is why SSH is working. You can easily test this theory by modifying "-A INPUT" to "-I INPUT". The -I inserts the rules at the beginning of the filter, the -A is at the end.

Again, Using iptables -vnL will show you the counters and, if you have a controlled environment it can assist you in working out which rule is hitting which packet.

0

First we can't see all your rules, but you need this one for sure.

iptables -I INPUT 1 -m conntrack -j ACCEPT --ctstate RELATED,ESTABLISHED

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.