How to modify iptables rules via editing a file rather than interacting via command line?

In the history, i would simply edit a file and then
reboot the whole server.

i would clone the line that had port 22 open
change it to 80 and then save the file.. and reboot
the whole system so the iptables would start with port 80 open.

but in the recent times.. that file is no longer in existent
in my centos 6.5 O.S.

most answers on google suggest i must interact with iptables
in order to enable and disable ports.

is it possible to not interact with iptables but rather
just see everything infront of you as one editable file ?

Asked By: user74548

||

In CentOS you have the file /etc/sysconfig/iptables if you don’t have it there, you can create it simply by using iptables-save to dump the current rule set into a file.

iptables-save > /etc/sysconfig/iptables

To load the file you don’t need to restart the machine, you can use iptables-restore

iptables-restore < /etc/sysconfig/iptables
Answered By: Rabin

I think it should be,
“service iptables save” to save it on /etc/sysconfig/iptables
then, “service iptables restart” to make sure that the rules created stays

Answered By: Dan
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.