Symlinked hosts file in OS X Lion doesn’t work for some domains

August 3rd, 2011 Comments Off

I have absolutely no idea how and why this works, or why it’s a problem in the first place. Just posting it here so it might help someone.

Prior to upgrading to Lion, my /etc/hosts file was a symlink to the actual file I put in my Dropbox sync folder (so I get a backup), and it was working perfectly. One of the entries I have in my hosts file is
127.0.0.1 dev.local.com
and Snow Leopard faithfully resolved that to 127.0.0.1.

After the upgrade to Lion, it appeared that OS X would now first query the DNS server before it consults the hosts file. See below -
/etc $ ping dev.local.com
PING dev.local.com (63.251.207.31): 56 data bytes
64 bytes from 63.251.207.31: icmp_seq=0 ttl=238 time=282.977 ms

What’s weird about it is, it works for some domains and doesn’t work for some. I’ve tried out suggestions to rearrange the position of the entry, or to change to only one entry per line, but none of them worked.

So guess what fixed that? I deleted the symlink and put the actual file in /etc. Ta-da, that fixed it!
/etc $ ping dev.local.com
PING dev.local.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.051 ms

Comments are closed.

What's this?

You are currently reading Symlinked hosts file in OS X Lion doesn’t work for some domains at hello@keewooi.

meta

  • @keewooi

    • Oops .. it looks like Twitter is down