Howto disable the iptables firewall in Linux

by Vivek Gite on April 10, 2007 · 24 comments

Q. Quick question: I need to disable firewall in Linux for testing purpose. I’m using CentOS 4.4. How do I disable the firewall in Linux?

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

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

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

Type the following command to turn on iptables firewall:
# /etc/init.d/iptables start

Other Linux distribution

If you are using other Linux distribution such as Debian / Ubuntu / Suse Linux etc, try following generic procedure.

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

Now type the following commands (login as root):
# 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

To restore or turn on firewall type the following command:
# iptables-restore < /root/firewall.rules

GUI tools

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

Howto disable the iptables firewall in Debian  / Ubuntu Linux

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 24 comments… read them below or add one }

1 mike November 23, 2007

you can get the status of iptables with the following

service iptables status

service iptables help gives:

Usage: /etc/init.d/iptables {start|stop|restart|condrestart|status|panic|save}

Reply

2 hanumanaik February 9, 2011

how to insatall CentOS 4.3 in VMWere

Reply

3 Gregory May 3, 2011

Same as on a machine…

Reply

4 Photos of China July 4, 2008

I have this error on centOS

/etc/init.d/iptables save
Usage /etc/init.d/iptables {start|output_int|stop|restart|status}

Reply

5 vivek July 4, 2008

Are you sure you got CentOS? Another option is
iptables-save > /root/working.fw

Reply

6 Flash32 October 30, 2008

Thanks Guys!!!

Reply

7 Robert December 24, 2008

The easy way to do this is:

chkconfig iptables off

then to re-enable

chkconfig –level 345 iptables on

Reply

8 joe January 5, 2009

on fedora, once you enabled firwalls/selinux during installation, I can never make nfs boot or ftp works. you can see firewall disabled, iptables disabled, yet no help. Either selinux or fedora GUI has bugs, what I get:
Loading: TFTP error 2: Only absolute filenames allowed
Failed.
to our people, the selinux is a nightmare. forget what the system told you. selinux adds extension to file attributes then some garbage cannot be removed.

Reply

9 Amie January 7, 2009

Hi – first time here and really need some help!

I gave my father in law a netbook for Xmas with Linux as an operating system but cannot connect to Sky broadband. Sky unable to help, any ideas??

Reply

10 Manu Anand January 9, 2009

Hey Amie:

Try connecting with a ethernet cable.
If that works then try KDE’s network manager.

HTH
Manu

Reply

11 Tomas February 27, 2009

Excellent!
Really Thanks

Reply

12 Ashwani April 9, 2009

Thanks for help….

FTP can be accessed by stop IP tables.

Reply

13 mallikarjun goud November 15, 2009

how to stop iptables with out chkconfig iptables off command………………..plz help me out

Reply

14 Kapil Ahire March 17, 2010

Thanks All Of you

Reply

15 Alex March 30, 2010

Hi,

I have a problem starting iptables:

[root@myserver ~]# /etc/init.d/iptables start
[root@myserver ~]# /etc/init.d/iptables status
Firewall is stopped.

[root@myserver ~]# rpm -q iptables
iptables-1.3.5-5.3.el5_4.1

Please help me solve this problem.
Thanks!
Alex

Reply

16 neha soni April 3, 2010

how can we stop the iptables service in ubuntu???
i have tried “services iptables stop” but it is giving “unrecognized service”.
is there any other command or method to do so???

Reply

17 Yogesh Kumar April 16, 2010

/etc/init.d/iptables status

if running than to stop

/etc/init.d/iptables stop

Reply

18 vijay April 17, 2010

HI,
I am very confused about iptables status.

I stopped my iptables by running ” service iptables stop”, later on i checked wheter it is really running or not by running “service iptables status”. It shows me ” Firewall is disabled”. If I run iptables -L it shows me the list of INPUT/OUTPUT/FORWARD Chains. If again i will run ” service iptables status” it will show me againall chains. What it really means, does iptables start auutomatically when I type ” iptables -L”? Please reply lots of confusion!!!

Thanks in advance.

Vijay

Reply

19 maansingh June 22, 2010

dear sir ,
how can i configure the firewall

Reply

20 quan September 13, 2010

I make iptable stop but not start it
>>

[root@FreeSX ~]# /etc/init.d/iptables start
Applying iptables firewall rules: iptables-restore: line 1 failed
[FAILED]
[root@FreeSX ~]# /etc/init.d/iptables status
Firewall is stopped.

>>
plz help me as soon as possible
thks!!!!!!

Reply

21 Tyler April 19, 2011

Debian Stable doesn’t seem to have an init.d script, or the services application, or the chkconfig application. How does one start/stop/restart the iptables service on Debian?

Reply

22 jokish May 13, 2011

Thankss a lot ………………………….. gud to learn

Reply

23 ram November 6, 2011

To stop firewall during bootup aka permanently

[root@ssd optimized]# chkconfig –list | grep iptables
iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@ssd optimized]# chkconfig –level 345 iptables off
[root@ssd optimized]# chkconfig –list | grep iptables
iptables 0:off 1:off 2:on 3:off 4:off 5:off 6:off

Reply

24 Inversys November 12, 2011

Excellent!
Thanks for all.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 12 + 13 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the simple math so we know that you are a human and not a script.




Previous post:

Next post: