[systemd-devel] Transient hostname default behaviour

Lennart Poettering lennart at poettering.net
Mon Oct 29 18:18:57 PDT 2012


On Mon, 29.10.12 13:33, Daniel Drake (dsd at laptop.org) wrote:

> Hi,
> 
> I'm working on updating OLPC configuration for systemd-195 based on this info:
> http://lists.fedoraproject.org/pipermail/test/2012-October/111230.html
> 
> I can't quite figure out the hostname thing.
> 
> We need to set unique hostnames for avahi; machines with the same name
> cannot collaborate. Also, avahi does not like "localhost", it then
> uses a different name which also conflicts with other systems in the
> same situation. Generating/assigning our own hostnames has not been a
> problem until now, but I can't get it working.
> 
> 
> I tried writing the hostname "foo" to /etc/hostname and rebooting.
> However, the "hostname" command still returns localhost. hostnamectl
> shows:
> 
> Static hostname: foo
> Transient hostname: localhost
> 
> avahi picks up the transient hostname, and runs into the problems
> described above. :(
> 
> This part of the man page makes me think that the transient hostname
> should default to the static hostname:
> "the transient hostname which might be assigned temporarily due to
> network configuration and might revert back to the static hostname if
> network connectivity is lost"
> but that seems not to be happening.

The dynamic host name does default to the static hostname.

> Any hints?

Something is changing your hostname. You need to find out what. One
chance to find the culprit might be to replace /usr/bin/hostname by a
script, and log about how and by what it is called from that
script. That of course only works if the culprit uses /usr/bin/hostname
(rather than the sethostname() syscall directly, or writing to
/proc/sys/kernel/hostname), but this is quite likely, given that
dhclient and similar tools apply host name changes via callout scripts.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the systemd-devel mailing list