Changes to /etc/hosts are Wiped out after Reboot

Asked by Neal Gamradt

I have a number of manual entries that I have always put directly into my /etc/hosts file. When I do this in 12.04 LTS, it works fine until I reboot, then all of my entries are deleted. There is obviously some other process nuking my entries but I don't cannot find anything about it.

Can someone please explain to me how I can cleanly add entries to the /etc/hosts file in Ubuntu 12.04? I just want to make simple entries such as:

127.0.1.1 dev.mysite.com

I am guessing this now has to be done through a tool or some sort? Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu network-manager Edit question
Assignee:
No assignee Edit question
Solved by:
Neal Gamradt
Solved:
Last query:
Last reply:
Revision history for this message
Chris (fabricator4) said :
#1

No, there's nothing that will change the hosts file, as far as I know. I can't replicate this problem. I've got a huge list of sites that I sometimes add to my hosts file so they redirect to the local machine 127.0.0.1. I've just done this and then rebooted; nothing changed it back; the file we as I saved it.

I suggest you save it again, then reboot, then check it again. Maybe look at the time stamp on the file and see exactly _when_ it was saved. Since the file is owned by root, there cant' be too many things messing with it.

Chris

Revision history for this message
Neal Gamradt (ngamradt-d) said :
#2

Hello Chris,

Thank you for the response. I am not in a position to test again (I will
try again tonight), but I made my changes twice yesterday and both times
after a reboot things were wiped out except for the orginal values in the
file. I will confirm the timestamp and all but I am fairly confident that
something wiped out the file.

I was reading that (as of 12.04), DNS is handled differently, but I haven't
seen much explaining what the differences are. This is a fresh install of
12.04 versus an upgrade, not sure if that makes a difference.

Neal
On Mar 19, 2012 5:10 AM, "Chris" <email address hidden>
wrote:

> Your question #191063 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/191063
>
> Status: Open => Answered
>
> Chris proposed the following answer:
> No, there's nothing that will change the hosts file, as far as I know.
> I can't replicate this problem. I've got a huge list of sites that I
> sometimes add to my hosts file so they redirect to the local machine
> 127.0.0.1. I've just done this and then rebooted; nothing changed it
> back; the file we as I saved it.
>
> I suggest you save it again, then reboot, then check it again. Maybe
> look at the time stamp on the file and see exactly _when_ it was saved.
> Since the file is owned by root, there cant' be too many things messing
> with it.
>
> Chris
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ubuntu/+question/191063/+confirm?answer_id=0
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ubuntu/+question/191063
>
> You received this question notification because you asked the question.
>

Revision history for this message
Daniel Letzeisen (dtl131) said :
#3
Revision history for this message
Neal Gamradt (ngamradt-d) said :
#4

Hello Dave,

Yes, I believe you are correct, this sounds a lot like my issue as the
entries I put in are mostly 127.*.*.* ...that being said, not all of my
entries that were removed are 127 entries. But it does sound like a similar
issue to what I am seeing.

Thank you for the reply. Hopefully there is a simple solution to this
problem. I won't be able to play with things until tonight.

Neal
On Mar 19, 2012 10:05 AM, "Dave Lentz" <email address hidden>
wrote:

> Your question #191063 on Ubuntu changed:
> https://answers.launchpad.net/ubuntu/+question/191063
>
> Dave Lentz posted a new comment:
> It could be a regression of this bug:
> https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/659872
>
> --
> You received this question notification because you asked the question.
>

Revision history for this message
Sam_ (and-sam) said :
#5
Revision history for this message
Neal Gamradt (ngamradt-d) said :
#6

Hello Sam,

Thank you for the links. It does appear that dnsnasq is probably what is causing my issue. However, is it fair to say there is currently no work-around to this issue? We just need to wait for the fix? Do I need to convert this to an official bug? I would assume this issue will affect a fairly large number of people if it goes out in the official release :-)

I am very happy with 12.04, this is one of the last issues I find to be a major one. Thanks again to everyone.

Revision history for this message
Sam_ (and-sam) said :
#7

In order to provide some more info to developers please run in a terminal:
ubuntu-bug network-manager

Revision history for this message
Neal Gamradt (ngamradt-d) said :
#8

After running over 130+ updates this morning, it appears someone already squished this bug. I am no longer seeing my /etc/hosts getting overwritten after a reboot. I will continue to monitor, but it appears someone fixed their bug. I thank everyone for the feedback.

Revision history for this message
Neal Gamradt (ngamradt-d) said :
#9

I have discovered that the cause of this is my companies Juniper Network Connect VPN software. Any changes you make to /etc/hosts or /ets/resolv.conf during the VPN session are wiped out when you disconnect from the VPN. I just wanted to add these details in case someone else had this same issue.

Revision history for this message
Torstein Knutsen (torstein-knutsen) said :
#10

Good thinking Neal !
You caught me with you last comment ! Thank you !

Revision history for this message
Brett Randall (javabrett) said :
#11

To continue the VPN agent theme - Cisco AnyConnect did the same thing for me with this version:

Cisco Systems VPN Agent (version 2.5.3055 )

It wipes out all static/maintained entries. I'm not aware of a workaround, but I wasn't using it anymore, so removed it. There are later versions available from Cisco, so these might be worth a try.