/etc/hosts getting reset in Lion

I just discovered what is resetting my /etc/hosts file. It the Cisco AnyConnect VPN Client. Any time I would connect to my organization's VPN, it was resetting the hosts file to a default. I so rarely connect to the VPN, that it made the problem seem intermittent.

If you use Cisco's AnyConnect VPN Client, please be aware that it will reset your hosts file to the contents of the following: /etc/hosts.ac

To solve the problem, make your hosts changes in both the /etc/hosts and the /etc/hosts.ac file.

I got the hint from MacWorld.


Directory Services (NetInfo in Tiger and earlier) has its own static hosts map, which will be used by the address resolver before /etc/hosts. These can be manipulated through Directory Utility or dscl.

dscl localhost -create /Local/Default/Hosts/www.myhost1.com IPAddress 127.0.0.1
dscl localhost -create /Local/Default/Hosts/www.myhost2.com IPAddress 127.0.0.1
dscl localhost -create /Local/Default/Hosts/www.myhost3.com IPAddress 127.0.0.1
dscl localhost -create /Local/Default/Hosts/www.myhost4.com IPAddress 127.0.0.1