A blog and nothing more.

Fedora, NetworkManager, hostname, DHCP

  • Wed 09 September 2009
  • oss

So after my last post I went on and started testing different configs to pinpoint where exactly the problem was. I didn't want to do that because I'm a lazy guy, but incredibly enough, google gave only vague results concerning my predicament.

The Problem

... or more like "annoyance" in this case. The facts:

  • My main router is a wireless
  • All the machines in my house connect wirelessly, all of them are linux machines
  • I used to have an ubuntu machine, now all of them are fedora
  • All of them can connect and use the internet just fine
  • Ubuntu machines (I only tried with ubuntu, I cannot assert this happens with other distros) identify themselves with their hostnames in the router list
  • Fedora machines (and I suspect any RH-based distro, again, this is just a guess) do not identify with their hostnames, the IP Address is the only record that appears in the router's client list
  • All of them are stock, just-installed machines using NetworkManager
  • My wireless network does not use any kind of key. This shouldn't have any impact whatsoever, but I wanted to clarify
  • If I connect to the router using an ethernet cable, both ubuntu and fedora work properly

The Testing Process

As I said, both distros have the stock install. I accomplished this by using ubuntu (Jaunty) and fedora (Leonidas) live CDs. No additional packages were installed, just the stock NetworkManager stack. After each test I disabled the networking (right-click on NM's applet, uncheck "Enable Networking"), deleted the lease file from /var/lib/dhclient and powered down the router. After making the changes (and waiting something like 5 minutes) I'd power up the router and re-enable NM.

The Root Cause

There were several comments in my last post explaining several theories, and I myself had a hunch where the issue could be present. Most of them pointed me to the dhclient.conf file, but that was half the issue:

  • Yes, it has to do with the DHCP request being sent to the DHCP server
  • The magic parameter here is "send host-name"
  • The tool system-config-network-gui does half the job

I had already tried adding the hostname in the DHCP part in the system-config-network-gui tool (Devices tab -> Your wireless card -> DHCP Settings -> Hostname (optional)) to no avail. I tried this with the eth0 and wlan0 cards, it worked OK for eth0, but not for wlan0.

The problem here is that fedora works with sysconfig parameters, that is, every tool fedora uses for its own management ends up creating/updating config files inside /etc/sysconfig. The conf files for the network cards are in /etc/sysconfig/network-scripts/ifcfg-YOURNIC, so, if you have eth0 and eth1 you should have ifcfg-eth0 and ifcfg-eth1, ifcfg-wlan0 for your first wireless card. If you check ifcfg-wlan0 after making the changes through system-config-network-gui you'll see a line like:


Again, check both the eth and wlan ifcfg files and you'll see your changes there, so what's causing only the wireless card to bork? Right now all evidence point to NetworkManager. NetworkManager does a damn fine job at managing your network connections, but it does it differently given the distro where it is running. So it reads the sysconfig files in fedora, and reads the /etc/default/interfaces stuff in debian-based distros. Besides that, it reads the common dhclient config. In ubuntu, we do have a file /etc/dhcp3/dhclient.conf which has a line:

send host-name "";

I think gets replaced somewhere along the way with the hostname taken from hostname or /etc/hosts. Fedora does not have a default /etc/dhclient.conf and, actually, it doesn't work as straightforward as you'd like.

I believe (and please, someone correct me if I'm wrong, I'm almost asleep now) NetworkManager creates a dhclient.conf file on the fly by reading the sysconfig values in fedora. After that it reads the common dhclient stuff. However, it is somehow ignoring the DHCP_HOSTNAME value, so it doesn't get translated to the "send host-name" directive in dhclient.conf lingo.

The Workaround

The simplest way would be to add a file /etc/dhclient.conf with the directive and be done with it, however, fedora somehow ignores a "common" dhclient.conf file and instead uses a "per nic" conf file. So you'll have to create a file /etc/dhclient-wlan0.conf (or ra0 or ath0 or whatever your nic is called) with the line:

send host-name "prettyhostname";

Don't forget the semi-colon at the end, and of course replace prettyhostname with your actual hostname. Fedora does not work using a placeholder like ubuntu does (yes, I tried, doing so will make it appear as blank in the router's client list). Additionally, you can add any parameter you think should be superseded in this file (dns servers and whatnot)

The Closing Argument

So I spent some time understanding (or more like, trying to understand) NetworkManager's innards, I hope I got it OK. I also went ahead and posted a bug to NM's bugzilla, so hopefully this will get fixed later, the bug is here http://bugzilla.gnome.org/show_bug.cgi?id=594591

So that's it, I got to face my little pet peeve with NM, and with that, I'm off to sleep.