A
A
Alexander Karpov2017-03-29 20:39:07
CentOS
Alexander Karpov, 2017-03-29 20:39:07

How to save iptables settings once and for all?

Centos 7
I tried different methods that are offered on the Internet, however, after restarting the system, the iptables settings are reset.
What method are you using? Centos is fresh.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Karpov, 2017-03-30
@Inkognitoss

On Centos 7, firewall-cmd is preinstalled. If you haven't removed it, then you should use it.
Adding port 80:

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

Then you can check. Whether the port is added to the rules:
You can delete the rule as follows
firewall-cmd --zone=public --remove-port=80/tcp --permanent
firewall-cmd --reload

Check:
Should be empty.
I was directed to this option by Roman Sokolov
Thanks to him for this.

R
Ruslan Fedoseev, 2017-03-29
@martin74ua

service iptables save
service iptables restore
well, read the documentation...

Y
Yaroslav, 2017-03-29
@YarkoDzech

yum install iptables-services
iptables -F
iptables-save | sudo tee /etc/sysconfig/iptables
All rules, for example:
iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
...
iptables -L -n
iptables-save | sudo tee /etc/sysconfig/iptables
service iptables restart

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question