/ etc / hosts are ignored in mac El Capitan (10.11.5)

I am trying to redirect an existing web address to a remote machine on my subnet. To do this, I put the following in / etc / hosts

192.168.1.249 holub.com

and clear the DNS cache with

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

However, when I ping holub.com (the most reliable way I know to see how the address is actually resolved), I see the real web address (204.13.10.74), and not the one listed in / etc / hosts ( 192.168.1.249). Interestingly, the mysqladmin utility does not resolve the address correctly, but the Chrome browser resolves the address correctly. I assume that Chrome has a peculiar internal solution.

In general, it seems that / etc / hosts are used after the actual DNS lookup, and not earlier, as it should be, so the external address is not redefined.

I tried using different IPv6 equivalents for my local address (0: 0: 0: 0: 0: ffff: c0a8: 01f9 :: ffff: 192.168.1.249 :: 192.168.1.249), but that doesnโ€™t help. Rebooting (rather than clearing the cache) does not help either.

I found one unsatisfactory workaround. If I turn off DNS Review with

sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

then / etc / hosts is used, but then I canโ€™t access the Internet.

If anyone has encountered this problem, I would like to know if there is a workaround.

+5
source share
1 answer

I came across this, looking for an answer to a similar problem and wanted to publish my results for someone else in the same position.

As a three-person team, we found that editing the / etc / hosts file seemed to work, while editing the other two host files did not seem to be there. After further digging, we realized that I was on OS X 10.10, while they were on newer versions.

We found that after you tried about a million things, this is an addition to the hosts file in 10.11 and, apparently, cannot have more than one place between the IP and the domain, for example:

DOES NOT WORK:

1.2.3.4 some.site.com 

DID WORK:

 1.2.3.4 some.site.com 

After making this change, we immediately began to see the expected results without flushing, rebooting, or another cache.

I know that in your example you show only one space, but, in any case, now, as it appeared in your actual file, I wanted to share it anyway.

+6
source

All Articles