Windows 8 - HostnameA system can be identified on a network with a MAC address, IP address or its hostname. The hostname is the most readable form for humans, especially because you have the ability to change the hostname (unlike a MAC address and only partially for an IP address).

Giving the device a human readable hostname makes it easier to troubleshoot issues and is sometimes required to to apply to a naming convention. Having an asset tag on the device makes it easier for a user to explain what device he/she is using.

But what if you’re unable to change the hostname of a device or don’t want to specify this for each device? Think of thin clients (or zero clients) like a HP Smart Zero Client where you can’t (or want) to configure the hostname per device.

Well, you can push the hostname via the Dynamic Host Configuration Protocol (DHCP).

DHCP

A client can be configured with static or dynamic IP configuration, by default all systems are configured with a dynamic configuration. This means that a client requests an IP configuration from a server on the network, the DHCP server. DHCP works basically works in three phases:

  1. Initialization
  2. Renewing
  3. Rebinding

During the startup process of a system (or actually the network stack) there is no IP configuration and therefore it needs to initialize. During this phase (at least) 4 packets are broadcasted,

After receiving (and confirming) an IP configuration, a DHCP lease, a timer monitors when the half of the lease time T1 (typical lease time is 8 hours, so T1 is 4 hours) is expired. A unicast is sent to the DHCP server to renew the configuration. If the renewing phase fails (for what ever reason) the same request is sent as a broadcast the Rebinding phase). After the lease expires the whole process starts from the Initialization phase.

DHCP options

Besides offering an IP address the DHCPOFFER packet contains a list op DHCP options. The most common used are:

     001 – Subnet Mask

     003 – Router

     006 – Domain Name Server

     015 – Domain Name

With BOOTP / DHCP option 012 a host name can be supplied, but only if the client requests a hostname.

 

Server configuration

On the DHCP server you need to specify what name (hostname) you need to give to what device (MAC address), this is done with a reservation. You need to create a reserveration for each device and therefore you need to know the MAC address of all of those device.

 

Linux

If your using a linux server as your DHCP server you’re probable using dhcpd (DHCP daemon). You can add a reservation with the following lines in dhcpd.conf.

host LAPTOP_IV { 
   hardware ethernet 60:6B:BD:0B:67:3F; 
   fixed-address 192.168.0.101;
   option host-name "LAPTOP_IV";
}

host THN-WG-2012 { 
   hardware ethernet 9C:8E:99:E7:1A:B8; 
   fixed-address 192.168.0.102;
   option host-name "THN-WG-2012";
}

 

Windows

The following procedure explains how to add a reservation for a device and specify a hostname in a Windows 2008 R2 Server.

  1. In the left pane, select the Address Leases in the scope where the device has a DHCP lease
  2. Right-click the DHCP lease, and then select Add to Reservation

  3. In the left pane, select the Reservations in the scope where the device has a DHCP lease
  4. Right-click the Reservations, and then click Configure Options

  5. Select option 012 Host Name and enter the name of the device in the Data entry field


  6. Verify the information is correct and click OK


Client configuration

Linux

On a a device with a Linux operating system the dhclient  provides a means for configuring network interfaces using DHCP (or BOOTP). The configuration is stored in the dhclient.conf file (which can be found in /etc/dhcp).

In this configuration file you can specify which DHCP options the client should request (and honor) with the DHCPREQUEST packet. One of the options you can specify is:

request host-name

 

Windows

Unfortunately Microsoft has not implemented DHCP option 012 (Host Name) in the DHCP client.

I’d like to be proven wrong, so if you know how to configure the Windows DHCP client to receive a host name let me know in the comments.

 

Result

In this example a HP t510 thin client with MAC address 9C:8E:99:E7:1A:B8 got a default hostname of HP9c8e99e71ab8. If all is configured well the device requests the hostname from the DHCP server, resulting in the hostname THN-WG-2012.

  >   >   >   >  

2 Comments

  1. Hello. Thanks for this so interesting post!
    One question, though…if there’s no DNS server in LAN, having a hostname given by a DHCP server is pretty useless, isn’t? Because, if I haven’t understood this badly, there’s no way to get the name of a client-machine from another client-machine. Am I wrong?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

en_USEnglish