Proxy Script – Fix Issues with Dual Network Cards

javascriptPROXYscriptingwpad.dat

I have deployed a wpad.dat. Works like a charm except for some users that are connected to two networks at the same time (ethernet and another networkadapter that emulates an analog modem for fax). I also tested this with my notebook. When I connect to the LAN through cable and at the same time to another network through WiFi, I do not get a connection to the internet. When I provide the proxy address directly, it works.

How do I have to change my script, in order to solve my problem?

function FindProxyForURL(url, host) {
    if (isInNet(host, "127.0.0.1", "255.255.255.255"))
        return "DIRECT";
    if (shExpMatch(url, "*.intranet.*/*"))
        return "DIRECT";
    if (isInNet(myIpAddress(), "172.0.0.0", "255.255.0.0"))
        return "PROXY 10.1.1.254:8080";
    return "DIRECT";
}

Best Answer

@Palmin I had the same problem, and thankfully stumbled upon a solution in this social.technet thread! The priority of adapter IPs that Windows returns to a browser's myIpAddress() implementation can be modified by changing the IP metrics.

I manually set the metrics for my physical adapters to 1, 2, etc, and put the VirtualBox Host-Only Network at the end. It works like a charm now.

My specific configuration/journey for others struggling with the same issue:

  • Windows 7 Enterprise
  • VirtualBox 4.1.20 r80170

Accessing web pages on the Internet when on wireless always failed. When on a wired connection they worked just fine, and intranet pages were always accessible. Disabling the VirtualBox Host-Only Network adapter resolved the issue. Manually configuring my browser to always use a proxy (versus auto-detect) also resolved the issue.

To confirm the nature of the PAC problem, I used the pactester utility to test the behavior of wpad.dat with my physical addresses versus the VirtualBox one. As expected, the proxy script returns direct connections for private IPv4 addresses. The default VirtualBox Host-Only IPv4 address is in the 192.168.x.x range.

Modifying the adapter priority did not resolve the issue for me. It was not fully (and cleanly) resolved until I modified the metrics for each adapter.