FS#17223 - [dhcpcd] send hostname to DHCP server / router

Attached to Project: Arch Linux
Opened by Suraj N. Kurapati (sunaku) - Saturday, 21 November 2009, 00:34 GMT
Last edited by Ronald van Haren (pressh) - Thursday, 04 March 2010, 21:18 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Ronald van Haren (pressh)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

For the longest time, the default ArchLinux networking setup had one
deficiency: it would not send the machine hostname to the DHCP server
/ router when acquiring a DHCP lease. As a result, I was never able
to ping/ssh my ArchLinux system by its hostname from other machines in
my home network --- instead, I was always forced to type out my
ArchLinux system's IP address in full.

I looked high and low across the 'net before I finally found the
answer in the dhcpcd.conf man page: the solution was to add the
following line to my /etc/dhcpcd.conf file:

hostname

I request the developers in charge of the default ArchLinux networking
setup to make the above change, so that ArchLinux systems send their
hostnames to the DHCP server (and therefore can be
pinged/ssh'ed/accessed by their hostname) out of the box!

Thanks for your consideration.


P.S.
The following line in the default /etc/dhcpd.conf file confused me:

# dhcpcd-run-hooks uses these options.
option domain_name_servers, domain_name, domain_search, host_name

The "option host_name" part *seems* like it would send your
machine's hostname to the DHCP server, but it really doesn't.
Maybe that's a bug?



Additional info:

I am using this version of dhcpcd:

core/dhcpcd 5.1.3-1 [installed] (base)
RFC2131 compliant DHCP client daemon

And the default version of /etc/rc.d/network on a wired
(eth0) connection to my router. Here is the relevant
portion of my /etc/rc.conf file:

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="yantram"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
# - prefix an entry in INTERFACES with a ! to disable it
# - no hyphens in your interface names - Bash doesn't like it
#
# DHCP: Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#
#eth0="eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255"
eth0="dhcp"
INTERFACES=(eth0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
# - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.0.1"
ROUTES=(!gateway)

# Enable these network profiles at boot-up. These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
# - set to 'menu' to present a menu during boot-up (dialog package required)
# - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
#NETWORKS=(main)



Steps to reproduce:

1. Run `/etc/rc.d/network start` on your ArchLinux machine
2. Go to a different machine on your network
3. Try to ping your ArchLinux machine by its hostname (will not work)
4. Try to ping your ArchLinux machine by its IP address (will work)
This task depends upon

Closed by  Ronald van Haren (pressh)
Thursday, 04 March 2010, 21:18 GMT
Reason for closing:  Fixed
Additional comments about closing:  upstream has added 'hostname' to the config file
Comment by Jan de Groot (JGC) - Saturday, 21 November 2009, 00:52 GMT
sending the hostname to the DHCP server has nothing to do with being able to ping by hostname, it all depends on what your dhcp server does with the sent hostname. By default, a DHCP server won't do this updating for you and neither will a DNS server allow you to do dynamic updates.

As for the host_name option in dhcpcd.conf: if the DHCP server sends out a hostname for the client, dhcpcd will set the client hostname on the system in that case.
Comment by solsTiCe (zebul666) - Saturday, 21 November 2009, 08:50 GMT
so it's not a bug ?
Comment by Attila (attila) - Saturday, 21 November 2009, 09:41 GMT
I think more the problem is that it is not possible in the rc.conf to let the dhcp server set the hostname. And don't misunderstood me because i see this more as a feature request than a bug.-)
Comment by Thomas Bächler (brain0) - Saturday, 21 November 2009, 11:07 GMT
Okay, in the past, dhcpcd had the "-h $HOSTNAME" option set in /etc/conf.d/dhcpcd by default. This isn't the case anymore. Netcfg doesn't use that file, but also doesn't have it set.

The question is: Do we want this by default or as a user-configuration? Just adding "-h ''" to the options in /etc/config/dhcpcd should help. The same also works in netcfg profiles (or the netcfg interface config file) with the DHCP_OPTIONS/DHCP_OPTS option or similar.


As for the usefulness: Some cool DHCP server, like dnsmasq, add the hostname sent by the dhcp client to the DNS, which is very very useful. But as I said, you can easily configure this behaviour in Arch.
Comment by Ronald van Haren (pressh) - Monday, 23 November 2009, 08:34 GMT
Suppose I can add it to the dhcpcd config file on next update, I don't see any side effects in doing so. But then again, it does look like a rare case to me. Why would the inet provider need to know my hostname (or do they also provide a hostname you have to use)?
Comment by Suraj N. Kurapati (sunaku) - Monday, 23 November 2009, 16:57 GMT
The inet provider (my LAN router acting as DHCP server) does not provide a hostname to any of my LAN machines. Instead, it seems that the other Ubuntu and Windows machines on my LAN send their hostname to the DHCP server when acquiring a lease. The default ArchLinux setup did not do this, so my machine was registered as having no hostname (NULL) on the DHCP server. As a result, I could ping (by hostname) the Ubuntu and Windows machines from my ArchLinux machine, but not vice versa. Ping by IP address always works though.

Thanks for your consideration.
Comment by xduugu (xduugu) - Wednesday, 02 December 2009, 23:07 GMT
FYI, the hostname option is already contained in the default config file:

$ bsdtar xOf /var/cache/pacman/pkg/dhcpcd-5.1.3-1-x86_64.pkg.tar.gz etc/dhcpcd.conf | grep hostname
# Inform the DHCP server of our hostname for DDNS.
hostname
# A hook script is provided to lookup the hostname if not set by the DHCP
nohook lookup-hostname

Loading...