1

Is it somehow possible for me to modify the configuration of the windows (in my case windows 7), network adapter with python? Network Adapters in Control Panel I am subscribed to a VPN provider and just want to change the host name address ocasionally (for example if the current connection to their server starts lagging or died entirely), so I can hop around on their servers without having to use their GUI because it's too much hardware resource taking. Also I just recently found this: https://stackoverflow.com/a/7581831/15163882 ; it seems to actually modify network adapter settings, the issue is it is not modifying my IPVanish network adapter but the "Local Area Connection" network adapter > IPv4 configuration and all it did so far is bricking my network connection by overwriting it with invalid settings. Can anyone help me point it to the correct adapter, I am struggeling to find a documentation apart from the docs that microsoft provided https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-networkadapterconfiguration

Here are manual examples of the process I am trying to replicate in python: (On these examples, they're entirely setting up the network adapter from the start to end, like having to register it first and everything, while I am only trying to change the field called 'Server name or adress' on windows 10 and 'Host name or IP Address of destination' or 'Internet Address' on windows 7)

Windows 10: https://support.ipvanish.com/hc/en-us/articles/360001689994-IKEv2-Setup-on-Windows-10

Windows 7: https://support.ipvanish.com/hc/en-us/articles/360008240774-Windows-7-IKEv2-Setup

Additionally I did some research through githubs code search and after looking at multiple codes I'm not so sure anymore if it would even be possible to edit the host server address of a network adapter to that way cause a dynamic server switch. Here's my search term https://github.com/search?l=Python&p=1&q=Win32_NetworkAdapterConfiguration%28&type=Code I came to this conclusion, because none of them have included editing the host name at all. But it could also be, that I'm just missing the point entirely and you don't even have to in first place set the host name adress(also username, password) through code as you would need to, when connecting through the network adapter manually (initially)?

As a side note; I also noticed that it would be possible just using openvpn through their cmd interface / powershell, but I'm really trying to save hardware resources on the machine I am trying to configure the network adapter on as it's very resource limited, so I can't afford a 150-400 memory taking program running in the background.

Finally I also want to point out, that this method that I hoping to turn into reality, would be a huge innovative step in controlling VPN network access (to VPN providers that do not offer an API) with any programming language, since you would literally be able to replicate this procedure with all VPN providers that install their own virtual network adapter into windows, to be able to connect to their service - which is basically all of them.

Mika C.
  • 70
  • 1
  • 14
  • Maybe you don't need Python to change only one parameter at all. Take a look at the [Powershell solution](https://stackoverflow.com/questions/62376718/change-serveraddress-of-vpn-connection) ([Microsoft docs](https://learn.microsoft.com/en-us/powershell/module/vpnclient/set-vpnconnection?view=windowsserver2022-ps)) – viilpe Jun 25 '22 at 16:36
  • What's the VPN? Is it nord by any chance? – OneAndOnly Jun 27 '22 at 15:51
  • @OneAndOnly IPVanish @ https://www.ipvanish.com/ – Mika C. Jun 27 '22 at 16:32
  • Are you trying to make this change remotely or locally? If you're trying to do it locally, just use PowerShell. If you're remote, use `pywinrm` to run PowerShell. – Utkonos Jun 29 '22 at 05:47
  • I am trying to make this change locally and how do I ever use PowerShell to change the host address of the VPN adapter? – Mika C. Jun 29 '22 at 11:28

0 Answers0