Mavericks and editing /etc/hosts file

ammonsc
Contributor II

It seems as though Mavericks is ignoring changes to the hosts file. I use:

sudo vi /etc/hosts

Make changes as necessary and then run

sudo killall -HUP mDNSResponder

and

sudo dscacheutil -flushcache (just in case)

But the changes to the hosts file are not taking. No matter what I do it does not seem to see the changes to the hosts file and still pings an incorrect address? Has anyone figured out a workaround?

4 REPLIES 4

rfadul
New Contributor II

ammonsc
Contributor II

It's not the browser I need to direct to this address. Mail is trying to hit a DMZ address and not an external address, due to internal DNS and some vpn tunneling I need them to use the external public IP and not the DMZ IP.

sean
Valued Contributor

Does a reboot work after editing the file? If not, then restarting services isn't going to help and the problem lies elsewhere.

chuck3000
Contributor

May want to consider a "Resolver" file instead.
Check this out:

https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/resolver.5.html
http://apple.stackexchange.com/questions/74639/do-etc-resolver-files-work-in-mountain-lion-for-dns-resolution

A bunch more stuff if you google search it.

Essentially, it's just a directory and a file at /etc/ called resolver/
In there you put a file (no . extension, just the file), called the domain you're trying to resolve to.

I gave the folder and file perms of 755 and owner 0:0.
This worked instantly once in place. No browser relaunch, no reboot necessary, no caches to clean. Tested on 10.6 - 10.9.2 w/out issue