3

I'm new to Linux and encountered a problem with iptables.

Here is the content of my /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 the 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 aren't the rules from /etc/sysconfig/iptables displayed in output?

1 Answer 1

3

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

Because the iptables service is not enabled in startup.

You can check using:

chkconfig --list iptables

When the iptables service gets started, it loads rules from /etc/sysconfig/iptables using:

iptables-restore /etc/sysconfig/iptables

So check whether the iptables service is running or not:

sudo /etc/init.d/iptables status
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .