Advertisement
Guest User

Untitled

a guest
Nov 17th, 2012
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.43 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. EXTIF=eth0
  4. INTIF=eth1
  5. INTIF2=wlan0
  6.  
  7. # delete all existing rules
  8. iptables -F
  9. iptables -t nat -F
  10. iptables -t mangle -F
  11. iptables -X
  12.  
  13. # Always accept loopback traffic
  14. iptables -A INPUT -i lo -j ACCEPT
  15.  
  16. # Allow established connections, and those not coming from the outside
  17. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  18. iptables -A INPUT -m state --state NEW -i $INTIF -j ACCEPT
  19. iptables -A INPUT -m state --state NEW -i $INTIF2 -j ACCEPT
  20. iptables -A FORWARD -i $EXTIF -o $INTIF -m state --state ESTABLISHED,RELATED -j ACCEPT
  21. iptables -A FORWARD -i $EXTIF -o $INTIF2 -m state --state ESTABLISHED,RELATED -j ACCEPT
  22.  
  23. # Allow outgoing connections from the LAN side
  24. iptables -A FORWARD -i $INTIF -o $EXTIF -j ACCEPT
  25. iptables -A FORWARD -i $INTIF2 -o $EXTIF -j ACCEPT
  26.  
  27. # Connect LANs
  28. iptables -A FORWARD -i $INTIF -o $INTIF2 -j ACCEPT
  29. iptables -A FORWARD -i $INTIF2 -o $INTIF -j ACCEPT
  30.  
  31. # Masquerade
  32. iptables -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
  33.  
  34. # Don't forward from the outside to the inside
  35. iptables -A FORWARD -i $EXTIF -o $EXTIF -j REJECT
  36. iptables -A FORWARD -i $EXTIF -o $INTIF -j REJECT # masked for ssh to LAN
  37. iptables -A FORWARD -i $EXTIF -o $INTIF2 -j REJECT # masked for ssh to LAN
  38.  
  39. # MTU
  40. iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
  41.  
  42. echo 1 > /proc/sys/net/ipv4/ip_forward
  43.  
  44. for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement