TUN是什么概念,大家或许都有所耳闻,绝对是一把利器。
今天就来说说如何将经常看到的SOCKS5转换成TUN
以ubuntu为例(linux基本上都适用)
1.下载二进制文件
感谢大佬 heiher 的开源项目 https://github.com/heiher/hev-socks5-tunnel
试了几家的socks5转tun工具,最后决定使用这个开源项目,相对于其他家来说这个占用资源少,速度相对可观。
wget https://github.com/heiher/hev-socks5-tunnel/releases/download/2.8.0/hev-socks5-tunnel-linux-x86_64 -O tun2socks
2.赋予可执行权限
chmod +x ./tun2socks
3.配置文件(tun2socks.yaml)
感谢 大佬 @foxmail 提供的socks5接口 https://clochat.com/t/topic/2017
这个接口挺有意思,能自动切换IP,赞!
tunnel:
name: tun1234
mtu: 8500
multi-queue: true
ipv4: 10.20.30.40
ipv6: '2001::10:20:30:40'
socks5:
port: 12118
address: 107.148.72.133
udp: 'tcp'
#username: 'username'
#password: 'password'
misc:
log-level: info
connect-timeout: 5000
read-write-timeout: 10000
4.运行tun2socks
./tun2socks tun2socks.yaml
5.判断是否配置成功
ip addr | grep -F “tun1234”
3: tun1234: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 8500 qdisc mq state UNKNOWN group default qlen 500
inet 10.20.30.40/32 scope global tun1234
或
ifconfig | grep -F “tun1234”
tun1234: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 8500
或
ping 10.20.30.40 -c 2
PING 10.20.30.40 (10.20.30.40) 56(84) bytes of data.
64 bytes from 10.20.30.40: icmp_seq=1 ttl=64 time=0.070 ms
64 bytes from 10.20.30.40: icmp_seq=2 ttl=64 time=0.050 ms
如果出现上述信息就是配置成功了。
这个TUN就相当于加了一块虚拟网卡,数据可以进行透明传输等等。
有了TUN怎么玩? 请各位大佬畅所欲言各述己见。