Talking about DHCP Relay


        I believe that many students who are studying networking are familiar and unfamiliar with the DHCP protocol. This protocol is a necessary protocol for us to surf the Internet through terminal devices in our normal lives. Today we will chat about this familiar and unfamiliar Internet protocol.    

        Dynamic Host Configuration Protocol (DHCP) is a technology for centralized dynamic management and configuration of user IP addresses. When we learned this knowledge in the HCIA stage, the scenario given was very simple-DHCP client and DHCP server are in the same network segment; today we will popularize the scenario where DHCP client and DHCP server are not in the same network segment. , How to make DHCP client obtain ipv4 address.

        

 image.png

 

        As shown in the above figure: if the router device between the DHCP client and the DHCP server does not enable the DHCP Relay function, then the DHCP client will send a DHCP discover broadcast message to obtain the ipv4 address. At this time, because the router in the middle is isolated and broadcast, then At this time, the discover broadcast message sent by the DHCP client cannot be delivered to the DHCP server through this intermediate router. This causes the DHCP client to never obtain an ipv4 address from the DHCP server. So in order to solve this problem, we let the intermediate router device turn on the DHCP Relay relay function. When the intermediate router turns on the relay function, it will convert the discover broadcast message sent by the client into a unicast message and forward it to the DHCP server. After that, all the broadcast messages sent between the DHCP client and the relay router will communicate with each other in a unicast manner after passing through the relay router.

        Next, we will demonstrate the above theory through a specific experiment.

        

 image.png

 

        Experimental scenario description: The DHCP server and the DHCP Relay belong to the 10.1.1.0/24 network segment, and the DHCP Relay and the DHCP client belong to the 192.168.0.0/24 network segment. The purpose now is to make the DHCP client PC1 available from the DHCP server. An ipv4 address of 192.168.0.x/24, through which the Internet can be accessed.

        At this point, we are capturing packets on interface G0/0/1 of R1

 image.png

 

        At this time, we are capturing packets on interface G0/0/2 of R2

 image.png

 

        As shown in the two screenshots of the above two packet captures: the discover and Request messages between the DHCP Relay and the DHCP client are broadcast, and these two messages are indeed unicast messages between the DHCP server and the DHCP Relay, which just verifies the previous About the theory of messages. So does PC1 get the ipv4 address of 192.168.0.x/24? How did you get it? PC1 sends a discover broadcast message to the dhcp relay router R1. The dhcp relay router R1 turns the discover message into a unicast message and sends it to the dhcp server, and the DHCP server passes the "relay agent" in the discover message ip address=192.168.0.1" and your server also has an address pool of 192.168.0.0/24. At this time, the dhcp server knows that it is time to assign an address of 192.168.0.x/24 to the DHCP client. As shown in the figure below, PC1 finally got an address of 192.168.0.254/24.

 image.png

      Finally, I leave two questions for you to think about:

1. What does the DHCP server use to determine which network segment ipv 4 address should be allocated ?

2. According to our experiment, the client is in the network segment of 192.168.0.0/24 , and the server is in the network segment of 10.1.1.0/24 , then how does the server know that the client should be assigned the ip address of the network segment of 192.168.0.0/24 Instead of assigning the ip address of the network segment 10.1.1.0/24 ?

      

 

 


Guess you like

Origin blog.51cto.com/15134242/2662754