13

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  
    

6 Answers 6

9

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

0
3

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
1
  • 1
    Thanks a lot. Indeed, the old way of doing it doesn't work in rhel 7.2
    – Oleg Gryb
    Dec 16, 2016 at 3:44
1

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

1
  • This would only work on distros which use init and not on system which use systemd or upstart.
    – ntwrkguru
    Jul 14, 2017 at 16:29
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.

1
  • 2
    That 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
    Jul 14, 2017 at 16:24
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.

0

You can achieve this in a single command with:
sudo systemctl disable --now firewalld

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .