How can I make iptables service start automatically after reboot on CenOS/RHEL7?
Solution 1
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
[Unit]
Description=firewalld - dynamic firewall daemon
Before=network.target
Before=libvirtd.service
Before=NetworkManager.service
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
Solution 2
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.
Related videos on Youtube
iRunner
Updated on September 18, 2022Comments
-
iRunner over 1 year
I am developing an android app.I am using
RelativeLayout
for login page and adding a button at the bottom usingandroid:layout_alignParentBottom="true"
, but whenever i am type into login box keypad is getting displayed and that login button is also getting shifted above the keypad.I want that button always to remain at the bottom.How to achieve that?
-
iRunner about 11 yearsAwesome.thnks a lot.Working fine now.
-
Dave over 9 yearsHi flemingovirus, I did trying what you have suggested and also looked at the link but it is still not working. Any ideas? thanks
-
Dave over 9 years[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 over 9 yearsthere is no dpkg so I used rpm instead. is this output sensible? thanks
-
flemingovirus over 9 yearsOh I am so sorry, my mind got mixed up with another question. ok forget about the location of iptables. So what do you get when you use
systemctl
? Post the output on your question. -
Dave over 9 yearsthanks 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?
-
flemingovirus over 9 years@Dave the output of systemctl says it has been put for startup. Check with a reboot.
-
Dave over 9 yearsHi yes I did several times but no luck unfortunately
-
Dave over 9 yearsI cannot understand why these rules are forgotten after reboot
-
amir jj over 9 yearsiptables is builtin in Centos. i think you had a problem in installation. please try
$sudo service iptables status
and write output in comment. -
Davor Cubranic almost 4 yearsThe document you reference does not say that firewalld prevents iptables from loading, where did you get that idea?
-
Davor Cubranic almost 4 yearsCould be interaction with
firewald
? (See @zanegray's answer.)