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

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

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Beans
    13
    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
    Feb 2006
    Beans
    12

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

    Just another grateful user thanking you for posting this.

  9. #9
    Join Date
    Sep 2007
    Location
    Slovenia
    Beans
    2
    Distro
    Ubuntu 7.04 Feisty Fawn

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

    The problem seems to be resolved with the recent version of Cisco AnyConnect (3.1.01065). Can anyone confirm?

  10. #10
    Join Date
    Nov 2013
    Beans
    1

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

    The VPN client suddenly earned itself a nice
    Code:
    update-rc.d -f vpnagentd_init remove
    just as any other intrusive piece of software.

    Thanks

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
  •