Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED]I don't understand transient hostnames
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
beguiledfoil
n00b
n00b


Joined: 23 Jan 2011
Posts: 47

PostPosted: Wed Sep 10, 2014 6:16 pm    Post subject: [SOLVED]I don't understand transient hostnames Reply with quote

So, this is a poor question, and I'm sorry. I'll do my best to make it productive and keep it short.

I'm running a systemd based system for the first time and I'm having an issue with my hostname. Basically, when I connect to (some) networks the network assigns me a transient hostname. This transient hostname seems to completely break everything with my desktop manager (KDM). I have to log out, and then log in with the new transient hostname (which is presumably assigned shortly after I log in and network manager connects to the network).

Is this expected? I have set my hostname as described in the handbook and the systemd wiki page.

How do I make my hostname *never* change based on dhcp crap?


Last edited by beguiledfoil on Thu Sep 11, 2014 6:06 am; edited 1 time in total
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1636
Location: United Kingdom

PostPosted: Wed Sep 10, 2014 7:27 pm    Post subject: Reply with quote

Are you using NetworkManager, by any chance? I use OpenRC rather than systemd, but you can tell NetworkManager to use a persistent hostname by editing the file /etc/NetworkManager/NetworkManager.conf and specifying the hostname. Here is what I have in mine:

Code:
[main]
plugins=keyfile

dhcp=dhcpcd

[ifnet]
managed=true
auto_refresh=false

[keyfile]
hostname=meshedgedx

You'll notice that I'm using dhcpcd. Well, strictly speaking, NetworkManager is using dhcpcd. If I (NetworkManager, really) were using dhclient, I'd have declared dhcp=dhclient in the file instead.
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
beguiledfoil
n00b
n00b


Joined: 23 Jan 2011
Posts: 47

PostPosted: Wed Sep 10, 2014 8:04 pm    Post subject: Reply with quote

Thanks so much for the reply. I don't have a NetworkManager.conf in that location. Should I create it? I'm a little worried that it won't be used as there are other references to a NetworkManager.conf that should live in /etc/dbus-1/system.d/. The version of NetworkManager.conf that lives in /etc/dbus-1/ is also, apparently meant to be XML.

I'm really tempted to just go back to openrc. I adopted systemd because it seemed inevitable, but the fact that I've managed to make my desktop unresponsive (like, I can't even run a program) by misconfiguring my network is clearly complete insanity.

Edit: I think you're totally right about this being a misconfiguration of NetworkManager on my part. My /etc/resolv.conf has some nameserver stuff and a comment that it was "Generated by NetworkManager". My current best idea is that I need it to not generate nameserver stuff (which is maybe what you're suggesting) :)
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1636
Location: United Kingdom

PostPosted: Wed Sep 10, 2014 8:37 pm    Post subject: Reply with quote

I'm not sure what you're doing, but NetworkManager takes care of everything in my case. Anything special can be done using NetworkManager Dispatcher (e.g. I use NetworkManager Dispatcher to insert "options single-request" in /etc/resolv.conf because my ISP does not support IPv6 and my home router does not handle IPv6 requests correctly, but that's another story).

I know very little about systemd configuration, but, according to the Arch Wiki article on NetworkManager, you can force a persistent hostname in the same way that I'm doing it on my Gentoo installation with OpenRC, namely to do as I wrote in my previous post. Have a look at the Arch Wiki article which explains it: https://wiki.archlinux.org/index.php/NetworkManager#Hostname_problems
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Wed Sep 10, 2014 8:45 pm    Post subject: Reply with quote

Speaking solely for dhcpcd, dhcpcd will set the hostname if the DHCP message supplies one and the hostname is currently unset.

What does this mean in real terms?
Ensure that whatever statically configures the hostname runs before dhcpcd.

The same rule applies to dhclient as well, NetworkManager uses them both but I think it controls the hostname.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
beguiledfoil
n00b
n00b


Joined: 23 Jan 2011
Posts: 47

PostPosted: Wed Sep 10, 2014 11:26 pm    Post subject: Reply with quote

Great suggestions folks. I've done a few things that may or may not be making a difference:

1. Added UseHostname=false to /etc/systemd/network/10-dhcp.network Full instructions here
2. Updated my /etc/hosts file to include '.localdomain':
127.0.0.1 my_real_hostname localhost.localdomain localhost

I'll report back if this has finally fixed it. A race condition between whatever is setting the hostname statically and NetworkManager/dhcpd would be my worst nightmare. No idea what is setting the hostname statically...
Back to top
View user's profile Send private message
beguiledfoil
n00b
n00b


Joined: 23 Jan 2011
Posts: 47

PostPosted: Thu Sep 11, 2014 5:49 am    Post subject: Reply with quote

I think everything is working thanks to the arch wiki page that Fitzcarraldo linked me to.

Specifically, I ended up adding a /etc/NetworkManager/NetworkManager.conf that contains the following lines:

[keyfile]
hostname=your_hostname

Where your_hostname is my hostname. My hostname is now written in 3 places (/etc/hosts, /etc/hostname, and /etc/NetworkManager/NetworkManager.conf). Oh, and I have some random executable (hostnamectl) sitting on my system doing a seemingly poor job of 'controlling' my hostname.

On a related note: If anyone knows of developers that are actively maintaining/improving openrc or are in any way ensuring that systemd remain optional please link me to their paypal(s)...
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Thu Sep 11, 2014 6:34 am    Post subject: Reply with quote

beguiledfoil wrote:
On a related note: If anyone knows of developers that are actively maintaining/improving openrc or are in any way ensuring that systemd remain optional please link me to their paypal(s)...


They don't require paypal as such. I'm not involved in OpenRC active development these days - it does what I set out to do at the time.
However, what the team really needs is more developers!

I do have a wishlist though, but I only really work on dhcpcd and related parts right now, although I have submitted two OpenRC patches recently .... heh.
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Fitzcarraldo
Veteran
Veteran


Joined: 30 Aug 2008
Posts: 1636
Location: United Kingdom

PostPosted: Thu Sep 11, 2014 2:09 pm    Post subject: Reply with quote

For what it's worth, OpenRC causes me absolutely zero trouble. It just works. Reliably. And I like its features, such as local.d which enable me to do what I want to do. Perhaps my needs are not as sophisticated as some people's, but OpenRC does everything I need and no doubt more.

I have written only a handful of OpenRC init scripts in my time, but they were easy to knock out and worked. Ironically, one of them was to implement, just for the fun of it, Lennart Poettering's and Vivek Goyal's userspace alternative using cgroups to the so-called "200 Lines Kernel Patch That Does Wonders" back in 2010 (my post Re: Magical Patch!! in the Sabayon Linux forums referred).

So thank you for creating it, Roy!
_________________
Clevo W230SS: amd64 OpenRC elogind nvidia-drivers & xf86-video-intel.
Compal NBLB2: ~amd64 OpenRC elogind xf86-video-ati. Dual boot Win 7 Pro 64-bit.
KDE on both.

Fitzcarraldo's blog
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6737
Location: Blighty

PostPosted: Thu Sep 11, 2014 2:36 pm    Post subject: Reply with quote

:oops: :oops: :oops: :oops: :oops: :oops:
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
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
You cannot vote in polls in this forum