[BlueOnyx:18423] Re: Hosts changing to localhost.localdomain

Michael Stauber mstauber at blueonyx.it
Fri Sep 25 20:05:13 -05 2015


Hi Colin,

> That would be brilliant! :)

I think I got it and just published updates for 5209R (base-vsite and
base-network). As usual: The cced.init restart at the end of the YUM
update might be necessary for this to kick in right away.

The new constructors and handlers that auto-generate /etc/hosts are now
Perl scripts and they create a very detailed /etc/hosts that ought to
cover all the bases.

Sample output on a testbox of mine:

[root at sec]# cat /etc/hosts
# /etc/hosts
# Auto-generated file. Please put your customizations at the very end.

# Entries for localhost and primary IP address:
127.0.0.1                       localhost    	localhost.localdomain
10.1.250.233                    sec          	sec.smd.net

# Entries for all other IP addresses bound to this server:
10.1.251.2                      sec             sec.smd.net
10.1.251.4                      sec             sec.smd.net
10.1.251.3                      sec             sec.smd.net
10.1.251.5                      sec             sec.smd.net
10.1.251.1                      sec             sec.smd.net

# Entries for all Vsites on IP addresses of this server:
10.1.251.2                      t2              t2.smd.net
10.1.251.4                      t4              t4.smd.net
10.1.251.3                      t3              t3.smd.net
10.1.251.5                      t5              t5.smd.net
10.1.251.5                      t5b             t5b.smd.net
10.1.251.5                      t5a             t5a.smd.net
10.1.251.1                      t1              t1.smd.net

# The following lines are desirable for IPv6 capable hosts
::1                             localhost ip6-localhost ip6-loopback
ff02::1                         ip6-allnodes
ff02::2                         ip6-allrouters

# END of auto-generated code. Customize beneath this line.

It does the following: It reads the existing /etc/hosts to see if there
are any customizations beneath the bottom comment. If so, it takes note
of them and chucks them at the end of the new auto-generated /etc/hosts
when it's done creating a new one.

It then adds entries for 127.0.0.1 and the primary IP of the server to a
new /etc/hosts.

Next it creates entries for all bound extra IPs that your interfaces
might have and gives them the primary hostname and fqdn of the server.

Then it adds entries for ALL Vsites with their IP, hostname and FQDN.

Lastly it adds the IPv6 provisions (which we don't really need) and
appends any manual entries that the old /etc/hosts might have had.

It also creates /etc/hostname with the hostname of the server, as EL7
somehow seems to need it nowadays. On older systems it at least won't
hurt to have it either.

Like said: This should cover all bases and you can now even ping and
locally access new Vsites by their FQDN or hostname, even if you don't
have DNS for them yet. Which is the real purpose of /etc/hosts anyway.

I'll backport this to 5207R and 5208R as well, but I first need to check
if I don't shoot myself in the foot with it as base-network on 5209R is
a hell of a lot more modern than on 5207R/5208R.

-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list