Linode Forum
https://forum.linode.com/

[SOLVED] Cannot set transient hostname on Arch Linux Linode
https://forum.linode.com/viewtopic.php?f=19&t=11059
Page 1 of 1

Author:  joe_temp [ Mon May 19, 2014 1:16 pm ]
Post subject:  [SOLVED] Cannot set transient hostname on Arch Linux Linode

Hey all,
I'm an Arch Linux user and I'm trying to set up my VPS. The only problem I'm having is that I'm unable to set my transient hostname. Arch Linux uses hostnamectl to set the hostname. This sets the static hostname, the transient hostname, and the pretty hostname. However, as soon as I reboot, the transient hostname reverts to the default hostname, which looks like 'li708-220'.

Has anyone else had this issue?? What should I do?

Author:  akerl [ Mon May 19, 2014 1:23 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

Why are you trying to set 3 different hostnames?

- Les

Author:  joe_temp [ Mon May 19, 2014 1:29 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

That's just how Arch Linux rolls. And it's not me... it's by default. Hostnamectl is a function of systemd.

Author:  sweh [ Mon May 19, 2014 1:54 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

You're likely using DHCP to get an IP address and so DHCP is setting the host name. Either convert to static IP or tell DHCP to not set the hostname. How you do this with Arch Linux... I dunno!

Author:  akerl [ Mon May 19, 2014 2:14 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

joe_temp wrote:
That's just how Arch Linux rolls. And it's not me... it's by default. Hostnamectl is a function of systemd.


As somebody who uses Arch, "no it doesn't". You set one hostname, using hostnamectl:

https://wiki.archlinux.org/index.php/Ne ... e_hostname

- Les

Author:  joe_temp [ Mon May 19, 2014 2:46 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

@akerl

Sorry to tell you Les, you are wrong. Read the hostnamectl man page:

http://www.dsm.fordham.edu/cgi-bin/man- ... &ampsect=1

hostnamectl without question sets 3 distinct hostnames. That is, unless you haven't used spaces or special characters... then it only sets two, static and transient.

The man page even talks about the fact that DHCP configurations can change the transient hostname. My question is how to stop that from happening, without using a static IP. I know for a fact there is a way to tell DHCP what the hostname should be, each time the machine is booted.

I wish anyone had a meaningful answer.

Author:  manrajsingh [ Mon May 19, 2014 9:22 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

@joe_temp

do the following as root.

# hostnamectl set-hostname yourhostname

and then

# cp /usr/lib/systemd/network/10-dhcp.network /etc/systemd/network/

use your favorite editor to modify (I am using vim )
# vim /etc/systemd/network/10-dhcp.network

Make sure the file looks like the following ... You should only have to add the last 2 lines.
Code:
[Match]
Name=eth0

[Network]
DHCP=yes

[DHCPv4]
UseHostname=false


Save the file .. reboot

After reboot .. your hostname should be the one you set initially with hostnamectl command.

Author:  joe_temp [ Mon May 19, 2014 11:31 pm ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

Hey @manrajsingh... there are no words for how grateful I am. Thank you so much for helping me out with this. I KNEW there was some kind of DHCP controlling config somewhere that I needed to edit in some way. Thank you for helping me find that. Much, much appreciated.

Author:  joe_temp [ Tue May 20, 2014 11:32 am ]
Post subject:  Re: Cannot set transient hostname on Arch Linux Linode

Does anyone know how this works? I wasn't aware that I had an interface of 'eth0'... so how does this work? By the way, it totally works, I'm just wondering how? :)

Author:  manrajsingh [ Wed May 21, 2014 1:39 pm ]
Post subject:  Re: [SOLVED] Cannot set transient hostname on Arch Linux Lin

@joe_temp

You can run Ip utility to see what kind of network interfaces you already have.

Code:
# ip address


It should return something like the following. Notice the eth0 .. I changed my ip address to xx.xxx.xx.xxx .. but you should see your ip address there.

Code:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
    link/ether 7d:5a:93:a0:06:07 brd ff:ff:ff:ff:ff:ff
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether d2:3c:f1:73:gf:85 brd ff:ff:ff:ff:ff:ff
    inet xx.xxx.xx.xxx/24 brd xx.xxx.xx.xxx scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2600:3c00::f03c:91ff:fe73:ef85/64 scope global mngtmpaddr dynamic
       valid_lft 2591987sec preferred_lft 604787sec
    inet6 fe80::f03c:91ff:fe73:ef85/64 scope link
       valid_lft forever preferred_lft forever
4: teql0: <NOARP> mtu 1500 qdisc noop state DOWN group default qlen 100
    link/void
5: tunl0: <NOARP> mtu 0 qdisc noop state DOWN group default
    link/ipip 0.0.0.0 brd 0.0.0.0
6: gre0: <NOARP> mtu 1476 qdisc noop state DOWN group default
    link/gre 0.0.0.0 brd 0.0.0.0
7: gretap0: <BROADCAST,MULTICAST> mtu 1476 qdisc noop state DOWN group default qlen 1000
    link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
8: ip_vti0@NONE: <NOARP> mtu 1500 qdisc noop state DOWN group default
    link/ipip 0.0.0.0 brd 0.0.0.0
9: ip6_vti0: <NOARP> mtu 1500 qdisc noop state DOWN group default
    link/tunnel6 :: brd ::
10: sit0: <NOARP> mtu 1480 qdisc noop state DOWN group default
    link/sit 0.0.0.0 brd 0.0.0.0
11: ip6tnl0: <NOARP> mtu 1452 qdisc noop state DOWN group default
    link/tunnel6 :: brd ::
12: ip6gre0: <NOARP> mtu 1448 qdisc noop state DOWN group default
    link/gre6 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00 brd 00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00


According to Network configuration - ArchWiki , with Systemd-networkd (systemd) version >= 209 it is possible to manage network connections with systemd-networkd. You can run the following to see if systemd-network is up and running in your system.

Code:
# systemctl status systemd-networkd 


If the above command returns something like the following

Code:
● systemd-networkd.service - Network Service
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled)
   Active: active (running) since Tue 2014-05-20 01:43:19 UTC; 1 day 15h ago
     Docs: man:systemd-networkd.service(8)
 Main PID: 2200 (systemd-network)
   Status: "Processing requests..."
   CGroup: /system.slice/systemd-networkd.service
           └─2200 /usr/lib/systemd/systemd-networkd



This means that your networking is handled by systemd-networkd service.

Now systemd-networkd - ArchWiki states that configuration files will be read from /usr/lib/systemd/network

In my previous post, I directed that you should copy the 10-dhcp.network from /usr/lib/systemd/network to /etc/systemd/network to override the settings.

Why move it to /etc/systemd/network ? Becuase files in here will not change in case of an update while /usr/lib/systemd/network could change and revert to default whenever there may be an update to systemd-networkd

Moving on .. the file contents of /usr/lib/systemd/network/10-dhcp.network are as the following

Code:
[Match]
Name=eth0

[Network]
DHCP=yes


According to this, file your IP is assigned to you by the DHCP server and according to systemd-networkd - ArchWiki

====== systemd-networkd - ArchWiki as of 05/20/2014 =======
Quote:
By default hostname received from the DHCP server will be used as the transient hostname.
To change it add UseHostname=false in section [DHCPv4]

Code:
/etc/systemd/network/MyDhcp.network
----------------------------------------------------------------------------
[DHCPv4]
UseHostname=false


====== end systemd-networkd - ArchWiki ==============

So when you set UseHostname=false system doesnt use hostname provided by DHCP server but instead uses the one you set this hostnamectl command.

Below is what your /etc/systemd/network/10-dhcp.network file should look like in order for you to use your own hostname rather than what DHCP server provides.

Code:
[Match]
Name=eth0

[Network]
DHCP=yes

[DHCPv4]
UseHostname=false


I hope this helped.

Author:  vonskippy [ Wed May 21, 2014 2:42 pm ]
Post subject:  Re: [SOLVED] Cannot set transient hostname on Arch Linux Lin

manrajsingh wrote:
I hope this helped.

It helped me hate the SYSTEMD morons even more for inflicting this nonsense on everyone - thanks.

Page 1 of 1 All times are UTC-04:00
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/