Why is Chromium bypassing /etc/hosts and dnsmasq?

I'm using hostsblock together with dnsmasq on Arch Linux to block some websites, one of them is facebook.com and www.facebook.com.

I know everything is working properly because a simple ping to facebook.com (or www.facebook.com) returns 127.0.0.1. Also, if I access these websites from Midori, a blank page is returned (this is an expected behavior, since I'm algo using the kwakd daemon to return blank pages on localhost).

Only Chromium seems to bypass my blocklist. Accessing facebook.com from it makes me go straightly to the facebook homepage.

After cleaning up everything (Ctrl+Shift+Delete) since the beginning of time and restarting Chromium, I get the desired behavior (= cannot access Facebook).

Although, after a while (I'm not exactly sure what causes this), Chromium ignores again my local dnsmasq DNS and successfully access the facebook Homepage.

I read something about the caching and pre-fetching of DNS queries of Chromium, but I'm not sure how to disable it.

Question is: why is Chromium bypassing my local DNS, and what can I do to stop it?


The majority of references about this subject are old. If you have an old version of Chromium, follow edvinas.me answer.

For current versions of Chromium (at the time this post was written: 33rd), here is what you should do:

  1. Go to chrome://settings
  2. Click on "Show advanced settings..."
  3. Unmark the Predict network actions to improve page load performance box.
  4. Check if the DNS prefetching is really disabled by going to chrome://dns. You should see there something like DNS pre-resolution and TCP pre-connection is disabled. If the prefetching is not disabled, you'll see some tables there.

Update

For newer versions of Chrome (at the time of this update: 55th), the third item is worded as: Use a prediction service to load pages more quickly.

Reference

  • http://www.chromium.org/developers/design-documents/dns-prefetching

Updated Answer

Make sure you clean Chrome's cache. Type this in address bar:

chrome://net-internals/#dns

Then click Clear host cache button.

Old Answer

Chromium is using Google's internal DNS by default (8.8.8.8 and 8.8.4.4)

To disable it:

  1. Click on Tools menu (a little wrench icon), then go to Options.

  2. ‬Click on the Under the Hood tab.

    ‪3. ‬Under “Privacy” section, untick the check box for Use DNS pre-fetching to improve page load performance.

    ‪4. ‬Click on the Close button.

    ‪5. ‬Refresh to reload the web page.