Share Pastebin
Guest
Public paste!

transparent_proxysh

By: a guest | Apr 28th, 2008 | Syntax: Bash | Size: 1.44 KB | Hits: 98 | Expires: Never
Copy text to clipboard
  1. #!/bin/sh
  2. iptables -t nat -F  # clear table
  3. iptables -t nat -X
  4. iptables -t filter -F
  5. iptables -t filter -X
  6.  
  7. # bypass laptop
  8. iptables -t nat -A PREROUTING -p tcp -i eth1 -s 192.168.0.27 -j ACCEPT
  9.  
  10. # chains
  11. iptables -t nat -N REDGUARDIAN
  12. iptables -t nat -N REDSQUID
  13.  
  14. # normal transparent proxy
  15. iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 80 -j REDIRECT --to-port 8080
  16. iptables -t nat -A PREROUTING -p tcp -i eth1 --dport 21 -j REDIRECT --to-port 2121
  17.  
  18. # handle connections on the same box (192.168.0.2 is a loopback instance)
  19. gid=`id -g proxy`
  20. dgid=`id -g dansguardian`
  21. iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner $gid  -j ACCEPT
  22. iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner $dgid -j ACCEPT
  23. iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner 1000 -j ACCEPT
  24. iptables -t nat -A OUTPUT -p tcp --dport 80 -m owner --gid-owner 0 -j ACCEPT
  25. iptables -t nat -A OUTPUT -p tcp --dport 21 -m owner --gid-owner $gid -j ACCEPT
  26. iptables -t nat -A OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j ACCEPT
  27. iptables -t nat -A OUTPUT -p tcp -d 192.168.0.5 --dport 80 -j ACCEPT
  28. iptables -t nat -A OUTPUT -p tcp -d 192.168.0.27 --dport 80 -j ACCEPT
  29. iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 192.168.0.1:3128
  30. #iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination 192.168.0.1:8080
  31. iptables -t nat -A OUTPUT -p tcp --dport 21 -j DNAT --to-destination 192.168.0.1:2121