[firefox] Switch firefox to use a different DNS than what is in the windows.host file

For example, I have a development site on a different server but I'm trying to copy content over from the live site so it'd be handy to have the live site in IE and the dev site in FF.

I tried FoxyProxy but I can't seem to get it to work.

This question is related to firefox dns

The answer is


Since http proxy protocol is similar to raw http protocol, you can redirect desired traffic to your development server by telling firefox it's a proxy server.

two limitations:

A. this won't let you use https connections.

B. some frameworks (e,g: wordpress) don't like this method and redirect the request the wrong way

just copy the following code into a .pac file (enter your site domain and IP address, of course), and switch development/production just by changing proxy configuration.

function FindProxyForURL(url, host) {
    var prox4site = {
        "mysite.com":"PROXY 10.0.1.100:80",
        "www.mysite.com":"PROXY 10.0.1.100:80"
    }

    return prox4site[host] || "DIRECT";
}

Go to options->Advanced->Network->Settings->Automatic proxy configuration url and enter 8.8.8.8 All you Mozilla traffic uses Google dns now.


I wonder if you could write a custom rule for Fiddler to do what you want? IE uses no proxy, Firefox points to Fiddler, Fiddler uses custom rule to direct requests to the dev server...

http://www.fiddlertool.com/fiddler/


What about having different names for your dev and prod servers? That should avoid any confusions and you'd not have to edit the hosts file every time.


It's now possible, with the DNS over HTTPS function:

Open Options, General, scroll to very bottom and open Network Settings,

On the very bottom, you can find DNS over HTTPS:

dnsOverHttps


You had to use about:config before to change this setting, here's for documentation:

Type about:config in firefox address bar.

search for: network.trr.uri

You can use one of the DNS servers below:

Cloudflare: https://cloudflare-dns.com/dns-query
Google: https://dns.google/dns-query
Secure DNS EU: https://doh.securedns.eu/dns-query
Quad 9: https://dns.quad9.net/dns-query

And set network.trr.mode to 1

Hijacked from here: https://www.ghacks.net/2018/04/02/configure-dns-over-https-in-firefox/


It appears from your question that you already have a second set of DNS servers available that reference the development site instead of the live site.

I would suggest that you simply run a standard SOCKS proxy either on that DNS server system or on a low-end spare system and have that system configured to use the development DNS server. You can then tell Firefox to use that proxy instead of downloading pages directly.

Doing it this way, the actual DNS lookups will be done on the proxy machine and not on the machine that's running the web browser.


DNS resolving is usually done at the system level and not at the application level, so you can't normally have one program use one dns and another program use a different dns. I'm not aware of any firefox extensions that allow you to use a different dns.


I wonder if you could write a custom rule for Fiddler to do what you want? IE uses no proxy, Firefox points to Fiddler, Fiddler uses custom rule to direct requests to the dev server...

http://www.fiddlertool.com/fiddler/


DNS resolving is usually done at the system level and not at the application level, so you can't normally have one program use one dns and another program use a different dns. I'm not aware of any firefox extensions that allow you to use a different dns.


I wonder if you could write a custom rule for Fiddler to do what you want? IE uses no proxy, Firefox points to Fiddler, Fiddler uses custom rule to direct requests to the dev server...

http://www.fiddlertool.com/fiddler/


Go to options->Advanced->Network->Settings->Automatic proxy configuration url and enter 8.8.8.8 All you Mozilla traffic uses Google dns now.


What about having different names for your dev and prod servers? That should avoid any confusions and you'd not have to edit the hosts file every time.


It appears from your question that you already have a second set of DNS servers available that reference the development site instead of the live site.

I would suggest that you simply run a standard SOCKS proxy either on that DNS server system or on a low-end spare system and have that system configured to use the development DNS server. You can then tell Firefox to use that proxy instead of downloading pages directly.

Doing it this way, the actual DNS lookups will be done on the proxy machine and not on the machine that's running the web browser.


DNS resolving is usually done at the system level and not at the application level, so you can't normally have one program use one dns and another program use a different dns. I'm not aware of any firefox extensions that allow you to use a different dns.


It's now possible, with the DNS over HTTPS function:

Open Options, General, scroll to very bottom and open Network Settings,

On the very bottom, you can find DNS over HTTPS:

dnsOverHttps


You had to use about:config before to change this setting, here's for documentation:

Type about:config in firefox address bar.

search for: network.trr.uri

You can use one of the DNS servers below:

Cloudflare: https://cloudflare-dns.com/dns-query
Google: https://dns.google/dns-query
Secure DNS EU: https://doh.securedns.eu/dns-query
Quad 9: https://dns.quad9.net/dns-query

And set network.trr.mode to 1

Hijacked from here: https://www.ghacks.net/2018/04/02/configure-dns-over-https-in-firefox/


Since http proxy protocol is similar to raw http protocol, you can redirect desired traffic to your development server by telling firefox it's a proxy server.

two limitations:

A. this won't let you use https connections.

B. some frameworks (e,g: wordpress) don't like this method and redirect the request the wrong way

just copy the following code into a .pac file (enter your site domain and IP address, of course), and switch development/production just by changing proxy configuration.

function FindProxyForURL(url, host) {
    var prox4site = {
        "mysite.com":"PROXY 10.0.1.100:80",
        "www.mysite.com":"PROXY 10.0.1.100:80"
    }

    return prox4site[host] || "DIRECT";
}

I use this to override system's DNS with localserver
in about:config
change this value:

  • network.dns.forceResolve
  • network.dns.ipv4OnlyDomains
  • network.dns.localDomains
  • with IP address of local DNS server (for exsample 192.168.1.88)
    Sorry for my english


    What about having different names for your dev and prod servers? That should avoid any confusions and you'd not have to edit the hosts file every time.


    I use this to override system's DNS with localserver
    in about:config
    change this value:

  • network.dns.forceResolve
  • network.dns.ipv4OnlyDomains
  • network.dns.localDomains
  • with IP address of local DNS server (for exsample 192.168.1.88)
    Sorry for my english


    DNS resolving is usually done at the system level and not at the application level, so you can't normally have one program use one dns and another program use a different dns. I'm not aware of any firefox extensions that allow you to use a different dns.


    What about having different names for your dev and prod servers? That should avoid any confusions and you'd not have to edit the hosts file every time.