#!/bin/sh # Change the part after the = to the where you # IPTABLES is on your system IPTABLES=/sbin/iptables # Flush existing rules $IPTABLES -F INPUT # Allow connections going outbound # from this machine to reply back $IPTABLES -A INPUT -j ACCEPT -m state --state \ ESTABLISHED -i eth0 -p icmp $IPTABLES -A INPUT -j ACCEPT -m state --state \ ESTABLISHED -i eth0 -p tcp $IPTABLES -A INPUT -j ACCEPT -m state --state \ ESTABLISHED -i eth0 -p udp #Allow incoming SSH requests $IPTABLES -A INPUT -p tcp --dport 22 -j ACCEPT #Allow incoming DNS $IPTABLES -A INPUT -p udp --dport 53 -j ACCEPT $IPTABLES -A INPUT -p tcp --dport 53 -j ACCEPT #Allow incoming HTTP requests (to Web server) $IPTABLES -A INPUT -p tcp --dport 80 -j ACCEPT $IPTABLES -A INPUT -p tcp --dport 443 -j ACCEPT #Allow Ping echo $IPTABLES -A INPUT -p icmp -j ACCEPT # Load Modules insmod ip_conntrack_ftp insmod ipt_LOG insmod ipt_REJECT insmod ipt_limit insmod ipt_state # The logging is set so if more than 5 packets are dropped # in three seconds they will be ignored. This # helps to prevent a DOS attack # Crashing the computer the firewall is running on $IPTABLES -A INPUT -m limit --limit 3/second \ --limit-burst 5 -i ! lo -j LOG # Drop and log all other data $IPTABLES -A INPUT -i ! lo -j DROP