Disable iptables Firewall in Linux


To totally unlock this section you need to Log-in


Login

A Linux firewall is software based firewall that provides protection between your server (workstation) and damaging content on the Internet or network. It will try to guard your computer against both malicious users and software such as viruses/worms.

Check the Status of The Iptables Firewall

Run the following command to check the status of the iptables IPv4 firewall:

# service iptables status

Run the following command to check the status of the iptables IPv6 firewall:

# service ip6tables status

Disable / Turn off Linux Firewall (Red hat/CentOS/Fedora Core)

Type the following two commands (you must login as the root user):

# /etc/init.d/iptables save
# /etc/init.d/iptables stop

Turn off firewall on boot:

# chkconfig iptables off

Enable / Turn on Linux Firewall (Red hat/CentOS/Fedora Core)

Type the following command to turn on iptables firewall:

# /etc/init.d/iptables start

Turn on firewall on boot:

# chkconfig iptables on

A note about other Linux distribution

If you are using other Linux distribution such as Debian / Ubuntu / Suse / Slakcware Linux etc., try the following generic procedure. First, save the current firewall rules, type:

# iptables-save > /root/firewall.rules

OR
$ sudo iptables-save > /root/firewall.rules

Next, type the following commands (login as the root) as bash prompt:

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 OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

Or create a shell script as follows and run it to disable the firewall:

#!/bin/bash
# reset.fw - Reset firewall
# set x to 0 - No reset
# set x to 1 - Reset firewall
# ---------------------------------------------------------------------------------------------------------------
# Added support for IPV6 Firewall
# ---------------------------------------------------------------------------------------------------------------
# Written by Vivek Gite 
# ---------------------------------------------------------------------------------------------------------------
# You can copy / paste / redistribute this script under GPL version 2.0 or above
# =============================================================
x=1

# set to true if it is CentOS / RHEL / Fedora box RHEL=false
### no need to edit below ### IPT=/sbin/iptables IPT6=/sbin/ip6tables
if [ "$x" == "1" ]; then if [ "$RHEL" == "true" ]; then # reset firewall using redhat script /etc/init.d/iptables stop /etc/init.d/ip6tables stop else # for all other Linux distro use following rules to reset firewall ### reset ipv4 iptales ### $IPT -F $IPT -X $IPT -Z for table in $(</proc/net/ip_tables_names) do $IPT -t $table -F $IPT -t $table -X $IPT -t $table -Z done $IPT -P INPUT ACCEPT $IPT -P OUTPUT ACCEPT $IPT -P FORWARD ACCEPT ### reset ipv6 iptales ### $IPT6 -F $IPT6 -X $IPT6 -Z for table in $(</proc/net/ip6_tables_names) do $IPT6 -t $table -F $IPT6 -t $table -X $IPT6 -t $table -Z done $IPT6 -P INPUT ACCEPT $IPT6 -P OUTPUT ACCEPT $IPT6 -P FORWARD ACCEPT fi else : fi

To restore or turn on firewall type the following command:

# iptables-restore < /root/firewall.rules

Stop and Disable Firewalld on CentOS 7

Firewalld is a complete firewall solution that has been made available by default on all CentOS 7 servers, including Liquid Web Core Managed CentOS 7, and Liquid Web Self Managed CentOS 7. On occasion, perhaps for testing, disabling or stopping firewalld may be necessary. Follow the instructions below to disable firewalld and stop firewalld.

NOTE: It is highly recommended that you have another firewall protecting your network or server before, or immediately after, disabling firewalld.

Disable Firewalld

To disable firewalld, run the following command as root:

systemctl disable firewalld

Stop Firewalld

To stop firewalld, run the following command as root:

systemctl stop firewalld

Check the Status of Firewalld

And finally, to check the status of firewalld, run the following command as root:

GUI tools

If you are using GUI desktop firewall tools such as 'firestarter', use the same tool to stop the firewall. Visit System > Administration > firestarter > click on Stop Firewall button.

Disable iptables Firewall in Linux