Android版的tinc-vpn

作者网站 http://tinc_gui.poirsouille.org/
源代码 https://github.com/Vilbrekin/tinc_gui

配置文件最好存储在外置的SD卡上, 但是 SD卡一般以noexec属性挂载, 不能直接执行脚本
所以,在配置文件里加了一个 选项

ScriptsInterpreter = /system/bin/sh

配置
tinc.conf

Name = nubiaz9
AddressFamily = ipv4
Device = /dev/tun
#DeviceType = tun
#Mode = switch
Interface = tun0
ConnectTo = sfdo
PrivateKeyFile=/storage/sdcard1/tiny/rsa_key.priv
#KeyExpire = 3600
ScriptsInterpreter = /system/bin/sh

tinc-up

#!/system/bin/sh

ifconfig $INTERFACE 10.0.0.2 netmask 255.255.255.0
echo 1 > /proc/sys/net/ipv4/conf/$INTERFACE/rp_filter

tinc-down

#!/system/bin/sh

ifconfig $INTERFACE down

服务器配置
hosts/sfdo

Address = 5.6.7.8
Port = 4000
Subnet = 0.0.0.0/0

-----BEGIN RSA PUBLIC KEY-----
.....
-----END RSA PUBLIC KEY-----

host-up

#!/system/bin/sh

VPN_GATEWAY=10.0.0.1
ORIGINAL_GATEWAY=`ip route show | grep ^default | busybox cut -d ' ' -f 2-5`
echo $ORIGINAL_GATEWAY

ip route add $REMOTEADDRESS $ORIGINAL_GATEWAY
ip route add default via $VPN_GATEWAY dev $INTERFACE
#sleep 0.1
#ip route del default $ORIGINAL_GATEWAY

setprop net.dns1 8.8.4.4

host-down

#!/system/bin/sh

ip route del $REMOTEADDRESS

host-up


#!/system/bin/sh

VPN_GATEWAY=10.0.0.1
ORIGINAL_GATEWAY=`ip route show | grep ^default | busybox cut -d ' ' -f 2-5`
echo $ORIGINAL_GATEWAY

ip route add $REMOTEADDRESS $ORIGINAL_GATEWAY

#busybox route add default gw 10.0.0.1 
ip route add default via $VPN_GATEWAY

ip route del default $ORIGINAL_GATEWAY
ip route del default $ORIGINAL_GATEWAY

发表评论

电子邮件地址不会被公开。 必填项已用*标注