View Full Version : [ubuntu] [SOLVED] Problems saving iptables setup

June 5th, 2008, 02:51 PM
Hi all,

I have been using the excellent IPTables HowTo (https://help.ubuntu.com/community/IptablesHowTo).

You are supposed to be able to save your current setup using the following command:

sudo iptables-save > /etc/iptables.rules
However when I try this I get the following:

-bash: /etc/iptables.rules: Permission denied
The really strange thing is I can edit the file directly with an editor (sudo vim /etc/iptables.rules).

Any ideas?

June 5th, 2008, 04:56 PM
sudo runs iptables-save as root, then you're piping the result of the sudo command as your regular user to /etc/iptables.rules. However, you don't have permission to create a file in /etc. This is the only annoying thing about sudo. Try this, instead.

sudo bash -c "iptables-save > /etc/iptables.rules"

June 5th, 2008, 08:03 PM
Just like the man said.

Thanks cdenley :)

May 18th, 2010, 02:21 PM
Cool bananas .... thanks a mil :)