2

I added some lines to my /etc/hosts file to resolve a private hostname, but every time after rebooting, the lines I added get lost. Should there be any setting options to make these changes take effect?

  • Do you edit it from root? – Daniil Ryzhkov Aug 31 '12 at 2:54
  • @Daniil yes, of course – qiuxiafei Aug 31 '12 at 6:51
  • Are you using some third-party VPN client. Some "disfunctional" clients modify the /etc/hosts files themselves. – Gerry Aug 31 '12 at 8:09
4

The Cisco AnyConnect VPN Client is known to show this behavior. It will reset your /etc/hosts file on reboot to the contents of /etc/hosts.ac.

If you use this VPN client, you should make your modifications to both files.

See this hint for more info.

http://hints.macworld.com/article.php?story=20111011050950471

  • god, i really use Cisco AnyConnect VPN... – qiuxiafei Sep 5 '12 at 1:49
2

Looks like some app deletes this lines from /etc/hosts on system startup. OS X itself doesn't delete any lines on startup nor reboot.

  • And my estimated guess would be a third party VPN client. – Gerry Aug 31 '12 at 8:04
1

After changing the hosts file, change the permissions on it to stop the file being modified. You may have to play a bit to see what works.

0

Try sudo nano /private/etc/hosts in Terminal.

0

If you are using pulse secure the file /private/etc/jnpr-pulse-hosts.bak gets copied to /private/etc/hosts every time you reconnect to the VPN (including each time your Mac wakes up from sleep mode).

So if you want some changes to survive a reconnection, edit the /private/etc/jnpr-pulse-hosts.bak file, use

sudo vi /private/etc/jnpr-pulse-hosts.bak

to add your changes there.

Then disconnect the network and reconnect (use the option disconnect in pulse secure or pull the network cable off and on or disable and re-enable the wifi) and once pulse secure reconnected to your VPN, check that your changes are now in /private/etc/hosts.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .