The Dynamic Host Configuration Protocol (DHCP) makes it possible to control different network configurations of clients from a server. In addition to an IP address, each client also receives a subnet mask, a gateway address, and IP addresses of the DNS servers. In most cases, the IP address owned by the client has an expiration date when the addresses are assigned dynamically. If the client does not answer for a certain time, the server assigns the address again. Accordingly, this is called the lease time. On the other hand, a connection for an undetermined time can be made in case of a manual configuration.
DHCP was used for the first time in 1993. It was built on the Bootstrap Protocol (BOOTP) of 1985. The definition of the Dynamic Host Configuration Protocol is in RFC 2131 and can be found under the UDP port numbers 67 and 68.
Advantages of the System
The main advantage is the easy use and configuration, as the network parameters have to be entered only once. Furthermore, the existing IP addresses can be used optimally. Because of the frequently changed locations, it is almost impossible that mobile devices configure themselves constantly. Here, the automatic DHCP system offers the advantage of uncomplicated and simple applicability. A plug & play network has been created.
Areas of Application
DHCP was developed for two areas. On one hand, large networks with changing users need to be managed without complications. This is the case for example in public networks, company networks, or university networks. In addition, it makes it possible for the network user without IT experience to easily make a connection without having to study the process in any depth.
The precondition for use is that automatic reception of the IP address has been set at the client. When a client wants to log onto a network that can be reached, it can receive the required parameters like IP address, subnet mask, gateway, and some others automatically from the DHCP.
Construction of a DHCP packet
- op (1 byte): Differentiation between request and answer
- htype (1 byte): Description of the network (e.g. 1 = Ethernet, 6 = IEEE 802 networks)
- hlen (1 byte): indicates the length of the physical network address
- hops (1 byte, optional): indicates the number of DHCP relay agents on the data path
- xid (4 bytes): serves for identification between client and server
- secs (2 bytes): Time in seconds since the start of the client
- flags (2 bytes): indicates whether a client has a valid IP address (1st byte), the second byte can be used for extensions
- ciaddr (4 bytes): Client IP address
- yiaddr (4 bytes): own IP address
- giaddr (4 bytes): Relay agent IP address
- chaddr (16 bytes): Client MAC address
- sname (64 bytes): Name of the DHCP server when the client is supposed to connect to a specific one (optional)
- file (128 bytes): Name of a file (e.g. system kernel) to be sent to the client (optional)
Allocation variants of the DHCP server
The IP addresses can be distributed by the server to the clients in three different ways. Depending on the requirements, a selection can be made between manual, automatic, and dynamic allocation. When the server has been started, it waits on the UDP port 67 for the query of a client that wants to connect to the network. The required parameters are located in a configuration file specified in advance and they are then sent to the client to configure it.
- Manual allocation: This type also is called static DHCP. With this, fixed IP addresses are allocated at the server to specific MAC addresses (unique identification number of a network-enabled device). This is done for an indefinite time. It is problematic that no additional clients can join the network without the administrator configuring this at the server. However, this permits increased security from undesired intruders.
- Automatic allocation: Here, the allocation is similar to the manual system, but a range of IP addresses is offered by the server to the client. However, once a MAC address is linked with an IP address, it remains connected to it for an indefinite time. When all IP address ranges have been issued, a new client can also only connect here manually.
- Dynamic allocation: This procedure again corresponds to automatic allocation, with the difference that the allocation is made only for a specified time. If no connection exists in excess of this specified time (lease time), the link between the MAC address and the IP address is dissolved and the address again becomes free. At the time of connection, the client is informed of the lease time. After one half of the time, the client makes a request and thus indicates to the server that there is further interest in the IP address. If this did not function, the connection continues to exist, until a second request is made at 7/8 of the time.
The problem with DHCP is that clients accept any server. Accordingly, when another server is in the vicinity, the client may connect with this server, and this server may possibly send invalid data to the client.
Furthermore, the supposed security of the unique MAC address is not given, as it is relatively simple to change the MAC address of a device and thus to imitate another device and to connect to the network.