I can see that lot's of programs like openvpn and Teamviewer for their VPN Connection creat a virtual network connection on windows. I want to create one for myself for testing purposes.
Is it possible to create one programmatically or so?
I can see that lot's of programs like openvpn and Teamviewer for their VPN Connection creat a virtual network connection on windows. I want to create one for myself for testing purposes.
Is it possible to create one programmatically or so?
This might be a step in the right direction?
From the page:
The Remote Access Service (RAS) supports Virtual Private Network (VPN) connections in addition to conventional remote access connections that use Point-to-Point Protocol (PPP). In a VPN connection, the VPN packets are encapsulated in IP packets and sent across an IP network such as the Internet. Therefore, access to an IP network is a requirement in order to establish a VPN connection. If the client computer has an always-on connection to an IP network, for example a connection to an IP LAN, the client can establish the VPN connection using a single call to the RasDial function.
It sounds like you're looking for the Tap-Win32 driver. It's the driver OpenVPN on Windows uses to create the virtual interface you are seeing, and in fact part of the OpenVPN package. This subsystem is also available on many *nixes.
The interface to this TAP driver is roughly the same on all OSes. You open a special file, and write raw Ethernet frames to this file. The driver then inserts these frames into the virtual interface. Conversely, any packets that are transmitted on the virtual interface, can be read from the special file as raw Ethernet frames.
Most implementations also have a TUN mode, which operates at layer 3 instead of layer 2. So you will be reading raw IP, IPv6, etc. packets instead of Ethernet frames.
I have no experience with this on Windows, so I'm going by quick skimming of source code here. OpenVPN goes through most of these steps in tun.c function open_tun. You'll find multiple definitions of this function, but they're #ifdef'd for different OSes (so search for CreateFile). The basic way this seems to operate on Windows is:
So while the API is really just a special file and thus fairly simple, there's a lot to actually managing the interface. But if you're just in it for testing, this may well be enough. You can then manually configure your test interface in Windows.