Hi, i want to use Leap 15.2 LXC containers and im found problem with hostname settings when wicked networking is used.
Setting hostname with
hostnamectl set-hostname somename
sucessfully change hostanme and /etc/hostanme modified.
But after restaring container this stay only as Static hostname
and old name was set as Transient hostname
As i read about transient it was changed by networking but i don found any configuration to be able change it.
There is only static network settings, no DHCP, no mDNS, no yast net configuraion.
When NetworkManager is used for networking it works correctly and it set hostname after container re/start.
But i don want to have NM for networking.
Yast is not installed in LXC container by default.
DHCP is not configured, i try also disable and mask wickedd-dhcp4, wickedd-dhcp6, wickedd-auto4 services to be sure that is not used.
Im checked jourrnal boot messages and no dhcp try start.
Temporary im created systemd service which run hostanamectl.
[Unit] After=local-fs.target network.target
Transient hostname is still set by some service after this. Im not sure which one but with
For what purpose are you using the Hostname?
Technically, a hostname is any name which will resolve to the ip address of the machine (or container in this case) and a machine can have any number and multiple hostnames that resolve to
The system Hostname is only the default hostname the machine advertises to others how it wants to be known, but there is usually no requirement that others need to resolve that specific name to access your machine.
Although a Hostname is always set that’s unique on the network (A requirement), you’ll notice in the DHCP settings that allows the DHCP server to assign a different name to your machine.
Another example would be if you deploy a webserver on your machine supporting multiple websites that share the same IP address but use different host headers (different hostnames) to serve different websites. Typically in this and many other scenarios, a DNS server provides the mapping of hostnames to IP addresses.
Locally on a machine with multi-tenant apps like LXC dnsmasq might provide the hostname mapping in place of a full blown DNS server.
It’s also possible to use /etc/hosts entries to do something similar.
There’s many ways to set up hostname resolution, and any can be used unless you are running an app that requires a specific way… eg an app that might connect through UNIX sockets instead of network sockets, so can’t contact a name resolution server over a network.
Some applications read hostname to build their registry on that key. And is not read as fdqn from dns.
Im read documentation about wicked and its mechanism is use dbus for managing, and I dont found way how to set hostname when DHCP or mDNS is not used.
Im found that LXD report hostname to container as LXC container name (even dhcp is not used) so wicked take it as static hostname and then it is set via DBUS. And because host have set different hostname in /etc/hostname
it will be set by wicked as Transient. It can be changed via Yast but only temporary (after reboot is old again).
So i see the only way to rename container to that name which i want or use NetworkManager or additional systemd service as i created to update hostname.
This would probably work,
“In the old days” before systemd and more often than not still an acceptable practice nowadays,
If you want to run a system configuration command that won’t remain persistent across reboots,
Place the command within the following file and it will always run on bootup.
So, in your case, you can run your hostnamectl command within that file.
I don’t know for sure, but would assume it would be run in an LXC container… of course the slight issue might be that a container image might “just run” and not go through the usual bootup process as a normal machine.
For the sake of archives - you seem to believe that wicked does something special so set “transient” name. “Transient” exists only in systemd-hostnamed run-time properties and means that current hostname as set in kernel is different from hostname recorded in /etc/hostname. Nothing more, nothing else. Nobody “sets Transient name”.
If you actually showed value of /etc/hostname and hostnamectl output at least once, someone would have answered it already. Instead you continued with long descriptions of what you thought have happened without showing any fact.
This is text book example of how to not ask questions. Sorry.
LXD installs and uses dnsmasq as its local and private (utilized only by the local machine and any containers or machines on your machine, not accessible by remote machines) name resolution. You can create and modify dnsmasq zone and records directly. Although the following was written for Ubuntu, I see nothing that should work differently on other distros including openSUSE https://blog.simos.info/how-to-use-lxd-container-hostnames-on-the-host-in-ubuntu-18-04/
Correcting some misconceptions in your post…
The Fully Qualified Domain Name (FQDN) means that the name includes both the hostname(eg fu) and domain name (eg bar) which together creates the FQDN example fu.bar
I don’t know that there are any restrictions on what you should enter for your hostname partly because technically you can also have subdomains in the name, but it’s unorthodox to enter an entire FQDN in the hostname variable… A DNS may try to use your hostname variable in combination with a domain variable which would result in a weird result.
I agree with you. Im in learning process and it will be better
Good point, thanks. So it is not problem of wicked, now its clear to me.
Im find some documentantion https://www.freedesktop.org/software/systemd/man/hostname.html and regarding that semantics Transient hostname dont have be set beacause /etc/hostanme have higher priority.
“Note that systemd-hostnamed.service(8) gives higher priority to the static hostname, so the transient hostname will only be used if the static hostname is not configured.”*