The linux kernel itself has a command line accessible firewall that works barebone:
man iptables
This is usually used by the internet service providers, because it is very low on resources, but is very hard to configure (it requires advanced administrator skills).