Jump to content
Read the Funtoo Newsletter: Summer 2023 ×
  • 0

/etc/hosts is overwritten


gnuisance

Question

I have been using /etc/hosts to map ip addresses to aliases for as long as I can remember; but lately I've noticed my file has been overwritten.  Also I noticed the following:

# Local Host Database
#
# This AUTOMATICALLY-GENERATED file describes a number of aliases-to-address
# mappings for the local hosts that share this file.
#
# In the presence of the domain name service or NIS, this file may not be
# consulted at all; see /etc/host.conf for the resolution order.
#
# DO NOT EDIT THIS FILE BY HAND; YOUR CHANGES WILL BE OVERWRITTEN
#
# Define alias-to-address mappings in /etc/conf.d/hostname

I've relied on  my hosts file heavy, is there a preferred way to to match ip addresses with names similar to using the hosts file? 

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

Well that seems to be the magic.  Just cleaned out my hosts file, commented out all those aliases in /etc/conf.d/hostname, reboot, and perfect.  Indeed those warnings in the host were leftover from before, not there on this write.

Hopefully we'll get a new bug feature to keep us entertained soon.

Once again you've helped me so I didn't have to use my brain.  Thank you.

Link to comment
Share on other sites

  • 0

It's pretty annoying, isn't it?  Especially since without warning it nukes your /etc/hosts file with no backup.

Fear not though, still the same, the aliases just get copied over automatically from your /etc/conf.d/hostname file each startup.  Check that file out, it tells you how to do it.

cat /etc/conf.d/hostname
# Set to the hostname of this machine
hostname="thishearmachine"
#aliases=""
aliases="192.168.1.100       thishearrouter
192.168.1.102                someothermachine"

etc.

And then it was released in stages.  My arm machines a couple of months ago, amd64 a week ago, x86 a couple of days later.  Never a dull moment.

BUT

Once I got used to it on the arms, it works fine.  Today though I noticed that it was repeatedly pasting the aliases in the /etc/hosts file over and over again on my amd64, apparently not rewriting new each time as the arms do, and as is implied.  I don't know what that's about yet, gotta check it out.

Link to comment
Share on other sites

  • 0

i wonder how this is going to clash with dnsmasq....  dnsmasq can serve aliases though i have not gone through the program enough to know exactly how to do that.  i haven't had the opportunity to work with a network large enough to warrant learning these things.  i just use it for localhost cache only dns server end point for dnscrypt. my encrypted dns is much slower than 8.8.8.8 && 8.8.4.4.  i wonder what's automatically generating that file?  i kind of like the idea of the aliases in conf.d hostname though....

 

"aliases" floods my hosts files with duplicate entries if i restart /etc/init.d/hostname  its also inserting the 127.0.0.1 alias wonky stacked on top of the hostname line, its appending the first alias to the loopback hostname statement possibly a blank line then aliases would work

Link to comment
Share on other sites

  • 0

I thought maybe that was it, having restarted hostname a few times, but no, this morning on start I've got duped entries, cleaned it last night.

Snooped around a little last night, didn't see anything that jumps out & grabs me.  Also noticed the arms are doing it too, watched it closely a couple of months ago after the change, was working right then.  So maybe a funky version?  Hope they fix it.  Maybe a little creativity with the /etc/init.d/hostname file...

Link to comment
Share on other sites

  • 0

The plot thickens.

+# Add aliases for other hosts to /etc/hosts directly. The networking scripts
+# automatically generate the localhost lines only.

While updating my config files after an update I came across this addition to the /etc/conf.d/hostname file.  It looks like I'm supposed to put aliases for other hosts in /etc/hosts directly.  I look forward to the day my hosts don't have to live in fear of being overwritten.

Link to comment
Share on other sites

  • 0

That is interesting gnuisance.  Sounds like we go back to the old methods?  Perhaps I missed that last time I did dispatch-conf.

It's still duping like crazy here, so I'm gonna try that.

And yet it still says this in /etc/hosts:

#
# DO NOT EDIT THIS FILE BY HAND; YOUR CHANGES WILL BE OVERWRITTEN
#
# Define alias-to-address mappings in /etc/conf.d/hostname
 
Maybe left over from before
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...