tovis

Gateway script for RPI using HUAWEI E3372 LTE

Feb 21st, 2016
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. # simple gateway script working on Raspberry PI with HUAWEI E3372 LTE
  2. #
  3. #!/bin/sh
  4.  
  5. PATH=/usr/sbin:/sbin:/bin:/usr/bin
  6. LAN="eth0"
  7. NET="ppp0"
  8.  
  9. #
  10. # delete all existing rules.
  11. #
  12. iptables -F
  13. iptables -t nat -F
  14. iptables -t mangle -F
  15. iptables -X
  16.  
  17. # Always accept loopback traffic
  18. iptables -A INPUT -i lo -j ACCEPT
  19.  
  20.  
  21. # Allow established connections, and those not coming from the outside
  22. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  23. iptables -A INPUT -m state --state NEW -i ! $NET -j ACCEPT
  24. iptables -A FORWARD -i $NET -o $LAN -m state --state ESTABLISHED,RELATED -j ACCEPT
  25.  
  26. # Allow outgoing connections from the LAN side.
  27. iptables -A FORWARD -i $LAN -o $NET -j ACCEPT
  28.  
  29. # Masquerade.
  30. iptables -t nat -A POSTROUTING -o $NET -j MASQUERADE
  31.  
  32. # Don't forward from the outside to the inside.
  33. iptables -A FORWARD -i $NET -o $NET -j REJECT
  34.  
  35. # Enable routing.
  36. echo 1 > /proc/sys/net/ipv4/ip_forward
Advertisement
Add Comment
Please, Sign In to add comment