1

I'm one of the developers of the OpenConnect VPN client.

We're trying to modernize and improve our support for Windows. We use a user-customizable JScript called vpnc-script-win.js to configure IPv4/6 addresses, routing, and DNS based on the configuration sent by the VPN server.

One of the things this script needs to do is to set specific IP addresses for the VPN network interface. We use the command netsh interface ip set address to do this for IPv4, like so:

        run("netsh interface ip set address \"" + env("TUNIDX") + "\" static " +
            env("INTERNAL_IP4_ADDRESS") + " " + env("INTERNAL_IP4_NETMASK") + " store=active");

One of the limitations of the command is that it fails if the IP address in question is “in use” by another adapter (even if that adapter is not presently up-and-running):

screenshot

What I'd like to know is if there is any way to override this behavior, and force the setting of an IP address that conflicts with the address set on another adapter. I haven't been able to find anything in Microsoft documentation that explains a way to do this programmatically.

However, from configuring network interfaces on Windows using the Control Panel GUI, I know that it is in fact possible to configure conflicting IP addresses on Windows, after clicking through a brief warning.

So: is there a way to set an IP address for an adapter on Windows even if another adapter is (allegedly) using that address? Ideally, this will be done using command-line tools, since we prefer to keep all of the IP/routing/DNS configuration in this user-customizable script rather than in our binary code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.