Simple firewall script to allow ssh and web traffic
#!/bin/bash ### flush out all rules iptables -F ### allow loopback iptables -I INPUT 1 -i lo -j ACCEPT ### start by allowing establish sessions iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT ### allow ssh before blocking everything else iptables -A INPUT -p tcp --dport ssh -j ACCEPT ### allow web traffic iptables -A INPUT -p tcp --dport 80 -j ACCEPT ### block all other traffic iptables -A INPUT -j DROP
Run iptables-save to save your rules when rebooting. iptables-restore brings them back. I'm not quite sure how this works, so read up.
