Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.7: Adding entries to the Cisco AnyConnect hosts file System 10.7
I have been having problem adding entries into the OSX Lion's /etc/hosts file. I found that my entries into the /etc/hosts file only stuck around until I rebooted, then the /etc/hosts file would revert back to the default entries. My changes to the file were lost.

[crarko adds: This hint has been found to be specific to users of Cisco AnyConnect VPN client, and does not affect you otherwise. ]

In order to add your entries and make it stick in the /etc/hosts file, what you need to do is:
  • Launch Terminal.
  • Type sudo nano /etc/hosts.ac or sudo vi /etc/hosts.ac
  • Enter your admin password.
  • Add in your entries at the end of the file.
  • Save and exit.
If you make edits to the /etc/hosts file (like you do for Unix/Linux) your entries will not stick around after a reboot. You need to edit the /etc/hosts.ac file instead.

[crarko adds: I'm not sure about this one. I looked, and didn't see any /etc/hosts.ac file, and a search didn't reveal much of anything. Any of you folks out there who make modifications to hosts; when you've made changes under Lion do they stick or do you see the same kind of thing as this hint's author? And have any of you observed the hosts.ac file? I'd like to know where that comes from.]
    •    
  • Currently 2.00 / 5
  You rated: 1 / 5 (9 votes cast)
 
[12,650 views]  

10.7: Adding entries to the Cisco AnyConnect hosts file | 15 comments | Create New Account
Click here to return to the '10.7: Adding entries to the Cisco AnyConnect hosts file' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.7: Adding entries to the hosts file
Authored by: tofergregg on Oct 11, '11 07:37:47AM

I've made changes to the /etc/hosts file under Lion and it sticks after rebooting.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: rwaldin on Oct 11, '11 07:45:48AM

I'm pretty sure the hosts.ac file is put there by the Cisco AnyConnect VPN client as a clean copy of the hosts file before you connect to your VPN. This file is then used to restore your original hosts file after your VPN connection terminates, erasing any changes made by AnyConnect (or you) in the meantime.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: kerwinf on Oct 11, '11 07:54:37AM

I too have edited my hosts file and restart my Mac many times with no trouble. All entries stay just fine.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: wallybear on Oct 11, '11 07:56:05AM

The file hosts.ac is created and managed by Cisco Anyconnect VPN daemon, that rewrites the /etc/hosts file with the hosts.ac content at every reboot .
I thinks that's your case.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: dfbills on Oct 11, '11 08:06:38AM

Wow, that's a nasty one.

---
-d



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: wallybear on Oct 11, '11 02:59:02PM

Yes, creepy...



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: wOOge on Oct 11, '11 08:14:34AM

This tip is specific to the poster's software setup.
OP: I would change the title of the tip to include that info, otherwise it will lead people astray.

Changes to the stock Lion hosts file *are* respected/kept after a reboot by default.
I know this for a fact, I use this every day.

As a side note, someone should contact Cisco technical support and tell them not to mess with system files like that. Wow.

---
wOOge
http://www.axonz.com



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: leamanc on Oct 13, '11 06:44:40PM

It's quite common for VPN software to make edits to /etc/hosts and /etc/resolv.conf. Sometimes hosts have an internal (LAN) IP and a public facing one (a webmail server, for instance), and when you connect to the VPN, your IT admins may want to force you to go one or the other via hard-coding in hosts.

The real problem is that Apple has been threatening to phase out hosts and resolv.conf in OS X for years, and it's high time that developers start making use of Directory Services (via the dscl command) before it's too late and their VPN clients don't work anymore!



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: mr_kitty on Oct 11, '11 08:46:58AM

I just did a test to confirm edits to /etc/hosts remain after reboot in 10.7.1 -- which works as expected.

I would guess that the commenter's note about Cisco AnyConnect is the culprit in the submitter's case.... which is good to know for anyone that works with that Cisco software, but not a general OS hint, and likely not Lion specific.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: crarko on Oct 12, '11 06:22:24AM

The title has been corrected to reflect the new facts. Thanks, everyone.

Craig A.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: mufb74 on Oct 11, '11 04:28:25PM

Trying adding your custom entries to /private/etc/hosts. I have has the same trouble as everyone else with adding custom entries to the hosts file in /etc/, but the additions I have made in /private/etc/hosts have stuck since Lion was released.



[ Reply to This | # ]
10.7: Adding entries to the hosts file
Authored by: acobas on Oct 12, '11 12:37:23AM

Instead of modifying the hosts file, it's much more reliable to use the dscl command, which has been available since Leopard. Check out http://jonathan.tron.name/2008/01/05/hosts-aliases-in-leopard



[ Reply to This | # ]
10.7: Adding entries to the Cisco AnyConnect hosts file
Authored by: WilGeno on Oct 12, '11 07:20:37PM

I've had this happen to me. I simply deleted the hosts.ac file that AnyConnect created. When AnyConnect recreates the file it will use your new hosts file.



[ Reply to This | # ]
10.7: Adding entries to the Cisco AnyConnect hosts file
Authored by: dfbills on Nov 28, '12 11:36:04AM

I'm pleased to report that this file is no longer used in the 3.1.x software (necessary for Mountain Lion). The files are removed on install as well.

---
-d



[ Reply to This | # ]
10.7: Adding entries to the Cisco AnyConnect hosts file
Authored by: zais on Mar 07, '14 09:39:07AM

Really helpful for AnyConnect users (as it always overwrites hosts with default one :( )
Thanks a lot.



[ Reply to This | # ]