Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon May 19, 2014 1:16 pm 
Offline
Senior Newbie

Joined: Mon May 19, 2014 1:11 pm
Posts: 8
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?


Last edited by joe_temp on Tue May 20, 2014 11:33 am, edited 1 time in total.

Top
   
PostPosted: Mon May 19, 2014 1:23 pm 
Offline
Senior Member

Joined: Mon Jul 05, 2010 5:13 pm
Posts: 392
Why are you trying to set 3 different hostnames?

- Les


Top
   
PostPosted: Mon May 19, 2014 1:29 pm 
Offline
Senior Newbie

Joined: Mon May 19, 2014 1:11 pm
Posts: 8
That's just how Arch Linux rolls. And it's not me... it's by default. Hostnamectl is a function of systemd.


Top
   
PostPosted: Mon May 19, 2014 1:54 pm 
Offline
Senior Member
User avatar

Joined: Tue Apr 13, 2004 6:54 pm
Posts: 833
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!

_________________
Rgds
Stephen
(Linux user since kernel version 0.11)


Top
   
PostPosted: Mon May 19, 2014 2:14 pm 
Offline
Senior Member

Joined: Mon Jul 05, 2010 5:13 pm
Posts: 392
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


Top
   
PostPosted: Mon May 19, 2014 2:46 pm 
Offline
Senior Newbie

Joined: Mon May 19, 2014 1:11 pm
Posts: 8
@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.


Top
   
PostPosted: Mon May 19, 2014 9:22 pm 
Offline
Newbie

Joined: Mon May 19, 2014 9:14 pm
Posts: 2
@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.


Last edited by manrajsingh on Wed May 21, 2014 1:40 pm, edited 1 time in total.

Top
   
PostPosted: Mon May 19, 2014 11:31 pm 
Offline
Senior Newbie

Joined: Mon May 19, 2014 1:11 pm
Posts: 8
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.


Top
   
PostPosted: Tue May 20, 2014 11:32 am 
Offline
Senior Newbie

Joined: Mon May 19, 2014 1:11 pm
Posts: 8
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? :)


Top
   
PostPosted: Wed May 21, 2014 1:39 pm 
Offline
Newbie

Joined: Mon May 19, 2014 9:14 pm
Posts: 2
@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.


Last edited by manrajsingh on Wed May 21, 2014 4:06 pm, edited 1 time in total.

Top
   
PostPosted: Wed May 21, 2014 2:42 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
manrajsingh wrote:
I hope this helped.

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

_________________
Either provide enough details for people to help, or sit back and listen to the crickets chirp.
Security thru obscurity is a myth - and really really annoying.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group