Running when the brain hole open, think of yourself to write a simple VPN server, search, there are a lot of ready-made libraries or components, but curious if you want to use Python development, how can it be implemented?
Reply content:
If just implementing a simple VPN, personal use, is really very simple. The code amount is up to hundreds of lines.
Because the core of the operating system now has built-in TUN/TAP support, the application layer can easily establish the point-to-point tunnel and generate the virtual network card through the corresponding interface. After that, it is OK to set up the system data forwarding through the tools such as iptables. This is also true of the basic VPN now.
About Tun/tap:
https:// Zh.m.wikipedia.org/wiki /tun
A very simple implementation version of Linux C:
https:// Github.com/cloudwu/mptu N
Similar to Python implementations, the basic process is to open the/dev/net/tun operation Tun interface, such as TCP or UDP to set up a data forwarding channel to forward data.