RHEL / Centos Linux Disable Firewall Command

How do I disable firewall on CentOS or Red Hat Enterprise Linux server version 5.x/6.x running on my HP micro server?

You need to disable the following services to disable firewall under Red Hat Enterprise Linux or CentOS Linux version 4 / 5 / 6. The following commands also works on Fedora or Scientific Linux older version.

RHEL / Centos Linux Disable Firewall Command Line Option

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements iptables
Est. reading time 2m
The following two services are used by RHEL / CentOS 6.x:
  1. /etc/init.d/iptables – IPv4 iptables firewall service.
  2. /etc/init.d/ip6tables – IPv6 iptables firewall service.

You can use the service command to control firewall settings on RHEL or CentOS based systems.

Task: Disable firewall on RHEL

First login as root user either using the su command or sudo command:
su -
OR
sudo -
Type the following command as the root user to disable firewall for IPv4:
# service iptables save
# service iptables stop
# chkconfig iptables off

Sample outputs:

iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]

Sample output with verification (see below):

Red Enterprise Linux Disable Iptables IPv4 Firewall

Type the following command as the root user to disable firewall for IPv6 :
# service ip6tables save
# service ip6tables stop
# chkconfig ip6tables off
ip6tables: Flushing firewall rules:                        [  OK  ]
ip6tables: Setting chains to policy ACCEPT: filter         [  OK  ]
ip6tables: Unloading modules:                              [  OK  ]

Disable firewall on CentOS 6

You can also use the following command:
# /etc/init.d/iptables save
# /etc/init.d/iptables stop
# chkconfig iptables off
## IPv6 firewall
# /etc/init.d/ip6tables save
# /etc/init.d/ip6tables stop
# chkconfig ip6tables off

Task: Enable firewall

Type the following command as the root user to enable firewall for IPv4:
# service iptables start
# chkconfig iptables on

Sample outputs:

iptables: Applying firewall rules:                         [  OK  ]

Type the following command as the root user to disable firewall for IPv6 :
# service ip6tables start
# chkconfig ip6tables on

Task: Verify that firewall is disabled

Type the following command as root user to see IPv4 firewall rules:
# /sbin/iptables -L -v -n
OR
# service iptables status
The following output indicates that firewall is not active:

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Type the following command as root user to see IPv6 firewall rules:
# /sbin/ip6tables -L -v -n
OR
# service ip6tables status

Check out related media

This tutorial is also available in a quick video format:

(Video 01: CentOS / Red Hat IPTABLES: Deleting [DROP] and Flushing All Firewall Rules )
Conlusion

You learned how to turn off and disable RHEL and CentOS Linux firewall using the command line options. For more info see the following tutorials:


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • Raul Hernandez Feb 13, 2013 @ 12:31

    Estupenda informacion. Clara y justo lo que necesitaba.
    Muchas gracias

  • Sinan E. Nov 21, 2013 @ 10:09

    Worked for me @centOS 6.4
    Thanks.

  • Wellington Torrejais da Silva Jun 24, 2014 @ 13:56

    Thanks!!!

  • Rehmat Oct 20, 2014 @ 15:57

    Very informative i learn a lot thank you.

  • Ijtaba Hussain Feb 23, 2015 @ 10:47

    The command for enabling and disabling IPV6 firewall is listed as:
    # chkconfig ip6tables on

    Probably should be:
    # chkconfig ip6tables off

  • Ryan Mar 4, 2015 @ 12:21

    But when i ran that commends nothing happened
    what is the problem.
    [root@localhost ~]# # service ip6tables status
    [root@localhost ~]# # chkconfig iptables off
    [root@localhost ~]# # chkconfig iptables on
    [root@localhost ~]# # service ip6tables start
    [root@localhost ~]# /etc/init.d/iptables
    Usage: iptables {start|stop|reload|restart|condrestart|status|panic|save}
    [root@localhost ~]# /etc/init.d/ip6tables
    Usage: ip6tables {start|stop|reload|restart|condrestart|status|panic|save}
    [root@localhost ~]# # service iptables save
    [root@localhost ~]# # service iptables stop
    [root@localhost ~]# # chkconfig iptables off
    [root@localhost ~]# # service iptables start
    [root@localhost ~]# # chkconfig ip6tables on
    [root@localhost ~]#
    samba is not working in my system.So the problem might be in this???
    help me
    thanks advance

    • Ryan Mar 4, 2015 @ 12:26

      hi sorry.
      i am using centos 6.6.
      this is running in following commend.

      root@localhost ~]# /sbin/service iptables start
      iptables: Applying firewall rules: [ OK ]
      [root@localhost ~]# /sbin/service iptables restart
      iptables: Setting chains to policy ACCEPT: filter [ OK ]
      iptables: Flushing firewall rules: [ OK ]
      iptables: Unloading modules: [ OK ]
      iptables: Applying firewall rules:

      may i know why the samba server cannot accesses in windows machine?
      I have used yesteday in windows system before reinstalled the centos.
      But why samba is not running now.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum