On my Mac (running OS 10.6.8), I can edit my hosts file with sudo vi /etc/hosts, but changes I make don't seem to persist through restarts or possibly awaking from sleep mode.

Is there a way to make these changes persist?

Here's a sample change adding an override for www.example.com:

$ cat /etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost

1.2.3.4 www.example.com

Update: I am also using Cisco AnyConnect VPN software, and that turned out to be the clue. See Daniel's answer below.

link|improve this question
1  
possible duplicate of /etc/hosts getting reset in Lion – Daniel Beck Jan 26 at 18:18
@user606723 /etc is a symbolic link to /private/etc. – Daniel Beck Jan 26 at 18:18
Brian, are you using Cisco VPN software? Do you have the file /etc/hosts.ac? – Daniel Beck Jan 26 at 19:42
Bingo! I am in face using Cisco AnyConnect VPN. I updated /etc/hosts.ac file and it now persists the changes. Please put this as an answer and I'll accept it. – BrianC Jan 26 at 19:54
feedback

1 Answer

up vote 3 down vote accepted

You are using Cisco AnyConnect software, which will overwrite /private/etc/hosts with /private/etc/hosts.ac. Just edit that file instead.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.