Basic Slicehost Slice Setup Part 2 - Configure iptables
This is part two of our series on configuring a Slicehost slice.
Step Two – Configure iptables
Backup present rules
iptables-save > /etc/iptables.up.rules
Create Filter
Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn’t use lo0sudo iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
Accepts all established inbound connections
sudo iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
Allows all outbound traffic
sudo iptables -A OUTPUT -j ACCEPT
Allows HTTP and HTTPS connections from anywhere
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
Allows SSH connections (on port 1999)
sudo iptables -A INPUT -p tcp -m state --state NEW --dport 1999 -j ACCEPT
Allow ping
sudo iptables -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
Log iptables denied calls
sudo iptables -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
Reject all other inbound - default deny unless explicitly allowed policy
sudo iptables -A INPUT -j DROP
sudo iptables -A FORWARD -j DROP
Save Rules
sudo iptables-save > /etc/iptables.up.rules
Configure Network to Load Rules Automatically
Edit network interface to load rules automatically
sudo nano /etc/network/interfaces
Add pre-up iptables-restore < /etc/iptables.up.rules after iface lo inet loopback
Part 3
Tomorrow, we look at installing OpenSSH. Don’t forget to read the first post if you missed it.
Basic Slicehost Slice Setup Series List:
- Part 1 - Updating Ubuntu
- Part 2 - Configure iptables
- Part 3 - Install and Configure OpenSSH
- Part 4 - Install nginx Web Server
- Part 5 - Installing MySQL
- Part 6 - Installing PHP5 with fastcgi
- Part 7 - Create the Virtual Host Website
- Part 8 - Install WordPress via Subversion

One Response to “Basic Slicehost Slice Setup Part 2 - Configure iptables”
-
Dave Says:
February 19th, 2009 at 12:50 pmHave you seen the Slicehost articles site? http://articles.slicehost.com

