Advertisement
Guest User

Untitled

a guest
Oct 12th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #! /bin/bash
  2. # Niftiest Software – www.niftiestsoftware.com
  3. # Modified version by HTPC Guides – www.htpcguides.com
  4.  
  5. export INTERFACE="tun0"
  6. export VPNUSER="deluge"
  7. #export LOCALIP="192.168.1.130"
  8. export LOCALIP=$(hostname -i)
  9. export NETIF="eth0"
  10.  
  11.  
  12. # flushes all the iptables rules, if you have other rules to use then add them i nto the script
  13. iptables -F -t nat
  14. iptables -F -t mangle
  15. iptables -F -t filter
  16.  
  17. # mark packets from $VPNUSER
  18. iptables -t mangle -A OUTPUT -j CONNMARK --restore-mark
  19. iptables -t mangle -A OUTPUT ! --dest $LOCALIP -m owner --uid-owner $VPNUSER -j MARK --set-mark 0x1
  20. #iptables -t mangle -A OUTPUT --dest $LOCALIP -p udp --dport 53 -m owner --uid-o wner $VPNUSER -j MARK --set-mark 0x1
  21. #iptables -t mangle -A OUTPUT --dest $LOCALIP -p tcp --dport 53 -m owner --uid-o wner $VPNUSER -j MARK --set-mark 0x1
  22. iptables -t mangle -A OUTPUT ! --src $LOCALIP -j MARK --set-mark 0x1
  23. iptables -t mangle -A OUTPUT -j CONNMARK --save-mark
  24.  
  25. # allow responses
  26. iptables -A INPUT -i $INTERFACE -m conntrack --ctstate ESTABLISHED -j ACCEPT
  27.  
  28. # block everything incoming on $INTERFACE to prevent accidental exposing of port s
  29. iptables -A INPUT -i $INTERFACE -j REJECT
  30.  
  31. # let $VPNUSER access lo and $INTERFACE
  32. iptables -A OUTPUT -o lo -m owner --uid-owner $VPNUSER -j ACCEPT
  33. iptables -A OUTPUT -o $INTERFACE -m owner --uid-owner $VPNUSER -j ACCEPT
  34.  
  35. # all packets on $INTERFACE needs to be masqueraded
  36. iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE
  37.  
  38. # reject connections from predator IP going over $NETIF
  39. iptables -A OUTPUT ! --src $LOCALIP -o $NETIF -j REJECT
  40.  
  41. # Start routing script
  42. /etc/openvpn/routing.sh
  43.  
  44. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement