Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

DHCP principle and configuration (including DHCP Relay Lab)

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

What is the DHCP protocol?

1. The basic concepts of DHCP protocol

DHCP (Dynamic Host Configuration Protocol, dynamic Host configuration Protocol) is an efficient IP address allocation method. The host independently controls the dynamic allocation of network addresses and uses UDP protocol to work.

1.DHCP protocol content

DHCP is mainly divided into two parts: address management and transmission of configuration information.

Address management: address management handles the dynamic allocation of IP addresses, provides clients with the delivery of address lease configuration information, including DHCP message format, state machine

two。 The benefits of using DHCP reduce the workload of administrators to avoid IP address conflicts when the network changes the IP address, there is no need to reconfigure the IP address of each user, which improves the utilization of IP address and facilitates the configuration of the client

Automatic allocation of 3.DHCP: permanently use manual allocation after assigning an IP address: the DHCP server administrator specifically specifies the dynamic allocation of IP addresses: release the IP after use for other clients

The process by which a client obtains an IP address from a DHCP server is called a DHCP lease process.

The lease process is divided into four steps:

Analyze the scene.

For example: I want to surf the Internet, for DHCP this server, how to achieve?

1. First of all, I send out "this broadcast message that I want to surf the Internet."

two。 After receiving your broadcast message, the server will randomly assign an unused IP address to you from the existing address pool.

3. Then when you receive the IP address given to you by the server, you will send a broadcast message to this server and other servers on the network that provide your own access to the Internet. Now that this address is for me, please don't assign it to others.

4. After the server receives the customer's request, it then gives the customer a response. Okay.

Corresponding to it are these four processes.

1.DHCP discover

2.DHCP offer

3.DHCP request

4.DHCP ACK

All four stages are forwarded in the form of broadcast.

2. DHCP relay service experiment

1. Experimental environment

Here we need to run three virtual machines on the computer at the same time. One CentOS 7 as server and two windows 10 as clients. Layer 3 router and layer 2 switch are built on GNS3 to realize DHCP function and automatic allocation of IP address.

two。 Experimental topology diagram

3. The procedure of the experiment

(1) install dhcp software package

Open the terminal on the CentOS 7 virtual machine and install the dhcp package

(2) build and open the topology diagram in GNS3

(3) enter sw1 configuration

Create 3 vlan, namely vlan10, vlan20 and vlan100

(4) enter port f1amp1, assign it to vlan10, and set vlan mode to access.

Enter port f1max 2, assign it to vlan20, and set vlan mode to access

Enter port f1max 3, assign it to vlan100, and set vlan mode to access

Enter interface f1max 0, set the vlan mode to Trunk, and specify the encapsulation protocol as dotq

Turn off the routing function

(5) enter sw2 configuration

Enter interface f1max 0, set the vlan mode to Trunk, and specify the encapsulation protocol as 802.1q

Create 3 vlan, namely vlan10, vlan20 and vlan100

(6) enter vlan10 and configure IP address and subnet mask

Enter vlan20, configure IP address, and subnet mask

Enter vlan100, configure IP address, and subnet mask

(7) after the above configuration is completed, go back to the virtual machine, set VMnet8 to host-only mode, and turn off the dhcp service function

Set all the NICs of the three virtual machines to custom mode, and assign VMnet1 to the first win10, VMnet2 to the second win10, and VMnet8 to the CentOS 7 virtual server.

(8) modify virtual network card settings and DHCP service coordination files

Copy the dhcp configuration file from the original path to / etc/dhcp/dhcpd.conf

Modify subnet, add 3 vlan segments, assigned IP address range, and gateway

Save and exit after configuration

(9) enter vlan10,vlan20 and vlan100 and specify the port address of DHCP server.

Above, we have completed the configuration of the DHCP relay server

Next, we switch to the client side and view our information.

Use ipconfig to view Nic information on two win10

If you can't get your network card, use "ipconfig / release" to close it, and then use "ipconfig / renew" to get it again.

(10) go back to Windows to see if it is assigned to an IP address

The above is the configuration of our DHCP mid-end service, and the experiment is successful.

Summary

In DHCP, we need to understand the basic concepts of DHCP and the process of clients getting IP addresses from a DHCP server, noting that all four processes are in the form of broadcasts. DHCP relay service is also very important. Without DHCP relay service, the client cannot obtain the IP address. Pay attention to the configuration of the link. The command of DHCP relay service configures ip add helper-address in vlan.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report