Why is Chromium bypassing /etc/hosts and dnsmasq?

170

Solution 1

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

Solution 2

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.

Solution 3

One other obscure possibility is that your system is setup to use an automatic proxy *.pac file. This would normally be the case if you were issued a computer in a corporate environment and the *.pac file is telling your browser to go through a proxy to resolve the URL. This takes priority over your /etc/hosts file and if the *.pac file has a rule in it to return PROXY if nothing matches then it will appear that Chrome is not honoring the /etc/hosts. This will normally be the case if your command line is working as expected, e.g. dig, ping etc.

If you tried the other solutions and they don't work then check to see you don't have an auto proxy setup that Chrome is using.

Share:
170
Klypto
Author by

Klypto

Updated on September 18, 2022

Comments

  • Klypto
    Klypto almost 2 years

    This is with CMake version 3.18.4

    I am trying to add deferred target source/reference files relative to the target's absolute path output directory which is being manipulated in a cross-platform way. It's likely that I have a larger X-Y issue involved but I would like to understand what the problem is here with the generator expressions. The expressions work for other commands, just not the target_sources command.

    Note: There is also a custom function 'strip_output_folders' that is doing some stuff with changing the values of LIBRARY_OUTPUT_DIRECTORY / RUNTIME_OUTPUT_DIRECTORY / RUNTIME_OUTPUT_DIRECTORY_${CONFIG} etc to ensure binaries of different targets and libraries artifacts when compiled are all placed in the same output folders similar to what a release would be structured. Normally Visual studio and others like to just build the output relative to it's project location which is less than ideal for my needs.

    set(TARGET_NAME "myApplication")
    
    add_executable(${TARGET_NAME}
       main.cpp
    )
    
    # force all output to go to the same bin/lib folders
    # !!! - ANYTHING THAT REFERENCEES THE EXE BINARY DIRECTORY / BIN OUTPUT MUST OCCUR AFTER THIS LINE - !!!
    strip_output_folders(${TARGET_NAME})
    # !!! ---------------------------------------------------------------- !!!
    
    set(${TARGET_NAME}_XML "")
    list(APPEND ${TARGET_NAME}_XML "$<TARGET_FILE_DIR:${TARGET_NAME}>/${TARGET_NAME}.xml")
    list(APPEND ${TARGET_NAME}_XML "$<TARGET_FILE_DIR:${TARGET_NAME}>/${TARGET_NAME}-d.xml")
    
    # appending the xml config bin files is deferred because the known destination changes only after strip output paths is run
    target_sources(${TARGET_NAME}
        PRIVATE
        ${${TARGET_NAME}_XML}
    )
    
    source_group(bin 
        FILES 
        ${${TARGET_NAME}_XML}
    )
    
    #debug version
    add_custom_command(TARGET ${TARGET_NAME} 
        COMMAND ${CMAKE_COMMAND} -E copy
        ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.xml
        $<TARGET_FILE_DIR:${TARGET_NAME}>/${TARGET_NAME}.xml
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.xml
        COMMENT "${TARGET_NAME}.xml configuration file was copied to destination at $<TARGET_FILE_DIR:${TARGET_NAME}>"
    )
    
    
    #debug version
    add_custom_command(TARGET ${TARGET_NAME} 
        COMMAND ${CMAKE_COMMAND} -E copy
        ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}-d.xml
        $<TARGET_FILE_DIR:${TARGET_NAME}>/${TARGET_NAME}-d.xml
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}-d.xml
        COMMENT "${TARGET_NAME}-d.xml configuration file was copied to destination at $<TARGET_FILE_DIR:${TARGET_NAME}>"
    )
    
    

    Running this gives me a message:

    Configuring done
    CMake Error at applications/myApplication/CMakeLists.txt:109 (target_sources):
      Error evaluating generator expression:
    
        $<TARGET_FILE_DIR:myApplication>
    
      Expressions which require the linker language may not be used while
      evaluating link libraries
    
    
    

    The error doesn't seem straightforward to me.

    Is this because processing of target_sources is a sub-processes to defining a target which occurs before the generator expression for TARGET_FILE_DIR of that target is available or is self-referencing? I don't actually know how CMake processing internally works.

    • Zoredache
      Zoredache over 10 years
      Are you using a proxy? When you use a proxy, the DNS requests are performed on the proxy.
    • thiagowfx
      thiagowfx over 10 years
      No, I'm not using any proxy, hostsblock doesn't require one.
    • Geremia
      Geremia almost 7 years
      I tried the methods of the answers below, but somehow Chromium is still obtaining the IP addresses… Are there some hardwired addresses in Chromium?
  • thiagowfx
    thiagowfx over 10 years
    What you said would only apply to old versions of Chromium / Google Chrome. Newer versions do not have this setting anymore (neither "Under the Hood"). Maybe the new setting is "Predict network actions to improve page load performance"? Sadly, this does not mention any DNS, so I'm not sure.
  • phoops
    phoops over 10 years
    I have updated an answer on how to clear Chromium's DNS cache. Please have a look, I hope it helps.
  • phoops
    phoops over 10 years
    Well if you just disable that without clearing cache - it will not work until cache expires. After cache is cleared, I do not think that Chromium should be able somehow to pre-fetch the real-IPs. Even if pre-fetch is on it will prefetch the blocked values. Anyway, at least it seems you have sorted it out.
  • MediumOne
    MediumOne almost 7 years
    This worked for me!
  • Maciej Krawczyk
    Maciej Krawczyk over 6 years
    This doesn't work by itself. You must also disable the prediction service, see answer above.
  • Totty.js
    Totty.js almost 6 years
    "chrome://net-internals/#dns" -> clear, is not working.
  • lmat - Reinstate Monica
    lmat - Reinstate Monica over 4 years
    chrome://dns doesn't exist anymore.
  • user1082
    user1082 almost 4 years
    with Chrome v85, goto chrome://settings/security and scroll-down to Advanced - Use Secure DNS, then choose 'with your current service provider'; or Custom, and type whatever DNS you want Chrome to use; or disable Use Secure DNS altogether.
  • user1082
    user1082 almost 4 years
    I use Little Snitch on my mac and discovered that Snitch rules for blocking facebook domains were no longer being respected by Chrome (v85). I eventually found the solution was to change Chrome's Secure DNS setting to my own ISP, instead of Google Public DNS. facebook domains are once again blocked in Chrome… phew!