Advertisement
Guest User

Untitled

a guest
Oct 4th, 2015
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. # Squid transparent proxy
  2. PROXY_IPV4="192.168.x.x"
  3. PROXY_IPV6="xxxx:xxxx:xxxx:xxxx::x"
  4. CLIENTIFACE=br0
  5. FWMARK=3
  6.  
  7. iptables -t mangle -A PREROUTING -i $CLIENTIFACE -p tcp --dport 80 -s $PROXY_IPV4 -j ACCEPT
  8. ip6tables -t mangle -A PREROUTING -i $CLIENTIFACE -p tcp --dport 80 -s $PROXY_IPV6 -j ACCEPT
  9.  
  10. iptables -t mangle -A PREROUTING -i $CLIENTIFACE -p tcp --dport 80 -j MARK --set-mark $FWMARK
  11. iptables -t mangle -A PREROUTING -m mark --mark $FWMARK -j ACCEPT
  12. ip6tables -t mangle -A PREROUTING -i $CLIENTIFACE -p tcp --dport 80 -j MARK --set-mark $FWMARK
  13. ip6tables -t mangle -A PREROUTING -m mark --mark $FWMARK -j ACCEPT
  14.  
  15. iptables -t filter -A FORWARD -i $CLIENTIFACE -o $CLIENTIFACE -p tcp --dport 80 -j ACCEPT
  16. ip6tables -t filter -A FORWARD -i $CLIENTIFACE -o $CLIENTIFACE -p tcp --dport 80 -j ACCEPT
  17.  
  18. ip rule add fwmark $FWMARK table 2
  19. ip -6 rule add fwmark $FWMARK table 2
  20. ip route add default via $PROXY_IPV4 table 2
  21. ip -6 route add default via $PROXY_IPV6 table 2
  22.  
  23. # End Squid intercept proxy config
  24.  
  25. iptables -F -t mangle
  26. iptables -X -t mangle
  27. ip6tables -F -t mangle
  28. ip6tables -X -t mangle
  29. iptables -t mangle -N DIVERT
  30. ip6tables -t mangle -N DIVERT
  31.  
  32. iptables -t mangle -A DIVERT -j MARK --set-mark 1
  33. iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
  34. iptables -t mangle -A DIVERT -j ACCEPT
  35. iptables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 3129
  36.  
  37. ip6tables -t mangle -A DIVERT -j MARK --set-mark 1
  38. ip6tables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
  39. ip6tables -t mangle -A DIVERT -j ACCEPT
  40. ip6tables -t mangle -A PREROUTING -p tcp --dport 80 -j TPROXY --tproxy-mark 0x1/0x1 --on-port 3129
  41.  
  42. ip -f inet rule add fwmark 1 lookup 100
  43. ip -f inet route add local default dev eno1 table 100
  44.  
  45. ip -f inet6 rule add fwmark 1 lookup 100
  46. ip -f inet6 route add local default dev eno1 table 100
  47.  
  48. http_port 3129 tproxy
  49.  
  50. net.ipv4.ip_forward = 1
  51. net.ipv4.conf.default.rp_filter = 0
  52. net.ipv4.conf.all.rp_filter = 0
  53. net.ipv4.conf.lo.rp_filter = 0
  54. net.ipv4.conf.eno1.rp_filter = 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement