Advertisement
Guest User

up.sh

a guest
May 20th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. #! /bin/bash
  2. # This script enables policy routing after the tunnel interface is brought up
  3. # Policy routing is used to make sure response packets go through the tunnel interface
  4. # This is mandatory when your ISP has setup anti-spoofing filters
  5.  
  6. # Add a default route via tun0 into the VPN routing table
  7. ip route add default dev $1 table VPN
  8.  
  9. # Pass traffic from lo:1 (192.168.10.1) to the VPN routing table, using policy routing ("ip rule" commands)
  10. ip rule add from 192.168.10.1/32 table VPN
  11.  
  12. # Pass traffic from tur0 IP address to the VPN routing table
  13. ip rule add from $4/32 table VPN
  14.  
  15. #sed -i 's/\(\"bind-address-ipv4\":\).*/\1\ \"'"$4"'\",/' /etc/transmission-daemon/settings.json
  16.  
  17. #On ajoute les règles iptables pour faire le NAT
  18.  
  19. # Source NAT and destination NAT rules to make sure the incoming and ougoing packets on 192.168.10.1 are $
  20. iptables -A PREROUTING -t nat -i $1 -p tcp --dport 443 -j DNAT --to 192.168.10.1
  21. iptables -A PREROUTING -t nat -i $1 -p udp --dport 443 -j DNAT --to 192.168.10.1
  22. iptables -A POSTROUTING -t nat -o $1 -j MASQUERADE
  23. # Allow session continuation traffic
  24. iptables -A INPUT -i $1 -m state --state RELATED,ESTABLISHED -j ACCEPT
  25. # Allow Bittorrent traffic via tun0
  26. iptables -A SERVICES -p tcp --dport 51413 -j ACCEPT # rTorrent random range
  27. iptables -A SERVICES -p udp --dport 51413 -j ACCEPT # DHT
  28.  
  29. # Disallow BitTorrent traffic via eth0 - Just to be extra safe ;)
  30. iptables -A FORWARD -s 192.168.10.1/32 -o eth0 -j DROP
  31.  
  32. #Démarrage de transmission
  33. /etc/init.d/transmission-daemon restart
  34.  
  35. #Démarrage du script vérifiant que le VPN est toujours actif
  36. killall checkVPN
  37. /usr/bin/checkVPN &
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement