Ubuntu iptables configuration

My server which I am hosting this blog on runs Ubuntu Linux 5.10, I have been meaning to configure iptables to lock down the open ports.

I am not going to explain the configuration of iptables here, but there are many guides available.

Now you have created your iptables rules they are stored in memory and when you reboot your machine will be lost sad.png.

I found a solution to the problem on the Ubuntu Forums.

First off we need to create /etc/init.d/iptables and populate it, I have a put a copy of the iptables script on my server for you to download.

# cd /etc/init.d/
# wget http://files.toonarmy.mine.nu/iptables

MD5 Sum: 7cf9c61f8d284f65b99781c2d3355747

/etc/init.d/iptables needs to be executable:

# chmod +x /etc/init.d/iptables

Next we need to get iptables loaded at boot time before networking, this can be done with the following command:

# update-rc.d iptables start 37 S . stop 37 0 .

Now we have to save our current rules from memory to file so they are loaded at each boot.

# /etc/init.d/iptables save

A word of warning calling /etc/init.d/iptables stop twice in a row will clear your iptables configuration. I would advise you to make a backup of /etc/default/iptables-rules I use a simple copy command:

# cp /etc/default/iptables-rules /etc/default/iptables-rules~

Source

Note: This is mainly for my own reference but others may find it handy wink.png

Playing:

Red Hot Chili Peppers - By The Way

About Chris

Twenty-something year old computer science graduate living in the West Midlands, working as a PHP software developer for a local company.
This entry was posted in Linux, Ubuntu. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>