How can I start/stop the iptables service on Ubuntu?
I have tried
service iptables stop
but it is giving "unrecognized service".
Why is it doing so? Is there any other method?
I don't know about "Ubuntu", but in Linux generally, "iptables" isn't a service - it's a command to manipulate the netfilter kernel firewall. You can "disable" (or stop) the firewall by setting the default policies on all standard chains to "ACCEPT", and flushing the rules.
(You may need to flush other tables, too, such as "nat", if you've used them)
The following article on the Ubuntu website describes setting up iptables for use with NetworkManager: https://help.ubuntu.com/community/IptablesHowTo
I would first check if it is installed with (it probably is):
On Ubuntu, iptables is not a service.
In order to stop it, you have to do the following :
In order to restore your previous rules :
This was taken from http://www.cyberciti.biz/faq/turn-on-turn-off-firewall-in-linux/ and was tested on many Ubuntu 8.X & 9.10 installations.
Iptables is a command it's not a service, so generally it's not possible to use commands like
in order to start and stop the firewall, but some distros like centos have installed a service called iptables to start and stop the firewall and a configuration file to configure it. Anyway it's possible to make a service to manage ipotables editing or installing a script for this scope. All services in linux, ubuntu is not an exception, are executable scripts inside /etc/init.d folder, that implements a standard interface (start,stop,restart) A possible script looks like this:
This script is part of this tutorial, all the commands to configure the firewall must be inserted, according to the script above, into /etc/iptables.conf file. This script must be inserted into a file called iptables in /etc/init.d and make it executable using
and add the service to runlevels using
You can add new rules from shell, these rules will be immediatly active and will be added to /etc/iptables.conf when service stops(it means them will be saved for sure when system shutdown).
I hope this will be helpful to everyone.
If I recall correctly the suggested way to set up iptables in the ubuntu guides is to set it up as part of the networking scripts. which means there is no /etc/init.d/iptables script like there is in BSD style OS's.
Looks like there several ways to manage firewall in Ubuntu, so you may be interested in reading this: https://help.ubuntu.com/community/IptablesHowTo#Configuration%20on%20startup
To drop all current rules you can use these commands (put them in some script):
In usual case, your default firewall rules saved in some file (for example, /etc/iptables.rules). While booting system command
Create a file on /etc/init.d/
Make the file executable chmod +x
Make a symlink to that file on /etc/rc2.d/
Edit S80firewall and add the following
You can add all your custom iptables rules on this file
Now you can restart firewall (iptables) by running /etc/rc2.d/S80firewall (must be root)
I had an issue that involved only needing to restart the service, this did the trick: