Jump to content
funtoo forums
mauricev

repeating entries in /etc/hosts

Recommended Posts

What is causing /etc/hosts to be filled with a ton of repeating entries?

192.168.1.50 zfs2
192.168.1.90 zfs3
192.168.1.50 zfs2
192.168.1.90 zfs3
192.168.1.50 zfs2
192.168.1.90 zfs3
192.168.1.50 zfs2
192.168.1.90 zfs3
192.168.1.50 zfs2
192.168.1.90 zfs3
192.168.1.50 zfs2
192.168.1.90 zfs3
192.168.1.50 zfs2
192.168.1.90 zfs3
127.0.0.1	base localhost localhost.localdomain 192.168.1.70 base
192.168.1.50 zfs2
192.168.1.90 zfs3
::1		base localhost localhost.localdomain 192.168.1.70 base
192.168.1.50 zfs2
192.168.1.90 zfs3

The /etc/conf.d/hostname looks like this

hostname=base
aliases="192.168.1.70 base
192.168.1.50 zfs2
192.168.1.90 zfs3"

 

Share this post


Link to post
Share on other sites

Had been reported some years ago but could not be reproduced:

https://bugs.funtoo.org/browse/FL-2316?page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel&showAll=true

But I could reproduce it on my system as well. I've played with the configs for a while but it always copies the entries in the aliases line twice into the hosts file.

Opened up bug https://bugs.funtoo.org/browse/FL-4676

Share this post


Link to post
Share on other sites

As I see from your /etc/conf.d/hostname file you are setting aliases from other hosts but my file says:

# If your local system has other aliases for your local interfaces, you can
# add them here. These will also be added to /etc/hosts for 127.0.0.1 and ::1:
# Add aliases for other hosts to /etc/hosts directly. The networking scripts
# automatically generate the localhost lines only.

#aliases="mybox server1"

you should be putting aliases for other hosts in /ect/hosts as the directions say. its how I am doing it and have had no problem like this.

may well be why this is occurring.

 

Share this post


Link to post
Share on other sites

@dhudson You are correct, putting these entries into /etc/hosts directly seem to work.

But, if that is the way it should be done, why is there a big warning in the /etc/hosts file not to do it?

# 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
#

And it seems also contradictory to what is written here: https://www.funtoo.org/Hostname (bottom part)

Either the functionality or the documentation is not correct here and should be fixed.

Share this post


Link to post
Share on other sites

I am not sure about that warning, I remember seeing it before but either I maybe deleted it?

just checked laptop and there is no warning there either, but can confirm the same problem Maurice reported,

putting other hosts in aliases inside the quotes does that but goes away when done the way I described... strange!

also @mauricev I don't believe you need to alias your local box like that it already knows its base from the hostname=

but I may be wrong.

Share this post


Link to post
Share on other sites
1 hour ago, dhudson said:

also @mauricev I don't believe you need to alias your local box like that it already knows its base from the hostname=

but I may be wrong.

There is probably no need for this but some applications don't access the local host by using 127.0.0.1 but by the real address.

Share this post


Link to post
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

×