How to permanently disable firewall in Red Hat Linux

13

5

I have followed the below steps to disable the firewall in Linux. After reboot, again firewall is enabled. How to disable firewall permanently?

  1. Login as the root user.

  2. Next enter the following three commands to disable firewall.

    service iptables save  
    service iptables stop  
    chkconfig iptables off  
    
  3. Disable IPv6 firewall.

    service ip6tables save  
    service ip6tables stop  
    chkconfig ip6tables off  
    

user354719

Posted 2014-08-08T08:48:24.267

Reputation: 131

Answers

8

For version 7 of CentOS or RedHat Enterprise you must use the command systemctl.

For example:

#Check status:

systemctl status firewalld

#Stop firewall:

systemctl stop firewalld

#Disable firewall:

systemctl disable firewalld

Extracted from: http://www.sysadmit.com/2016/12/linux-deshabilitar-firewall-redhat-centos.html

Orange the new

Posted 2014-08-08T08:48:24.267

Reputation: 81

2

FYI: This no longer works in RHEL7, and the handy init.d script has been removed.

The following worked for me.

systemctl stop firewalld
systemctl disable firewalld
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT

teknopaul

Posted 2014-08-08T08:48:24.267

Reputation: 298

Thanks a lot. Indeed, the old way of doing it doesn't work in rhel 7.2 – Oleg Gryb – 2016-12-16T03:44:31.097

1

For disabling it permanently you can remove the iptables file from the directory /etc/rc.d/init.d.

user1564218

Posted 2014-08-08T08:48:24.267

Reputation: 111

This would only work on distros which use init and not on system which use systemd or upstart. – ntwrkguru – 2017-07-14T16:29:02.203

0

You can permanently disable firewall by running iptables -F command every time you restart your linux host.

Just run below commands cd /etc/profile.d/
touch custom.sh echo "iptables -F" >>custom.sh

create custom.sh file and write your command(iptables -F) inside that file

So every time you restart your Linux host iptables -F will be executed and your firewall will be disabled. It worked for me.

Naveen Kandakur

Posted 2014-08-08T08:48:24.267

Reputation: 1

1That does not disable the firewall, it merely flushes all of the rules. Rules can still be added by other applications after you flush them. A prime example would be Docker containers and the associated chains. – ntwrkguru – 2017-07-14T16:24:21.740

0

I followed @teknopaul answer and it worked fine both iptables and firewalld are stopped and inactive, however, if after reboot you still see some rules on running command iptables -L than check for your network interfaces by command ifconfig. If you see network interface virbr0 then disable it using commands

systemctl stop libvirtd.service
systemctl disable libvirtd.service

Now when you reboot the machine and run iptables -L you will see no rules and if you run ifconfig you will not see virbr0.

Mian Asbat Ahmad

Posted 2014-08-08T08:48:24.267

Reputation: 131