Ubuntu Server Configuration

A few random notes.

To start the iptables rules for the firewall on startup, first, create the firewall script, adding the iptables rules one by one, and save the rules with:

iptables-save > /etc/default/iptables

Then, to load the rules automatically with the new Upstart init system, I just create a new file, /etc/event.d/iptables :

# Script to start firewall
# Save rules with iptables-save > /etc/default/iptables

start on runlevel 1
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5

exec /sbin/iptables-restore < /etc/default/iptables

That way, you aren’t changing any existing files, just adding the new one. On every reboot, the iptables rules get loaded. You can check that they are loaded with:

sudo /sbin/iptables-save | less

Leave a Reply

Your email address will not be published.