I am having a few issues with a newly installed home server I am preparing. I have installed CentOS7 on it and I found that port 80 and 443 are off by default. I therefore added them to the iptables with the following commands:

iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
service iptables save

I also installed the iptable service which was not present. The problem is that every time I reboot the machine the new configurations are wiped.

I tried to add the the iptable service to chkconfig but I get the following error:

[root@CentOS-7]# chkconfig --add iptables
error reading information on service iptables: No such file or directory

I presume that the reason I get this error is because there is no iptable script in /etc/init.d/ however has anyone any ideas if I am actually doing the right thing and/or if there is an easier more solid way to do this? If not how can I solve this problem? In the end I just need to use my home server as a web/mail server...

I have also tried to use the 'systemctl enable iptables' command as flemingovirus kindly suggested but with no success. After I entered the command I got the following output:

ln -s '/usr/lib/systemd/system/iptables.service' '/etc/systemd/system/basic.target.wants`/iptables.service'`

UPDATE: I have looked at the iptables and the command "service iptables save" has worked properly. The problem seem to be due to the service not starting at reboot. I have managed to get the service running at reboot after adding the following line to /etc/rc.local

systemctl start  iptables.service

however I wonder why the 'systemctl enable iptables' command is not working in this case. Am I missing something? Thanks


3 Answers 3


Although this question is old, I came across the same issue and discovered the solution here.

systemctl mask firewalld
systemctl stop firewalld

Basically firewalld conflicts iptables and so will prevent iptables from loading:

# cat /usr/lib/systemd/system/firewalld.service 
Description=firewalld - dynamic firewall daemon
Conflicts=iptables.service ip6tables.service ebtables.service


I was able to solve this by masking firewalld to ensure it does not start automatically and will never be started thereafter. Of course you will need to ensure iptables is enabled:

systemctl enable iptables
  • The document you reference does not say that firewalld prevents iptables from loading, where did you get that idea? Jun 21, 2020 at 18:54

init scripts are gone. Now its systemctl. Its out there in all CentOS7 docs. To chkconfig ipatables or to start iptables service at startup you need to use this:-

systemctl enable iptables

You should checkout simple things to be known about systemctl at the Cyberciti docs on iptables.

  • Hi flemingovirus, I did trying what you have suggested and also looked at the link but it is still not working. Any ideas? thanks
    – Dave
    Aug 16, 2014 at 11:43
  • @Dave did you check where the iptables is? Is it /sbin/iptables itself? Check it out with dpkg -L iptables Aug 16, 2014 at 11:55
  • [root@CentOS-7}# rpm -ql iptables-services.x86_64 /etc/sysconfig/ip6tables /etc/sysconfig/iptables /usr/lib/systemd/system/ip6tables.service /usr/lib/systemd/system/iptables.service /usr/libexec/initscripts/legacy-actions/ip6tables /usr/libexec/initscripts/legacy-actions/ip6tables/panic /usr/libexec/initscripts/legacy-actions/ip6tables/save /usr/libexec/initscripts/legacy-actions/iptables /usr/libexec/initscripts/legacy-actions/iptables/panic /usr/libexec/initscripts/legacy-actions/iptables/save /usr/libexec/iptables /usr/libexec/iptables/ip6tables.init /usr/libexec/iptables/iptables.init
    – Dave
    Aug 16, 2014 at 12:02
  • there is no dpkg so I used rpm instead. is this output sensible? thanks
    – Dave
    Aug 16, 2014 at 12:04
  • 1
    @Dave the output of systemctl says it has been put for startup. Check with a reboot. Aug 16, 2014 at 13:11

First of all you should try #chkconfig --add /sbin/iptables this will recognize the "iptables". then you should create a script for your iptables configuration and then make that scrip to start on boot. create a script:

iptables -I INPUT 5 -i eth0 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT 5 -i eth0 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
/sbin/service iptables save

and name it for example myfirewall. make it executable with chmod +x myfirewall and write this ./myfirewall in /etc/rc.local to start the script on boot.

  • thanks but I get the following error: "error reading information on service iptables: No such file or directory" Also, to me it looks like a really complicated way to do this. Is there no other way to implement this in CentOS. In the end I am only trying to use it as a standard web/mail server. How can one use a web server if port 80 and 443 are not opened by default. Am I doing something wrong?
    – Dave
    Aug 16, 2014 at 12:54
  • iptables is builtin in Centos. i think you had a problem in installation. please try $sudo service iptables status and write output in comment.
    – amir jj
    Aug 17, 2014 at 4:10

You must log in to answer this question.

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