proxy.pac files, Mozilla (Firefox & Thunderbird) and Vista or Windows 7

Published: | by Julian Knight Reading time ~2 min.
📖 Posts | 📎 Software | 🔖 configuration, vista, win7

I’ve found a problem with Mozilla based products and proxy settings. To automatically configure a proxy for use by Internet browsers, you can use a file called “proxy.pac“. This is a JavaScript function that is loaded into the browser when it starts and redirects requests via a proxy where required. All of the descriptions for this file you will find on the Internet will provide the following example of checking your current IP address. This is used for laptops where the IP address will change depending on where you are. You can check when the laptop is on the corporate network and redirect requests via the corporate proxy as needed:

if ( isInNet(myIpAddress(), “”, “”) ) {
  alert(“Corporate address & proxy”);
  return “PROXY”;
Well, this does not work for Mozilla based applications (for example Firefox and Thunderbird) if you are using Microsoft Vista or Windows 7. That is because, under those operating systems, the internal function myIpAddress() does not return an IPv4 address as expected (e.g. but an IPv6 address instead (e.g something longer with lots of “:”). In order to make your proxy.pac file work with both IE and Mozilla, use something like:
if (isInNet(myIpAddress(), “”, “”) ||
            shExpMatch(myIpAddress(), “fe80::b892:6a74:9635:*“) ) {
  alert(“Corporate address & proxy”);
  return “PROXY; DIRECT;“;
You can discover your IPv6 address in several ways but the trusty command line “ipconfig /all” shows you everything you need. See also this discussion on the Mozilla support forums: proxy.pac myIpAddress() returns incorrect format? : , , ,
Technorati : , , ,
Diigo Tag Search : , , ,

comments powered by Disqus