RHEL / Centos Linux Disable Firewall

Posted on in Categories , , last updated October 19, 2013

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.

[a] /etc/init.d/iptables – IPv4 iptables firewall service.

[b] /etc/init.d/ip6tables – IPv6 iptables firewall service.

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

Task: Disable firewall

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
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

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 )

Recommend readings

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

7 comment

  1. 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

    1. 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 Comment