I have just installed Ubuntu 10.10 and was searching around for the simplest way to enable a basic firewall. Instead of messing around with iptables, I’ve found a program called ufw to be a much simpler way of managing your firewall. Just install it from apt, set up a couple simple rules, and let it do it’s magic.
If you don’t already have ufw installed then run this first.
apt-get install ufw
First ufw command is to deny everything by default. (It won’t boot you until you enable it.)
ufw default deny
Next is to tell it what ports to allow traffic into. You can either use predefined application profiles or just specify the port numbers directly.
Using profiles:
ufw allow 'Apache Full' ufw allow 'OpenSSH'
Or if you just want to use port numbers:
ufw allow 80,443/tcp ufw allow 22/tcp
And now to enable the firewall, and also save the settings for reboot.
ufw enable
There you have it. Visit this help page for more examples and info.