# Routing decided by myIpAddress()

Source: https://findproxyforurl.net/rules/myipaddress-usage/ · last updated 2026-10-14

Rule PAC-K013 (`myipaddress-usage`), severity medium, category: Compatibility across engines, top 20 #19.

Each engine picks "the client's IP" by its own rule (browsers the route to the internet, Windows the adapter order, pactester the computer's name), so with several adapters or a VPN the answer differs and can change. Location-based routing keyed on it is unreliable.

## Why it matters

`myIpAddress()` returns one address of a computer that usually has several, and nothing
guarantees that it is the one the PAC logic expects. Chromium (since M72) asks the system which
local address it would use to reach a public address (8.8.8.8, 2001:4860:4860::8888); only
without such a route does it look up the computer's own name and then routes into the private
ranges, and it returns `127.0.0.1` when all of that fails. Before M72 it simply resolved the
host name. Firefox also uses the route towards 8.8.8.8, but for a URL whose host is an IP address
it uses the route towards that address. In a lab test on Windows 11 (2026-10-14), Edge and Firefox
followed whichever adapter held the route to the internet. Windows' own engine (WinHTTP and
WinINet) did not follow the route at all: it returned the address of the first adapter in
Windows' order, which is set by the interface metric, even when that adapter had no route to
the internet. Changing the interface metric therefore changed the Windows answer but not the
browsers' answer. With Windows' built-in VPN client, a full tunnel gave the VPN address in every
engine (Windows raised the other adapters' metric while the tunnel was up), while split tunnelling
gave the browsers the adapter with the route to the internet and Windows the first adapter in its
order, which were not always the same. pactester (pacparser) resolves the computer's own name, so in tests the answer
comes from the test machine unless it is set with `pactester -c`. The answer can change without
a new PAC download: when a VPN connects, when a second network appears, or when Windows stops
using a gateway that does not answer (in the test, within seconds). A PAC that compares
`myIpAddress()` against site ranges also has to handle the `127.0.0.1` failure value.
Branch-office routing should use separate PAC URLs per site or the proxy's own client-IP policy
instead.


## How to fix

Do not gate routing on myIpAddress(); distribute per-site PAC URLs or decide on the proxy by source address.

## Bad

```js
function FindProxyForURL(url, host) {
  if (isInNet(myIpAddress(), "192.168.0.0", "255.255.0.0")) {
    return "PROXY branch-proxy.corp.example:3128";
  }
  return "PROXY hq-proxy.corp.example:3128";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  return "PROXY proxy.corp.example:3128; PROXY backup.corp.example:3128";
}
```

## Engine behaviour

- chromium >=72: Ordered heuristic: (1) source address of a route to 8.8.8.8 / 2001:4860:4860::8888, (2) first address from resolving the machine's hostname (IPv4 preferred), (3) route to 10.0.0.0 / 172.16.0.0 / 192.168.0.0 / fc00::; link-local and loopback only as last resort; returns 127.0.0.1 on failure. Before M72 it was just getaddrinfo(gethostname). (source: doc, verified 2026-10-04)
- firefox: Local address of the route towards 8.8.8.8; for a URL whose host is an IP address, the route towards that address (with pacUseMultihomedDNS = true, towards the resolved host). Does not look at the adapter type or order. (source: lab, verified 2026-10-14)
- pacparser: Resolves the local host name via getaddrinfo (hosts file, DNS) and falls back to 127.0.0.1; a fixed value can be set with pactester -c or setmyip(). (source: lab, verified 2026-10-11)
- winhttp: Does not follow the route. With several adapters it returned the address of the first adapter in Windows' order (lowest interface metric), also when that adapter had no route to the internet; never a 169.254.x.x address while another address existed. With a full-tunnel VPN (Windows' built-in client) the VPN address, with split tunnelling the first physical adapter. myIpAddressEx lists all addresses, including link-local and 169.254.x.x ones. (source: lab, verified 2026-10-14)
- wininet: The same answers as WinHTTP in every setup measured (first adapter in Windows' order, by interface metric). (source: lab, verified 2026-10-14)
