"Ubuntu
as any other Linux distribution comes with netfilter iptables as default firewall. This is one of the best firewall software for Unix family operating systems: it allows to perform various filtering operations and makes it possible to match packets using numerous ways starting from data in IP packet header and ending with Layer 7 packet inspection (but this is another topic).
Below you can find a list of articles on the Web helping to understand the logic of Ubuntu iptables setup as well as create powerful firewall from your Ubuntu system:"
http://www.linuxscrew.com/2009/01/22...bles-firewall/