This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

ఇంకా తెలుసుకోండి

myIpAddress() Returns IPv6 Address in Firefox 4 proxy.pac file

  • 7 ప్రత్యుత్తరాలు
  • 68 ఈ సమస్యలు కలిగి ఉన్నాయి
  • 1 వీక్షణ
  • చివరి సమాధానమిచ్చినది Apokalipse

more options

I have a proxy.pac file that works fine with IE9 and Chrome under Windows 7 that selects a proxy based on myIpAddress(). It wasn't working in Firefox 4 and it turns out myIpAddress() was returning the IPv6 address of the PC, instead of the IPv4 address. Is there some other function that is guaranteed to return the IPv4 address, or some other setting that would guarantee myIpAddress() returns the IPv4 address? I would rather not remove the IPv6 protocol from the client PC.

I have a proxy.pac file that works fine with IE9 and Chrome under Windows 7 that selects a proxy based on myIpAddress(). It wasn't working in Firefox 4 and it turns out myIpAddress() was returning the IPv6 address of the PC, instead of the IPv4 address. Is there some other function that is guaranteed to return the IPv4 address, or some other setting that would guarantee myIpAddress() returns the IPv4 address? I would rather not remove the IPv6 protocol from the client PC.

ఎంపిక చేసిన పరిష్కారం

We used the isinnet(myipaddress()) function to determine if a laptop was in the Company network or not, in this way we could tell the browser to use the proxy or not. As an alternative we switched to check if an internal DNS address could be resolved or not.

function FindProxyForURL(url, host)

{

       // proxy only needed if in 10.10/16
       //if(!isInNet(myIpAddress(), "10.10.0.0", "255.255.0.0")) 
       //        return "DIRECT"; 
      // This is now used as the above has issues with ipv6
          if(!dnsResolve("name.internal.domain"))
                   return "DIRECT";
       // if resolvable use the proxy 
                return "PROXY proxy.internal.domain:8080"; 

}

Hope this is helpful, as it took a little time to think of this. (with a little help from a colleague)

ఈ సందర్భంలో ఈ సమాధానం చదవండి 👍 3

ప్రత్యుత్తరాలన్నీ (7)

more options

Never mind, I found a solution. I went into about:config, then set network.dns.disableIPv6 to true. After re-starting Firefox 4, myIpAddress() returns the IPv4 address.

more options

I had a similar problem. After analyzing the issue, I found out, that the myIpAddress() returns the IP address of the first network adapter it will find. The hint to enable network.dns.disableIPv6 does not solve the issue that the "wrong" adapter might be taken. This is especially true when you use dial-up or virtual adapters the connect remotely and need to determine your assigned remote IP. The only way this could be solved is to have myIpAddressEx() implemented. This will return all IP addresses of all adapters. Well you have to write a JavaScript to strip off the "not useful" IPs, but at least you have to chance to find out the local IP (either IPv4 or IPv6).

)

న martin_md చే మార్చబడినది

more options

ఎంపిక చేసిన పరిష్కారం

We used the isinnet(myipaddress()) function to determine if a laptop was in the Company network or not, in this way we could tell the browser to use the proxy or not. As an alternative we switched to check if an internal DNS address could be resolved or not.

function FindProxyForURL(url, host)

{

       // proxy only needed if in 10.10/16
       //if(!isInNet(myIpAddress(), "10.10.0.0", "255.255.0.0")) 
       //        return "DIRECT"; 
      // This is now used as the above has issues with ipv6
          if(!dnsResolve("name.internal.domain"))
                   return "DIRECT";
       // if resolvable use the proxy 
                return "PROXY proxy.internal.domain:8080"; 

}

Hope this is helpful, as it took a little time to think of this. (with a little help from a colleague)

more options

Thanks! I wasn't even thinking of a solution without using myIpAddress(). This is very clever and eliminates the need for disabling IPv6 in Firefox. I'm wondering if Windows 7 does "negative" DNS caching. Although not a good thing in itself, it would improve the performance of the script when operating outside the internal domain.

more options

As you mention there could be a slow dns response when outside the internal network due to the necessary query. Maybe there is yet another alternative for determining if the browser is in our out of a particular network. In the mean time this seems to be quite browser resillient in that it also works with other browsers. I might revert to the IPv6 address schema in the script as per the other comment once I get my head around IPv6 a bit more as it must be faster.

more options

There are a few known bug reports in bugzilla.mozilla.org about issues with myIpAddress() it can return - 127.0.0.1 - ::1 - IPv6 - ipv4 - the IPv6 local link IP instead of the global one

The function is unsealable und unusable in many cases :-(

more options

@martin_md

You can change your adapter priority so that myIpAddress() returns the IP of the adapter you want

(Win7) go to network and sharing center -> change adapter settings

Press alt, go to advanced -> advanced settings

then change the order of the network adapters in the top field (top adapter has highest priority)

But it would be more helpful if Firefox supported the MyIpAddressEx() function (listing all IP addresses), and made myIpAddress() return an IPv4 address only for compatibility with standard pac/wpad files.

న Apokalipse చే మార్చబడినది