Jason
5 years ago
2 changed files with 62 additions and 7 deletions
@ -0,0 +1,41 @@ |
|||
#!/bin/sh |
|||
|
|||
TUN="${TUN:-utun0}" |
|||
ETH="${ETH:-eth0}" |
|||
ETHGW="${ETHGW:-172.16.1.1}" |
|||
TUNGW="${TUNGW:-240.0.0.1}" |
|||
PROXY="${PROXY:-172.16.1.2:1080}" |
|||
MONITOR="${MONITOR:-0.0.0.0:80}" |
|||
EXCLUDED="${EXCLUDED:-172.16.1.2/32}" |
|||
LOGLEVEL="${LOGLEVEL:-warning}" |
|||
BACKENDDNS="${BACKENDDNS:-8.8.8.8:53}" |
|||
HOSTS="${HOSTS:-localhost=127.0.0.1}" |
|||
|
|||
# enable ip_forward |
|||
sysctl -w net.ipv4.ip_forward=1 &> /dev/null |
|||
|
|||
# create tun device |
|||
ip tuntap add mode tun dev $TUN |
|||
ip addr add $TUNGW/24 dev $TUN |
|||
ip link set dev $TUN up |
|||
echo "tun device created: $TUN" |
|||
|
|||
# change default gateway |
|||
ip route del default &> /dev/null |
|||
ip route add default via $TUNGW dev $TUN |
|||
|
|||
# add to ip route |
|||
for ip in $(echo $EXCLUDED | tr ',' '\n') |
|||
do |
|||
ip route add $ip via $ETHGW |
|||
done |
|||
|
|||
# DNS settings |
|||
echo "nameserver $TUNGW" > /etc/resolv.conf |
|||
echo "DNS settings updated" |
|||
|
|||
tun2socks -loglevel $LOGLEVEL \ |
|||
-tunName $TUN -proxyServer $PROXY \ |
|||
-monitor -monitorAddr $MONITOR \ |
|||
-fakeDNS -hosts $HOSTS \ |
|||
-backendDNS $BACKENDDNS |
Loading…
Reference in new issue