0

I am running CentOS release 6.5 (Final) and cannot figure out why my iptables is not starting. I may have executed some other command to permanently prevent the start up of iptables; I do not remember. However, now I need iptables running, but cannot get it started.

Any suggestions?

[root@server1 log]# chkconfig iptables --list
iptables        0:off   1:off   2:on    3:on    4:on    5:on    6:off

[root@server1 log]# service iptables status
iptables: Firewall is not running.


[root@server1 log]# service iptables start


[root@server1 log]# service iptables status
iptables: Firewall is not running.

UPDATE:

I have looked at this a bit more and did an strace on /etc/init.d/iptables start and saw this message about no such file or directory.

stat("/var/lock/subsys/iptables", 0x7ffff80481d0) = -1 ENOENT (No such file or directory)

So I created this file, changed the perms and then started iptables. iptables still did not start, but I now get a message about "Firewall modules are not loaded."

This server had many security hardening changes made to it. Could this be the issue?

touch /var/lock/subsys/iptables
chmod 640 /var/lock/subsys/iptables

service iptables start
service iptables status
iptables: Firewall modules are not loaded.

UPDATE 2:

I rebooted after creating the subsys/iptables file and it was no longer there. All of my other services are running fine and start/stop without any problems.


UPDATE 3:

To ensure that iptables magically cured itself I rebooted the server. However after reboot the service is NOT running anymore.

-- BEFORE I REBOOTED --

[root@server1 ~]# who -r run-level 5 2014-09-10 13:47

[root@server1 ~]# chkconfig --list iptables iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

[root@server1 ~]# service iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination

Chain FORWARD (policy ACCEPT) num target prot opt source destination

Chain OUTPUT (policy ACCEPT) num target prot opt source destination

[root@server1 ~]# shutdown -r now

-- AFTER I REBOOTED --

[root@server1 ~]# service iptables status iptables: Firewall is not running.

[root@server1 ~]# chkconfig --list iptables iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

7
  • /var/lock/... files would get deleted upon restart. Check if this command has some output to verify installation: rpm -V iptables
    – NuTTyX
    Sep 8, 2014 at 18:49
  • Trying.. right now seems we have some sort of network issues that is making for timeouts.. Once I get the info I will reply. thanks for replying.
    – user5524xx
    Sep 8, 2014 at 19:14
  • That command (-V) runs and returns NO output. Still cannot get yum info to work due to network.
    – user5524xx
    Sep 8, 2014 at 19:50
  • OK, having no output is what it should be. Is your machine a VPS or similar? Could you try to run iptables -V and iptables -nvL and check if it shows some kind of error?
    – NuTTyX
    Sep 8, 2014 at 19:52
  • This is so strange.. I came in this morning and saw your comment. Now it seems iptables is running. When I left yesterday it was not running. I came in this morning it was. No one has access to this machine. [root@server1 ~]# service iptables status Table: filter Chain INPUT (policy ACCEPT) num target prot opt source destination Chain FORWARD (policy ACCEPT) num target prot opt source destination Chain OUTPUT (policy ACCEPT) num target prot opt source destination
    – user5524xx
    Sep 9, 2014 at 12:37

3 Answers 3

3

I was facing the same problem and I found a simple way to resolve it:

  1. Make sure your system has iptables's config file:

    ls -l /etc/sysconfig/iptables
    
  2. In my case, I found two files in this folder:

    iptables-config  iptables.old
    
  3. You should rename iptables.old to iptables (or create a new one) because only iptables will be accepted.

  4. Try to start iptables again.

    service iptables start
    iptables: Applying firewall rules:                         [  OK  ]
    
1

I faced the same problem today. It turned out the problem was in use of a rule with a domain name used instead of IP address. I suspect the server tries to start iptables before a network connection is available. So no domain name resolution is possible and consequently iptables fails to start even though there is no problem with iptables service start when the system is up and running as the network is up and DNS lookup succeeds at that time.

The moral is:

1) Never ever use domain names instead of IP addresses in iptable rules. I knew the rule but I ignored it thoughtlessly. :-/

2) Configure and properly test fallback tables /etc/sysconfig/iptables.fallback and /etc/sysconfig/ip6tables.fallback that will be applied if the primary configuration table fail to apply (see https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-Firewalls-Basic_Firewall_Configuration.html). That can save your system from being opened to everyone.

1
  • Your diagnosis was spot on in my situation too. It was driving me batty until I saw your answer. Thanks
    – Steve C
    Dec 18, 2015 at 10:35
0

In our case

service network restart

yum reinstall -y iptables.x86_64

service iptables restart - now works.

You must log in to answer this question.

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