save iptables so that it initiates on start up/reboot/ifup etc…

*THIS DID NOT WORK FOR US WHEN WE UPGRADED TO 8.04, Caused an error on startup and took forever to boot. We ended up using firestarter instead of iptables on 8.04* You are able to simply type “iptables-save” however the network manager apparently can interfere with this so run some tests perhaps before you trust it.

Write your IPTABLES rules

Save the current rules to a file
sudo sh -c “iptables-save > /etc/iptables.rules”
Add the restore command to the interface device that you are trying to lockdown eg eth0 (add this at the end of the eth0 section)
pre-up iptables-restore < /etc/iptables.rules
Add the post down command to the end of the network lines
post-down iptables-restore < /etc/iptables.rules

Reboot and type sudo iptables –list to see if the rules have taken

Advertisements

2 thoughts on “save iptables so that it initiates on start up/reboot/ifup etc…

  1. Pingback: Steps to consider (Post creation of Ubuntu Linux server) « RUBRIC Tech Team

  2. These instructions are a few years old but are still relevant. I’ve just successfully tested them on Ubuntu 11.10. One issue with the above instructions is that the post-down instruction should be saving the iptables’ state, not restoring it; so you don’t need to manually save the rules each time.

    # /etc/network/interfaces
    pre-up iptables-restore /etc/iptables.rules

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s