You are not logged in.

#1 2014-05-18 22:07:51

joetemp
Member
Registered: 2013-12-16
Posts: 73

[SOLVED] Hostname on Arch server resets after reboot

Hey guys,
I'm having an issue that's been talked about but not in this context. I'm trying to deploy a Linode VPS running Arch. Everything works great except for one thing: I cannot name my VPS. Well, I can, but as soon as I reboot, it looses its name. This part is important:

I'm NOT setting it temporarily. I'm following two methods that are recommended in the Wiki. The Beginners' Guide as well as the Network Configuration section, offer different advice that more or less do the same thing. I've tried this combination:

# echo myhostname > /etc/hostname

plus...

# nano /etc/hosts

#
# /etc/hosts: static lookup table for host names
#

#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost.localdomain	localhost	myhostname
::1		localhost.localdomain	localhost

# End of file

Found here: https://wiki.archlinux.org/index.php/be … e#Hostname

and this:

# hostnamectl set-hostname myhostname

plus...

/etc/hosts

#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost.localdomain	localhost myhostname
::1		localhost.localdomain	localhost

Found here: https://wiki.archlinux.org/index.php/Ne … e_hostname

Linode support seems to think it could be an issue with DHCP. So, they recommended a static IP... which I can't get to work for the life of me. What thoughts do you guys have?

Any help is very, very appreciated.

Last edited by joetemp (2014-05-20 03:26:52)

Offline

#2 2014-05-18 22:43:11

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

Just so you guys know, if I spin up a VPS that runs Ubuntu or Debian, I'm able to set a hostname that withstands a reboot no problem. This is without any static IP configuration. So, I'm wondering what other thing is controlling the hostname in Arch that I'm not aware of?

Offline

#3 2014-05-18 22:49:04

cris9288
Member
Registered: 2013-01-07
Posts: 348

Re: [SOLVED] Hostname on Arch server resets after reboot

isn't it supposed to be

#<ip-address>	<hostname.domain.org>	<hostname>
127.0.0.1	localhost.localdomain	yourhostname
::1		localhost.localdomain	yourhostname

EDIT:fixed formatting

Last edited by cris9288 (2014-05-18 22:49:38)

Offline

#4 2014-05-18 22:51:49

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

That's not what I saw on the wiki... but alas, I've tried that because that's what Linode suggests. There's clearly some piece of this that I'm missing.

Offline

#5 2014-05-18 22:52:38

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Hostname on Arch server resets after reboot

What's the output of 'hostnamectl'?

$ hostnamectl
   Static hostname: black
Transient hostname: dhcppc0
         Icon name: computer-desktop
           Chassis: desktop
        Machine ID: [redacted]
           Boot ID: [redacted]
  Operating System: Arch Linux
            Kernel: Linux 3.14.4-1-ARCH
      Architecture: x86

'Transient hostname: dhcppc0' is what may break things.

$ cat /etc/hostname 
black

Interesting. 'hostnamectl set-hostname --transient black' fixes it until reboot. I'm using systemd-hostnamed and not dhcpcd and this is likely the cause of the issue on my system.
I have no idea if this has anything to do with what you're experiencing.

Offline

#6 2014-05-18 23:01:39

cris9288
Member
Registered: 2013-01-07
Posts: 348

Re: [SOLVED] Hostname on Arch server resets after reboot

This snippet from the hostnamectl man page may be relevant:

This tool distinguishes three different hostnames: the high-level
       "pretty" hostname which might include all kinds of special characters
       (e.g. "Lennart's Laptop"), the static hostname which is used to
       initialize the kernel hostname at boot (e.g. "lennarts-laptop"), and
       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 and is only temporarily written to the
       kernel hostname (e.g. "dhcp-47-11").

What's the output of 'hostnamectl --static' 'hostnamectl --pretty' and 'hostnamectl --transient' and what is your VPN using your for network management? It sounds like you are going the manual route, but I just wanted to be sure.

Offline

#7 2014-05-19 03:25:28

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

@karol So, when I use:

hostnamectl set-hostname deathstar

It sets static and transient. Here is what I get:

Static hostname: deathstar
Icon name: computer-vm
Chassis: vm
Machine ID: 323f82a03c2e4a08961b5749acbb411b
Boot ID: 9dd547f32c64420dbead104b85b81984
Virtualization: xen
Operating System: Arch Linux
Kernel: Linux 3.14.4-x86_64-linode40
Architecture: x86-64 

It doesn't actually list transient because they're the same. It doesn't set a pretty version... because there's no special characters or spaces.

@cris9288 Now, when I reboot, the static hostname is still 'deathstar' but the transient hostname reverts back to 'li708-220'... just like the man page says. How much of a problem is this? Will it limit me in any capacity? Or is it fine?

Offline

#8 2014-05-19 16:49:34

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

I guess my question is: Do I really NEED to set a transient hostname? Or is this purely cosmetic and superficial?

Offline

#9 2014-05-19 18:57:18

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

I'm pretty sure it has something to do this this:

https://wiki.archlinux.org/index.php/Sy … CP_network

If I'm not mistaken, I should do this:

/etc/systemd/network/MyDhcp.network

[DHCPv4]
UseHostname=false 

However, I don't have a MyDhcp.network file in /etc/systemd/network. Should I simply create one and paste in these few lines?

Offline

#10 2014-05-19 19:44:54

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [SOLVED] Hostname on Arch server resets after reboot

By default /etc/systemd/network/ is empty. It is used for configuring network adapters using systemd-networkd. Can you "simply" create a file in that location with that content? Yes. Will that work? Only if you use systemd-networkd and configure an interface to use it.

Here's my config:

[Match]
Name=enp6s0

[Network]
Address=192.168.1.150/24
Gateway=192.168.1.1

Here [Match] says which network adapter to use with systemd-networkd, and [Network] provides the settings.

Last edited by bstaletic (2014-05-19 19:47:36)

Offline

#11 2014-05-19 19:56:53

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

Thank you so much @bstaletic. Perhaps you can answer my other question:

Does it at all matter that I don't have a properly set transient hostname? What bearing will this have on my server... if any?

Offline

#12 2014-05-19 20:04:56

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [SOLVED] Hostname on Arch server resets after reboot

I can not give you a straight answer, but I never bothered setting up transient hostname, yet I still have no issues related to hostnames. On the other hand I have been using Arch for ~4 months.

Offline

#13 2014-05-19 21:45:26

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

Ok. I notice that when I spin up a VPS or 'Droplet' on Digital Ocean, the /etc/hosts file has not even been touched. It still reads just the standard localhost bit. Now, that could be because they have static IPs by default. However, I've served files off of a server where /etc/hosts hasn't even been touched and no more than /etc/hostname was edited. Again... with a static IP. But, I still don't know how important a transient hostname is.

Last edited by joetemp (2014-05-19 21:45:37)

Offline

#14 2014-05-20 03:30:00

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

Guys, I got it!

@manrajsingh on the Linode forums was a huge help!!!

You need to set the hostname like usual:

hostnamectl set-hostname yourhostname

Then copy this file:

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

now edit the newly copied DHCP file to read this:

[Match]
Name=eth0

[Network]
DHCP=yes

[DHCPv4]
UseHostname=false

Then, reboot. BOOM! Done! The machine is deathstar forever!!!

Thanks to all who helped out with this!

Offline

#15 2014-05-20 06:18:51

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [SOLVED] Hostname on Arch server resets after reboot

I don't think you have a network interface with eth0 name. Systemd is giving every interface a "predictable" interface name like enp6s0.

Offline

#16 2014-05-20 15:30:13

joetemp
Member
Registered: 2013-12-16
Posts: 73

Re: [SOLVED] Hostname on Arch server resets after reboot

How does this work then? Because now, after doing this, the hostname never reverts. Even if I reboot the VPS.

Offline

#17 2014-05-25 18:40:56

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: [SOLVED] Hostname on Arch server resets after reboot

What is the output of "ls /sys/class/net/" ? It should list all network interfaces existing on your pc including "lo" for localhost.

Offline

#18 2014-05-28 15:43:11

geekinthesticks
Member
From: England
Registered: 2011-09-21
Posts: 143
Website

Re: [SOLVED] Hostname on Arch server resets after reboot

Just experienced the same problem setting up a new Linode and this solution worked for me. However, I have another Linode, which I have been running Arch on for a couple of years. This worked out of the box and continues to work without this fix.

Offline

#19 2014-06-09 15:26:07

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Hostname on Arch server resets after reboot

Which version of systemd are you using now?

Offline

#20 2014-06-09 15:28:13

geekinthesticks
Member
From: England
Registered: 2011-09-21
Posts: 143
Website

Re: [SOLVED] Hostname on Arch server resets after reboot

[git@blacky .ssh]$ systemctl --version
systemd 213
+PAM -AUDIT -SELINUX -IMA -SYSVINIT +LIBCRYPTSETUP +GCRYPT +ACL +XZ +SECCOMP -APPARMOR

Offline

#21 2014-06-09 15:58:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Hostname on Arch server resets after reboot

I though more about 'pacman -Q systemd' :-)

Offline

#22 2014-06-09 17:54:11

geekinthesticks
Member
From: England
Registered: 2011-09-21
Posts: 143
Website

Re: [SOLVED] Hostname on Arch server resets after reboot

Your wish is my command:)

blacky ~ » pacman -Q systemd
systemd 213-5

Offline

#23 2014-06-09 21:09:34

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] Hostname on Arch server resets after reboot

systemd 213-6 https://projects.archlinux.org/svntogit … 8e70369a98 and  systemd 213-7 (in [testing]) https://projects.archlinux.org/svntogit … 710b6dc58b have some network-related fixes / improvements.


Is anyone still suffering from the hostname & Co. issue?

Offline

Board footer

Powered by FluxBB