Getting started with DHCP for the first time
My name is Ito and I am an infrastructure engineer.
Do you know what DHCP is?
In fact, it exists nearby.
Can I connect to the internet at home or at work?
If you think it can be done, there is a high possibility that you are already using DHCP.
In this article, I would like to shed some light on DHCP, which is active in the shadows.
What is DHCP?
Roughly speaking, is it like this?
A protocol that allocates configuration information to enable communication with clients within a network .
When you connect a LAN cable to your PC, a pooled IP address is passed from the DHCP server, and
information about the gateway and DNS server is also passed and configured.
So, you can just plug in the LAN cable and start up the PC,
there is no need to configure network settings.
At this time, there is a DHCP server within the LAN, and the PC that is assigned an IP address from that server is called DHCP client
You will be able to access the Internet from your home PC without having to make any network settings.
That is "DHCP". At home, your router usually plays the role of DHCP.
The following are the settings that can be configured on the DHCP server.
- IP address
- subnet mask
- default gateway
- DNS server
In addition, there are other DHCP settings as follows.
- Lease period for various addresses
- Setting the scope (subnet range)
- Setting a reservation to assign a fixed IP to a specific PC
A brief explanation of each of the three settings is as follows.
Lease period | The period during which the assigned IP address can be used, and when the lease period ends, the DHCP client will obtain an IP address again. |
scope | 1 scope = 1 subnet. For example, "192.168.1.2 to 192.168.1.129" and "192.168.1.130 to 192.168.1.253" are scopes. |
reservation | A function that continues to assign the same IP address to DHCP clients with specific functions (e.g. servers) |
This setting is possible, but how does DHCP allocate IP addresses?
Let's dig a little deeper into DHCP.
More specific movements of DHCP
To use DHCP, the DHCP client must be able to receive an IP address.
DHCP is an abbreviation for ``Dynamic Host Configuration Protocol,'' which is a protocol that dynamically configures hosts,
so DHCP client C must be in a state where network settings can be configured dynamically.
This is the situation on Windows. By default, Windows is set to receive DHCP, so you don't need to worry about it too much.
For Windows 10, you can check below.
Check the properties of the target network from [Control Panel] - [Network and Sharing Center] - [Change adapter settings]
If you need to statically allocate an IP address, please do so manually as described above.
When a DHCP client receives an IP address
I will briefly outline the process by which a DHCP client receives an IP address.
- Broadcast a request to "I want an IP address" when starting the client (DHCPDISCOVER)
- The DHCP server broadcasts the setting “Please accept this IP address” (DHCPOFFER)
- The client broadcasts a request saying "Then use this IP address" (DHCPREQUEST)
- DHCP server returns OK/NG (DHCPACK/DHCPNAK)
What do you think? The secret is to communicate several times via broadcast.
After all, the IP address has not been determined yet.
It is also assumed that there will be multiple DHCP servers.
When the IP address lease period is about to end
When an IP address is assigned, the assigned IP address is linked to the MAC address of the DHCP client, and
the lease period of the target IP address is managed.
Therefore, even if the DHCP client and server do not communicate, the target IP address will continue to be assigned.
However, if there is no communication after the lease period, the target IP address will be returned to the DHCP server.
Also, when connected to the network, it performs the same operation as when receiving data earlier.
Now, I will write a little more detailed information about leases.
- When the lease period is halved, send a request to extend the use of the same IP address to the server (do the same thing as when receiving an IP address)
- If you send an extension request to the DHCP server and there is no response (DHCPACK), it will fail.
- Periodically sends an extension request to the DHCP server
- If the lease expires without a response, the IP address will be leased.
What do you think? The clever thing about DHCP is that it basically tries to use the same IP address.
By doing this, you will not have to think about setting the IP address again.
This means that the load on the DHCP server will not increase.
This is how DHCP works.
So why is there a protocol called DHCP?
It would be nice if everything was allocated statically. . . Isn't that what you think?
What are the benefits of DHCP?
If you don't use DHCP, you have to configure "IP address/gateway/DNS server" for all devices...
just thinking about it gives me chills.
Administrators in internal systems departments, etc. will benefit greatly from this.
This is because if you assign statically, you have to manage which device has which IP address. .
The big advantage is that centralized management is possible with just a DHCP server.
On the other hand, the disadvantage is that if the DHCP server goes down and cannot be recovered,
all DHCP clients may be unable to communicate.
It's a big deal, but since it's a rare accident, it might not be something to worry about.
summary
What did you think?
You may not be used to hearing about DHCP, but your home PC probably uses DHCP.
We also use DHCP to assign IP addresses to each client.
DHCP is convenient, but if you don't decide on the configuration at the construction stage, you may end up in trouble.
If the IP is not returned even after the lease period has passed,
it is possible that there will be a shortage of IPs and users will get angry.
Please plan your use accordingly.