Home>Article>Operation and Maintenance> Detailed explanation of DHCP protocol - where does IP come from?

Detailed explanation of DHCP protocol - where does IP come from?

齐天大圣
齐天大圣 Original
2020-12-11 16:14:34 2391browse

We know that if a host wants to communicate with other hosts, it must have an IP address. So, where did this IP address come from? Different from the MAC address, when you buy a laptop, the MAC address is stored in the read-only memory of the network card, but the IP address is not. Therefore, the IP address needs to be set by yourself. However, to configure it yourself, you need to know the knowledge of IP addresses, and you need to configure the IP address, subnet mask, gateway address, etc. Therefore, ordinary users may not configure IP. In most cases, the Dynamic Host Configuration Protocol DHCP is used to automatically obtain information such as IP addresses.

The workflow of DHCP has four steps, which are

  • DHCP discover: The new host sends a broadcast packet saying that it needs to be assigned an IP

  • DHCP offer: The dhcp server receives the request and sends a broadcast packet to tell the new host the assigned IP and other information.

  • DHCP request: The new host receives a message from the dhcp server and knows that it has a new IP. Send a broadcast packet to tell the dhcp server that you know the newly assigned IP.

  • DHCP ack: Broadcast a message packet to tell other hosts on the network that new friends have joined.

DHCP DISCOVE

When a new host (MAC address is 00:0b:82:01:fc: 42) When it first joins a network, it does not have an IP address at this time, so it needs to send a broadcast packet to let the network administrator DHCP SERVER receive the data packet (dhcp server is specially used to allocate IP and manage ip). The broadcast packet format is as shown below

Detailed explanation of DHCP protocol - where does IP come from?

#Here is an additional knowledge point: 255.255.255.255 is a special IP address for broadcast purposes. But its broadcast range is limited, and it will stop spreading when it reaches the gateway.

DHCP OFFER

When the dhcp server receives the Boot Request, it knows that a new host needs to be assigned an IP. At this time, dhcp The server also sends a broadcast packet (because the new host has not yet been assigned an IP). The information inside is the IP, subnet mask, lease and other information assigned to the new host.

Detailed explanation of DHCP protocol - where does IP come from?

DHCP REQUEST

The new host received the message from the dhcp server and knew that it was assigned The IP has arrived, but at this time, it cannot be used. I must tell the dhcp server that I have received the IP address. Therefore, you still need to send a broadcast packet to tell the dhcp server.

Detailed explanation of DHCP protocol - where does IP come from?

DHCP ACK

When the dhcp server receives the boot request message, it will broadcast it back to the client Send a DHCP ACK message packet to indicate that the client's selection has been accepted, and the legal lease information and other configuration information of this IP address are put into the broadcast packet and sent to the client to welcome it to join the network family.

Detailed explanation of DHCP protocol - where does IP come from?

At this point, the new host has its own IP address, and all subsequent data packets sent will include its own IP.

The above is the detailed content of Detailed explanation of DHCP protocol - where does IP come from?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn