[systemd-devel] systemd/hostnamed: setting the hostname and using it in the DHCP Discover

Andrey Yurovsky yurovsky at gmail.com
Mon Jul 31 16:32:50 UTC 2017


On Mon, Jul 31, 2017 at 9:27 AM, J Decker <d3ck0r at gmail.com> wrote:
> There's an option under [dhcp] section
> https://www.freedesktop.org/software/systemd/man/systemd.network.html
>
> SendHostname=
> When true (the default), the machine's hostname will be sent to the DHCP
> server.
>
> UseHostname=
> When true (the default), the hostname received from the DHCP server will be
> set as the transient hostname of the system
>
> Hostname=
> Use this value for the hostname which is sent to the DHCP server, instead of
> machine's hostname.
>
>
> would think if you set your name there it won't matter what /etc/hostname
> is?

Yeah, that's the workaround I'm currently using and it does work (set
the desired string in Hostname=, leave the rest as defaults), however
what Lennart suggested is more thorough as the actual hostname will be
set to what I need and I won't be swapping or editing my .network
files. In my case the hostname is partially based on the MAC of this
fixed Ethernet interface so it's a safe bet to use udev to trigger
settings things up.


More information about the systemd-devel mailing list