Sometimes we find in a running instance our iptables rules gets overridden by some old rules in /etc/sysconfig/iptables file after doing a restart on iptables service
Whenever you add a new rule to the iptables, be sure to call "iptables-save" otherwise the rules won't be persisted. Check whether the rules have been persisted in /etc/sysconfig/iptables
*********
# Generated by iptables-save v1.4.7 on Thu May 8 17:24:09 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [41:3768]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Thu May 8 17:24:09 2014
*********
If for some reason, you think the rules are not correct, you can run "sudo iptables --flush" and that will flush the rules and then add your new rules manually or load it from a file using "iptables-restore" command and then do a "sudo iptables-save".
Whenever you add a new rule to the iptables, be sure to call "iptables-save" otherwise the rules won't be persisted. Check whether the rules have been persisted in /etc/sysconfig/iptables
*********
# Generated by iptables-save v1.4.7 on Thu May 8 17:24:09 2014
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [41:3768]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Thu May 8 17:24:09 2014
*********
If for some reason, you think the rules are not correct, you can run "sudo iptables --flush" and that will flush the rules and then add your new rules manually or load it from a file using "iptables-restore" command and then do a "sudo iptables-save".
No comments:
Post a Comment