DHCP like DNS is a network service that is vital to networking and the internet.
But What exactly is DHCP, and What does it do?
In this tutorial I will explain the DHCP service and protocol, how it is implemented and how it works.
The key to understanding DHCP is to understand that all network devices on a network, and the Internet need an IP address to operate.
How Devices Get IP Addresses
There are two ways that the device can acquire an IPaddress. They are
- Manual Address assignment
- Automatic assignment using DHCP
Almost all networks use automatic IP address assignment using DHCP (Dynamic host configuration protocol) as it is easier and more reliable.
In order to have automatic address assignment on your network you need to have a DHCP server on that network.
How DHCP Works
All network devices (PCs,Tablets,Smart phones) come equipped with a DHCP client, and when they boot up they contact the DHCP server, and request an IP address.
You don’t need to tell the client the IP address of the DHCP server as the client uses a broadcast mechanism to locate it.
This means that the DHCP server must be located on the same broadcast networks as the client. -Not a problem with home networks. See the basic networking tutorial.
DHCP Server- What is it ? and What t does
A DHCP server is responsible for allocating IP addresses to DHCP clients.
The DHCP server is configured with a range of IP addresses that it can assign and also with other settings like DNS servers, default gateway addresses etc.
Provided everything is working OK they get an IP address, and other settings when they boot up.
The IP addresses from a DHCP server are normally leased, and must be renewed periodically.
The renewal process happens in the background, and doesn’t require any user intervention.
The screen shot below shows the IP address, DNS address and lease duration of my IP address.
You can find your own details by using the ipconfig /all command.
On large networks an administrator must set up and manage the DHCP server, but on home networks it is built into the home router, and doesn’t normally need any manual intervention.
Although on home networks you don’t need to configure the DHCP server you do need to tell the clients (computers) to use a DHCP for IP addresses.
This is the default for tablets and phones and computers.
DHCP Address Ranges
When configuring a DHCP server you will need to assign address ranges for the IP addresses.
When a client requests an IP address the DHCP server will assign the client an IP address from the address range.
On Home networks the home router is usually pre-configured to assign IP addresses in the 192.168. address range.
Below is a screen shot of my home router default DHCP settings:
Notice that the hub/router is using a static IP address (192.168.1.254)and this address range is outside the address range that the DHCP server is configured to allocate 192.168.1.64 -192.168.1.253.
It is also important to note that the addresses 192.168.1.1 -192.168.1.63 are not part of the allocated range.
You can use addresses in this range to assign to devices that require a static IP address.
Missing DHCP Server
If the client cannot find a DHCP server then It may auto assign an IP address from a reserved range 169.254.0.0-169.254.255.255 or simply have an IP address of 0.0.0.0.
Note: Different versions of windows use different default IP addresses
In either case it is unlikely to work correctly on the network
You can find out whether or not your client (windows) has an IP address by using the ipconfig command at a command prompt.
ipconfig ./all -This command will show IP and DNS settings
ipconfig ./release -This command will release the IP address from DHCP
ipconfig ./renew -This command will renew the IP address using DHCP
Common Questions and Answers
Q- Does DHCP work with the hosts file?
A- No it doesn’t.
Q- Can I assign static IP addresses and still use DHCP?
A- Yes most DHCP servers (even on home networks) allow you to exclude IP addresses and address ranges.
Q- Can I assign DNS servers manually even though I’m using DHCP?
A- Yes there is a separate setting for that.
Q- My IP address doesn’t appear to change does this mean that I have a static IP address?
A- No not necessarily as when a DHCP client renews its IP address it asks for the same address and will normally be allowed to keep it.
Q- Can I have more than one DHCP server on a network?
A- Yes but it isn’t common on home networks and they must be configured so as not to assign the same IP addresses from the same address range.
Related Articles and Resources
- Understanding IP Addresses
- Understanding DNS
- Internet and Networking Components– Internet and Networking Components for connecting to the Internet.
- DHCP specification RFC 2131 for IPv4
- Using the Ping Command