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.

https://help.ubuntu.com/community/IptablesHowTo »

Page Comments (Click to edit)

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Powered by pmwiki-2.2.0-beta65