Hi,
for this you can use iptables. This determines what can go in and out on each port for each interface for each protocol (if you see what I mean). An easy way to configure this is to use webmin (
www.webmin.com). Also, a quick google seach for "iptables howto" gives some handy results.
I hope this helps!
Radam