Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: hosts file keeps getting reset/rewritten, hosts.ac the culprit

  1. #1
    Join Date
    Jun 2011
    Beans
    10
    Distro
    Ubuntu 14.04 Trusty Tahr

    hosts file keeps getting reset/rewritten, hosts.ac the culprit

    This post is to help others who've encountered the same problem. I've been looking (Google'ing) around for quite some time and have just now come up with the solution. Tried to make the title Google-friendly

    Ever since a week ago, I haven't been able to change anything in the file. Whenever I reboot my system, the file gets overwritten.
    Just to be clear - the file is not wiped and restored to an original (clean) state, it's instead reverted to a previous state. Older hosts I've added to the file are still there, but I just can't add any new hosts to the file.
    Also, if I "sudo gedit /etc/hosts", the changes are saved for that session. But once I reboot, they're gone.

    Looking into the /etc folder, I've found a file called hosts.ac, which seemed like a copy of my hosts file. When I tried changing it - Presto! The /etc/hosts file was changed to reflect the content of this file.

    After some investigation, seems this file was added after installing Cisco AnyConnect (hence the ".ac"), and on every reboot, it copies this file over /etc/hosts.

    So if you have AnyConnect - in order to make changes to hosts, you need to edit /etc/hosts.ac, not the original /etc/hosts file!

    Hope this helps someone - was a big mystery for me...

  2. #2
    Join Date
    Dec 2011
    Beans
    8

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    That problem has plagued me for far too long. I eventually took the time to do some investigating and found the hosts.ac file, which looked just like the version of the hosts file that I kept reverting back to, either on reboot or after connecting/disconnecting with Any Connect. I searched for hosts.ac on these forums and came across this post, which is the only mention of the problem I have seen anywhere. Thanks for sharing. Hopefully this will help others with the same problem.

  3. #3
    Join Date
    Feb 2007
    Beans
    5

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    Quote Originally Posted by PhartSmellah View Post
    This post is to help others who've encountered the same problem. I've been looking (Google'ing) around for quite some time and have just now come up with the solution. Tried to make the title Google-friendly

    Ever since a week ago, I haven't been able to change anything in the file. Whenever I reboot my system, the file gets overwritten.
    Just to be clear - the file is not wiped and restored to an original (clean) state, it's instead reverted to a previous state. Older hosts I've added to the file are still there, but I just can't add any new hosts to the file.
    Also, if I "sudo gedit /etc/hosts", the changes are saved for that session. But once I reboot, they're gone.

    Looking into the /etc folder, I've found a file called hosts.ac, which seemed like a copy of my hosts file. When I tried changing it - Presto! The /etc/hosts file was changed to reflect the content of this file.

    After some investigation, seems this file was added after installing Cisco AnyConnect (hence the ".ac"), and on every reboot, it copies this file over /etc/hosts.

    So if you have AnyConnect - in order to make changes to hosts, you need to edit /etc/hosts.ac, not the original /etc/hosts file!

    Hope this helps someone - was a big mystery for me...
    Absolutely brilliant. You, sir, win the internet for the day. This same problem was bugging me to no end.

  4. #4
    Join Date
    Dec 2011
    Beans
    1

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    I've been an Ubuntu forums lurker for a while now.

    I went through the effort to register so I could give major kudos to the OP. I had the exact same problem, and this fixed it!

    I would add that /etc/hosts gets reset *every* time you connect with AnyConnect, as I observed it reverting even when I wasn't rebooting the machine. Why AC generates another hosts file is either beyond my comprehension or really stupid.

  5. #5
    Join Date
    Mar 2009
    Beans
    8

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    Thank you! That was driving me crazy!

    I wrote a little script called "vihosts" (to be consistent with "vipw" and "vigr") -- now I just have to remember to type "vihosts" instead of "sudo vi /etc/hosts" and everything should be fine.

    Code:
    #!/usr/bin/env bash
    FILE=`mktemp`
    cp /etc/hosts $FILE && vi $FILE && sudo cp $FILE /etc/hosts && sudo cp $FILE /etc/hosts.ac && rm $FILE

  6. #6
    Join Date
    May 2007
    Beans
    17

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    This has been driving me crazy, too. Thanks so much for posting.

  7. #7
    Join Date
    Jan 2007
    Location
    Location: Location:
    Beans
    1,246
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    clear && echo paste url and press enter; read paste; (youtube-dl $paste) | zenity --progress --title="" --text "Downloading, please wait" --auto-close --pulsate && ans=$(zenity --file-selection); gnome-terminal -x mplayer "$ans"

  8. #8
    Join Date
    Jul 2012
    Beans
    1

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    Had the exact same problem on Mac OSX with Cisco AnyConnect, and was driving me insane. Thanks for posting!

  9. #9
    Join Date
    Nov 2006
    Location
    Portugal
    Beans
    16
    Distro
    Kubuntu 6.10 Edgy

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    Thanks for posting this!! I was about to throw my laptop out the window...

  10. #10
    Join Date
    Aug 2012
    Beans
    1

    Re: hosts file keeps getting reset/rewritten, hosts.ac the culprit

    yes,we can also make a soft link from hosts to hosts.ac
    like this
    Code:
    删除原来hosts.ac
    	sudo rm /etc/hosts.ac
    	建立软链
    	sudo ln -s /etc/hosts.ac /etc/hosts
    visit http://llohellohe.github.com/mac/mac...rewritten.html for more details

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •