Advertisement
Guest User

blah2.0

a guest
Nov 21st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. #!/bin/sh
  2. EOF PRIVATE_IP=`wget -q -O - 'http://169.254.169.254/latest/meta-data/local-ipv4'`
  3. PUBLIC_IP=`wget -q -O - 'http://169.254.169.254/latest/meta-data/public-ipv4'`
  4. /bin/cp -f /etc/iptables.rules /etc/iptables.rules.old
  5. cat > /etc/iptables.rules <<EOF
  6. *filter
  7. :INPUT ACCEPT [0:0]
  8. :FORWARD ACCEPT [0:0]
  9. :OUTPUT ACCEPT [0:0]
  10. :ICMPALL - [0:0]
  11. :ZREJ - [0:0]
  12. -A INPUT -m conntrack --ctstate INVALID -j DROP
  13. -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  14. -A INPUT -i lo -j ACCEPT
  15. -A INPUT -p icmp --icmp-type 255 -j ICMPALL
  16. -A INPUT -p udp --dport 67:68 --sport 67:68 -j ACCEPT
  17. -A INPUT -p tcp --dport 22 -j ACCEPT
  18. -A INPUT -p udp -m multiport --dports 500,4500 -j ACCEPT
  19. -A INPUT -p udp --dport 1701 -m policy --dir in --pol ipsec -j ACCEPT
  20. -A INPUT -p udp --dport 1701 -j DROP
  21. -A INPUT -j ZREJ
  22. -A FORWARD -i eth+ -o ppp+ -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  23. -A FORWARD -i ppp+ -o eth+ -j ACCEPT
  24. -A FORWARD -j ZREJ
  25. -A ICMPALL -p icmp --fragment -j DROP
  26. -A ICMPALL -p icmp --icmp-type 0 -j ACCEPT
  27. -A ICMPALL -p icmp --icmp-type 3 -j ACCEPT
  28. -A ICMPALL -p icmp --icmp-type 4 -j ACCEPT
  29. -A ICMPALL -p icmp --icmp-type 8 -j ACCEPT
  30. -A ICMPALL -p icmp --icmp-type 11 -j ACCEPT
  31. -A ICMPALL -p icmp -j DROP
  32. -A ZREJ -p tcp -j REJECT --reject-with tcp-reset
  33. -A ZREJ -p udp -j REJECT --reject-with icmp-port-unreachable
  34. -A ZREJ -j REJECT --reject-with icmp-proto-unreachable
  35. COMMIT
  36. *nat
  37. :PREROUTING ACCEPT [0:0]
  38. :INPUT ACCEPT [0:0]
  39. :OUTPUT ACCEPT [0:0]
  40. :POSTROUTING ACCEPT [0:0]
  41. -A POSTROUTING -s 192.168.42.0/24 -o eth+ -j SNAT --to-source ${PRIVATE_IP}
  42. COMMIT
  43. EOF
  44.  
  45. cat > /etc/network/if-pre-up.d/iptablesload <<EOF
  46. #!/bin/sh
  47. /sbin/iptables-restore < /etc/iptables.rules
  48. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement