here it is
feel free to copy/play with
lines with a # infront of them are ignored, interesting to note that ssh is listening on port 234 and we are using iptables to limit the amount of connections to that port on a per minute basis
cheers
anyweb
Code:
#!/bin/bash
# Enabled packet forwarding for vpn work
#echo 1 > /proc/sys/net/ipv4/ip_forward
# Flush Old rules on reinit of rules
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t nat -F PREROUTING
iptables -t nat -F POSTROUTING
# Set input policy
iptables -P INPUT DROP
# Accepted Hosts
iptables -A INPUT -s 100.0.0.0/8 -j ACCEPT
iptables -A INPUT -s 127.0.0.1 -j ACCEPT
iptables -A INPUT -s 81.229.167.48 -j ACCEPT
iptables -A INPUT -s 217.209.122.25 -j ACCEPT
#ipv6 tunnel hosts
#iptables -I INPUT -s 213.121.24.85 -j ACCEPT
#iptables -I INPUT -s 62.75.252.206 -j ACCEPT
# Accepted Ports
#iptables -I INPUT -p icmp -j ACCEPT
iptables -A INPUT -p tcp -m multiport --dports 80 -j ACCEPT
#iptables -A INPUT -p tcp -m multiport --dports 8000,9000,9001,9002 -j ACCEPT
#iptables -A INPUT -p udp -m multiport --dports 53 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# deny mysql from communicating outside the firewall
iptables -A OUTPUT -p tcp --sport 3306 -j DROP
## Accept ports with rate limit
iptables -A INPUT -p tcp --dport 234 -m limit --limit 2/minute --limit-burst 1 -j ACCEPT
iptables -A INPUT -p tcp --dport 234 -j REJECT --reject-with tcp-reset
# Dropped Hosts
#iptables -A INPUT -s 207.46.98.0/24 -j DROP # Ms search bot
#iptables -A INPUT -s 70.25.150.84 -j DROP # samurai and jo
# Redirect ports over the vpn to my home network
#iptables -t nat -A POSTROUTING -d 192.168.55.0/24 -j SNAT --to-source 10.20.1.1
[CODE]
####
######### IPV6
####
#ip6tables -F INPUT
#ip6tables -P INPUT ACCEPT
#ip6tables -A INPUT -p tcp --dport 113 -j ACCEPT
#ip6tables -A INPUT -p ipv6-icmp -j ACCEPT