I need to override the name resolution for a given domain name for testing purposes in my browser (Firefox) on Ubuntu, so that when I write "www.agivendomain.org", it will point to a given IP that I decide, instead of resolving via DNS.

I already tried editing the /etc/hosts file, but it doesn't work. It does work when I ping the domain from the terminal, but Firefox seems to ignore it. I also flushed and disabled Firefox's DNS cache with no luck. It seems Firefox simply does not look at /etc/hosts and always resolves the domain name by asking the DNS.

What am I missing?

I've found similar questions like "how do I override DNS in Firefox" to which the usual answer is "use /etc/hosts", then the poster usually replies "I don't want to use /etc/hosts for this or that reason" - well I would be perfectly fine with using /etc/hosts but what nobody says is it just doesn't work for Firefox...

Thanks m.

  • Can you provide a link to your hosts file with pastie? – evan.bovie Jun 1 '11 at 15:43
  • My problem seems to be related to some sort of DNS cache. After rebooting, the changes I had made to /etc/hosts finally took effect on Firefox and other browsers. – matteo Jun 1 '11 at 19:30
  • Now I've changed /etc/hosts again and the browsers still "uses" the previous version. Now even after rebooting I cannot get the browser to see the changes I've made to /etc/hosts. – matteo Jun 1 '11 at 19:30
  • Note that the issue affects all browsers, not only firefox, but not other programs: ping and wget always resolve names correctly according to /etc/hosts. – matteo Jun 1 '11 at 19:31
  • I have already tried /etc/init.d/dns-clean, I've already tried disabling dns cache in Firefox both with the DNS Cache addon and manually in about:config. No way. – matteo Jun 1 '11 at 19:31

There is a post at azcentral. It says you need to enter two keys in about:config, namely

  1. "network.dnsCacheExpiration"
  2. "network.dnsCacheEntries"

and set them to 0.

Give it a try. I have not, but your question seems still unanswered.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.