Use those iptables…

If you can’t rely on your local network being firewalled the onus is on you to make sure that you have a firewall running on your computer. On linux you have iptables, which is remarkably easy to use if you have at least a basic understanding of how networking works (and/or google). Without going into details, you REALLY, REALLY. REALLY need to have your OWN firewall running if you are based at Umeå University.

Your needs may vary, but here’s a script that you can put in e.g. /etc/

Have it called from /etc/rc.local so that it starts during boot.


sudo iptables -F #FLUSH
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT #allows network
sudo iptables -A INPUT -i lo -j ACCEPT #
sudo iptables -A INPUT -s -j ACCEPT
sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT #ssh -world!
sudo iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT -s #ping
sudo iptables -A INPUT -d -j ACCEPT #broadcast traffic
sudo iptables -A INPUT -m limit --limit 15/minute -j LOG --log-level 7 --log-prefix " Dropped by firewall "
sudo iptables -A INPUT -m limit --limit 15/minute -j LOG --log-level 4 --log-prefix "[netfilter]"
sudo iptables -A INPUT -j DROP #drop all else
sudo iptables -A OUTPUT -o lo -j ACCEPT #
sudo iptables -A OUTPUT -j ACCEPT #all outgoing ok
sudo iptables -A FORWARD -p icmp --icmp-type 8 -j ACCEPT
#Default behaviour
sudo iptables -P INPUT DROP
sudo iptables -P OUTPUT DROP
sudo iptables -P FORWARD DROP
exit 0

Leave a Reply

Your email address will not be published. Required fields are marked *