Skip to content

Latest commit

 

History

History
43 lines (25 loc) · 1022 Bytes

README.md

File metadata and controls

43 lines (25 loc) · 1022 Bytes

通过wintun学习UDP协议

实现了一个从3层的tun设备上接收ipv4包,然后解析ipv4包、UDP包,并响应发送过来的UDP包

平台

Windows10

构建

cargo build --release

tun网卡的设置(代码里面设置,不需要自己动手)

42是我这边初始化出来的id,不同的机器可能不一样

netsh interface ip set interface 42 metric=255
netsh interface ip set address 42 static 10.28.13.2/24 gateway=10.28.13.1
netsh interface ip add route 10.28.13.2/24 42 10.28.13.1

测试

通过nc命令(没有的自己写udp去连也行)

nc -u 10.28.13.100 4321

这里端口随意,进去后随便输点东西即可,然后tun这边就可以将ip/udp协议解析出来,并打印一些输出,然后响应发送端,像下面这样("Recv: Hello World !"此句为wintun发送回来的响应)

C:\Users\pysrc>nc -u 10.28.13.100 7866
Hello World !
Recv: Hello World !
dst ip 10.28.13.100 port: 4321 recv: Hello World !