Skip to content

Instantly share code, notes, and snippets.

@chenshaoju
Created July 4, 2014 01:11
Show Gist options
  • Save chenshaoju/844cab98807b40893660 to your computer and use it in GitHub Desktop.
Save chenshaoju/844cab98807b40893660 to your computer and use it in GitHub Desktop.
iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 ! -i lo -j REJECT --reject-with icmp-port-unreachable
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1010 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 1011 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 4000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p udp -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
-A INPUT -j REJECT
-A FORWARD -j REJECT
-A OUTPUT -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A PREROUTING -i eth0 -p tcp --dport 3030 -j REDIRECT --to-ports 1010
-A PREROUTING -i eth0 -p udp --dport 3030 -j REDIRECT --to-ports 1010
-A PREROUTING -i eth0 -p tcp --dport 10000:19999 -j REDIRECT --to-ports 1011
-A PREROUTING -i eth0 -p udp --dport 10000:19999 -j REDIRECT --to-ports 1011
COMMIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment