I have followed the below steps to disable the firewall in Linux. After reboot, again firewall is enabled. How to disable firewall permanently?
Login as the root user.
Next enter the following three commands to disable firewall.
service iptables save service iptables stop chkconfig iptables offDisable IPv6 firewall.
service ip6tables save service ip6tables stop chkconfig ip6tables off
5 Answers
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 firewalldExtracted from:
0FYI: 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 For disabling it permanently you can remove the iptables file from the directory /etc/rc.d/init.d.
1You 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.
1I 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.serviceNow when you reboot the machine and run iptables -L you will see no rules and if you run ifconfig you will not see virbr0.