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 ?


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
  • This works as File creation and restauration, but after a reboot everything get back to the initial state! I am trying to add a script which is runnable on startup to apply this, but with no hope! – Yazid Erman Oct 3 '16 at 9:30
  • 1
    iptables-restore is good for OS start scripts. If you are doing some changes and want them to apply manually from console, there is a safer command iptables-apply - after a timeout it reverts all changes back if you accidentally cut yourself out of your server. – Messa Jan 16 '17 at 10:15
  • iptables-apply apparently isn't part of RedHat Enterprise 7.4 :-/ – Levon Oct 12 '17 at 19:45

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy