-
-
Save marklove5102/8697c5cbad901c11cec919e7ab594a06 to your computer and use it in GitHub Desktop.
InstallTun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# descr:TaterLi自创,用于配置自己的隧道的快捷工具,服务器部分,根据客户端参数来写. | |
# 使用方法 ./InstallTun.sh 0 1.1.1.1 | |
# 使用方法 ./InstallTun.sh [隧道ID] [IP地址] | |
cat >/etc/network/interfaces.d/tun$1 <<EOF | |
auto tun$1 | |
iface tun$1 inet6 v4tunnel | |
address 2a0e:aa07:e024:$(printf %x $((2*$1+1)))::2 | |
netmask 64 | |
endpoint $2 | |
local 209.141.40.15 | |
ttl 255 | |
mtu 1280 | |
post-up ip route add 2a0e:aa07:e024:$(printf %x $((2*$1+2)))::/64 dev tun$1 | |
pre-down ip route del 2a0e:aa07:e024:$(printf %x $((2*$1+2)))::/64 dev tun$1 | |
EOF | |
ifdown tun$1 | |
ifup tun$1 | |
cat >/tmp/tun0 <<EOF | |
auto tun0 | |
iface tun0 inet6 v4tunnel | |
address 2a0e:aa07:e024:$(printf %x $((2*$1+1)))::1 | |
netmask 64 | |
endpoint 209.141.40.15 | |
local $2 | |
ttl 255 | |
mtu 1280 | |
gateway 2a0e:aa07:e024:$(printf %x $((2*$1+1)))::2 | |
EOF | |
cat /tmp/tun0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment