[BlueOnyx:24425] Re: strange issue vsite and hostname

Michael Stauber mstauber at blueonyx.it
Tue Oct 27 17:30:32 -05 2020


Hi Gerrit,

> From our documentation, the hostname *should* be abc.xyz.net.
> On the server exists a vsite abc.def.net that is actually the same as the
> hostname.
> I did not expect this to actually work. We do not know, how it got there.
> (Bug, Customer changed it,...)

Yeah, this sure causes problems.

> We tried changing the hostname back to abc.xyz.net. This works in the first
> place, but after a reboot of the machine hostname abc.def.net is back.
> Also it seems that the old name still resides in some configuration files in
> /etc (admserv, hosts, ...)

On reboot the CCE constructor /usr/sausalito/constructor/base/system
uses the Perl module Sys::Hostname::FQDN to determine the servers host
and domain name this way:

($name,$aliases,$addrtype,$length, at addrs)=gethostinfo();
$myhost = short();
$fqdn = fqdn();
@hlist = split(/\s/, $aliases) ;
foreach $line (@hlist) {
    if ($line =~ m/^$myhost\.(.*)$/ig ) {
        unless (($line =~ m/localhost/ig) || ($line =~ m/localdomain/ig)) {
            $fqdn = $line;
        }
    }
}
$mydomain = $fqdn;
$mydomain =~ s/^$myhost\.//;

if ( $myhost eq "" ) {
    $myhost = "localhost";
}
if ( $mydomain eq "" ) {
    $mydomain = "localdomain";
}

So we end up with either the real host and domain name, or
"localdomain.localhost".

To see what the system has stored in regards to the host and domain name
you can use these three commands:

uname -a
hostnamectl
nmcli g hostname

This info is then inserted into CODB and a handler runs the required
commands to tell the system its new name.

HOWEVER: CentOS 7 and CentOS 8 are a bit unique there. In the past the
"hostname" command was sufficient to set a new hostname. But with the
introduction of "static", "transient" and "pretty" hostnames (which can
all be somewhat different from each other) things got messy and just
using "hostname" to set the hostname doesn't stick all that well.

I just published YUM updates for 5209R and 5210R that now use *all* the
bloody methods with which one can set the hostname in the hope that if
we fling enough shit, some will eventually keep sticking to the wall.

Here are the commands that we're using for that:

/bin/hostname $fqdn
/usr/bin/hostnamectl set-hostname $fqdn
/usr/bin/hostnamectl set-hostname $fqdn --static
/usr/bin/hostnamectl set-hostname $fqdn --transient
/usr/bin/nmcli g hostname $fqdn
/usr/bin/systemctl restart systemd-hostnamed

But like said: Do a "yum clean all" and "yum update" and then once you
change the hostname via the GUI it should finally stick even through
reboots.

-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list