3

I'm new in Linux and encountered with problem with iptables.

Here is content of /etc/sysconfig/iptables file

# Generated by iptables-save v1.4.7 on Tue Nov 27 21:41:04 2012
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [40672:2356787]
-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 FORWARD -j REJECT --reject-with icmp-host-prohibited 
COMMIT
# Completed on Tue Nov 27 21:41:04 2012

But when I try "sudo iptables -L -n -v -x" I have following output:

Chain INPUT (policy ACCEPT 261172 packets, 1040204290 bytes)
    pkts      bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
    pkts      bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 522761 packets, 2080465034 bytes)
    pkts      bytes target     prot opt in     out     source               destination  

Why doesn't the rules from /etc/sysconfig/iptables displayed in output?

3

Why iptables does not fetch information from /etc/sysconfig/iptables on centOs?

Because Iptables service not enable in startup.

You can check using :

chkconfig --list iptables

When Iptables service get start, it load rules from /etc/sysconfig/iptables using :

iptables-restore /etc/sysconfig/iptables

So check Iptables Service is Running or not :

sudo /etc/init.d/iptables status

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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