How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7

On the journey of exploring the newly releaed CentOS 7 . I found another interesting thing. This is related to iptables. In previous CentOS versions, we used to stop iptables service by using the command service iptables stop or /etc/init.d/iptables stop

On newly shined CentOS 7 / Red Hat 7 , with systemctl command we can control the service status.

To start/stop/restart/reload the iptables on CentOS 7 / RHEL 7 , follow the given below steps

Step 1 : Install iptables-services

yum install iptables-services

Step 2 : Manage iptables with systemctl

Use the below given syntax
systemctl [stop|start|restart|reload] iptables

Example.

To start iptables

systemctl start iptables

To stop iptables

systemctl stop iptables

To restart iptables

systemctl restart iptables

To reload iptables

systemctl reload iptables

We strongly suggest to use firewalld instead of iptables.


Posted

in

by

Tags:

Comments

6 responses to “How to start / stop / restart / reload iptables on CentOS 7 / RHEL 7”

  1. UnixNewbie Avatar
    UnixNewbie

    thank you. you are a lifesaver!

  2. Phoenix Kiula Avatar
    Phoenix Kiula

    Why do you strongly suggest firewalld instead of iptables?

  3. Nan Xiao Avatar
    Nan Xiao

    “another interesting thing”, not “another intersting thing”.

    1. sharad chhetri Avatar

      Thank You Nan Xiao,

      In very less word you really directed me to typo in this post.

      Regards
      Sharad

  4. dipanjan mukherjee Avatar
    dipanjan mukherjee

    you also need to run systemctl enable iptables. Because in RHEL/CentOS 7 no chkconfig command as well.

    1. sharadchhetri Avatar
      sharadchhetri

      Thankyou Dipanjan,

      Awesome
      You are correct. “systemctl enable iptables” is for enabling the iptables service at runlevels .
      In coming soon post, systemctl command will be written with more details and example. I will also include this example in it.
      Regards
      Sharad

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: