How to Create a Firewall on CentOS

Start by saving your current iptables rules if there are any.
If you are using CentOS 6.2 or 6.5, save your current iptables rules with the following command:

/sbin/service iptables save

If you are using CentOS 7 the base installation does not include iptables-services. You will need to install it before your firewall is persistent through boots

yum install -y iptables-services
systemctl enable iptables
systemctl start iptables

To save your current rule set use the following command

/usr/libexec/iptables/iptables.init save

That’s it! Your firewall rules are in place and protecting your server. Remember, you’ll need to edit the firewall rules later if you install other software or services.

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

FFMPEG install on CentOS

How to install FFMPEG and FFMPEG-PHP install on CentOS 5.X To install FFMPEG please follow the...

How to set hostname on Centos 6?

In order to permanently set hostname on Centos 6 VPS you neew to run # nano...

How to change hostname on CentOS permanently

If you are installing LAMP on a new server and ran into the following issue with httpd during the...

CentOS: Start custom script automatically after network startup

Find the ifup-post under /etc/sysconfig/network-scripts. This scipt is called right after any...

Change hostname in CentOS

How to Change Hostname - CentOSThis KB helps user to change hostname on CentOS. By default your...