[SOLVED] Cannot set transient hostname on Arch Linux Linode
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,
Has anyone else had this issue?? What should I do?
10 Replies
- Les
@joe_temp:
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:
- Les
Sorry to tell you Les, you are wrong. Read the hostnamectl man page:
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.
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.
[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.
You can run Ip utility to see what kind of network interfaces you already have.
# 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.
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</noarp></noarp></noarp></noarp></noarp></broadcast,multicast></noarp></noarp></noarp></broadcast,multicast,up,lower_up></broadcast,noarp></loopback,up,lower_up>
According to Network configuration - ArchWiki
# systemctl status systemd-networkd
If the above command returns something like the following
● 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
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
[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 =======
> By default hostname received from the DHCP server will be used as the transient hostname.
To change it add UseHostname=false in section [DHCPv4]
/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.
[Match]
Name=eth0
[Network]
DHCP=yes
[DHCPv4]
UseHostname=false
I hope this helped.
@manrajsingh:
I hope this helped.
It helped me hate the SYSTEMD morons even more for inflicting this nonsense on everyone - thanks.