I've had a bit of help but I'm still a bit unsure. I have an nginx webserver with SSH only required. I wrote this rule set based on information I found on the internet:
i=/sbin/iptables
# Flush all rules
$i -F
$i -X
# Setup default filter policy
$i -P INPUT DROP
$i -P OUTPUT DROP
$i -P FORWARD DROP
# DONT KNOW WHAT THESE DO
$i -A INPUT -i lo -j ACCEPT
$i -A INPUT -p icmp --icmp-type any -j ACCEPT
# Force SYN checks
$i -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
# Drop all fragments
$i -A INPUT -f -j DROP
# Drop XMAS packets
$i -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
# Drop NULL packets
$i -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
# Allow established connections
$i -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow unlimited traffic on loopback
$i -A INPUT -i lo -j ACCEPT
$i -A OUTPUT -o lo -j ACCEPT
# Open nginx
$i -A INPUT -p tcp --dport 443 -j ACCEPT
$i -A INPUT -p tcp --dport 80 -j ACCEPT
# Open SSH
$i -A INPUT -p tcp --dport 22 -j ACCEPT
Can anyone please tell me if I am taking the right approach here, and if I can improve it in any way?