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

The principle and Construction of DHCP Service

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

Share

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

This article introduces the relevant knowledge of "the principle and Construction of DHCP Service". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

First, the realization principle of DHCP

1. What is DHCP?

DHCP (Dynamic Host Configuration Protocol, dynamic Host configuration Protocol) is a local area network protocol that uses UDP protocol to work. It is a popular Client/Server protocol, which is generally used to specify relevant configuration information for hosts, routers, etc. DHCP service has been widely used in enterprises and families. It can automatically assign ip addresses and other related information, and the whole process is transparent to customers.

two。 Benefits of deploying DHCP services

Reduce the workload of administrators

Avoid the possibility of typing errors

Avoid ip address conflicts

When the network changes the ip address range, there is no need to reconfigure each user's ip address

Improve the utilization of ip address

Facilitate the configuration of clients

3. DHCP mode

Automatic assignment (Automatic Allocation), in which the DHCP server assigns a permanent IP address to the host, which can be permanently used once the DHCP client successfully leases the IP address from the DHCP server for the first time.

Dynamic allocation (Dynamic Allocation), in which the DHCP server assigns an IP address with a time limit to the host, which can be used by other hosts when the time expires or when the host explicitly abandons the address.

Manual assignment (Manual Allocation), the IP address of the client is specified by the network administrator, and the DHCP server simply tells the client host the specified IP address.

4. DHCP working process

When the DHCP client starts, it searches for the existence of a DHCP server on the network. If found, a request is sent to the DHCP server. When the DHCP server receives the request, it selects the parameters configured by TCP/IP for the DHCP client and sends these parameters to the client. If conflict detection settings are configured, the DHCP server uses Ping to test the connectivity of each available address in the scope before providing the address in the lease to the client. This ensures that each IP address provided to the customer is not used by another non-TCP/IP computer using manual DHCP configuration.

DHCP works differently depending on whether the client logs in to the network for the first time.

DHCP work when logging in for the first time consists of four steps:

(1) the first step is to find a DHCP server

When the DHCP client logs in to the network for the first time, the computer finds that there is no IP address setting on the machine, and will send DHCP   disco messages to find the DHCP server by broadcasting, that is, sending specific broadcast information to 255.255.255.255. Every host on the network that has the TCP/IP protocol installed will receive this broadcast message, but only the DHCP server will respond.

(2) the second step is to assign IP addresses.

The DHCP server that receives the DHCP   disco on the network responds by selecting one of the unassigned IP address pools to assign to the DHCP client and sending a DHCP offer supply information to the DHCP client containing the assigned IP address and other settings.

(3) step 3: accept the IP address

After receiving the DHCP offer provided information, the DHCP client selects the first received provided information and then broadcasts a DHCP   request request containing the content of requesting the IP address from the DHCP server it selected.

(4) confirmation of IP address assignment in step 4

When the DHCP server receives the DHCP request request information answered by the DHCP client, it sends a DHCP   ack confirmation message to the DHCP client containing the IP address and other settings it provides, telling the DHCP client that it can use the IP address it provides. The DHCP client then binds its TCP/IP protocol to the network card, and in addition, except for the DHCP server selected by the DHCP client, the DHCP server will retrieve the IP address that has been provided.

Log in again:

In the future, every time the DHCP client logs back into the network, it does not need to send a DHCP disco message, but directly sends the DHCP request request information containing the previously assigned IP address. When the DHCP server receives this message, it tries to keep the DHCP client using the original IP address and answers a DHCP   ack confirmation message. If this IP address can no longer be assigned to the original DHCP client, the DHCP server answers a DHCP   nack denial message to the DHCP client. When the original DHCP client receives this DHCP nack denial message, it must resend the DHCP discover message to request a new IP address.

If the IP address in the client DHCP request is not used on the server side, the DHCP server replies DHCP ACK to continue using IP.

If the IP address in the client DHCP request is already used on the server side, the DHCP server replies DHCP NACK to tell the client that IP has been used.

Restart the process of DHCP's first login after replying to NACK

Renew the lease:

The IP address leased by the DHCP server to the DHCP client usually has a lease term, and when the lease period expires, the DHCP server will take back the leased IP address. If the DHCP client wants to extend its IP lease, it must renew its IP lease. When the DHCP client starts and when the duration of the IP lease reaches 50% of the lease, the DHCP client automatically sends information to the DHCP server to update its IP lease.

Second, several common methods of building DHCP server

1. Provide services using DHCP function modules built into broadband routers such as TPLinK

This method is very simple, first of all, log in to the router, find the location of the DHCP function setting, and set it directly.

After setting up and saving the restart, the computers in the network can automatically obtain the iP address and other information.

two。 Office network environment uses layer 3 switch to build DHCP service

Take Huawei switch as an example:

The process of configuring DHCP services on a layer 3 switch:

System-view   (enters global mode) [Huawei] sysname   SW1   (  device naming) [SW1] dhcp   enable   (using DHCP feature) [SW1] ip   pool   10   (create global address pool Enter global address pool view at the same time) [SW1-ip-pool-10] network   192.168.10.0   mask   24 (configure IP address range that can be dynamically assigned by global address pool) [SW1-ip-pool-10] dns-list   8.8.8.8   (configure DNS  ) [SW1-ip-pool-10] gateway-list   192.168.10.1   (configure gateway) [SW1-ip-pool-10] excluded-ip -address   192.168.10.201   192.168.10.254   (keep unassigned addresses) [SW1-ip-pool-10] lease   day   7   (IP lease term) [SW1-ip-pool-10] dis   this   (query configuration of current mode) # ip   pool   10gateway-list   192.168.10.1   (gateway) network   192.168.10.0   mask   255.255.255.0   Address range) excluded-ip-address   192.168.10.201   192.168.10.254   (reserved IP address range) lease   day   7   hour   0   minute   0   (IP lease cycle) dns-list   8.8.8.8 [SW1-ip-pool-10] quit   (exit [SW1] ip   pool   20 [SW1-ip-pool-20] network   192.168.20.0   mask   24 [SW1-ip-pool-20] Dns-list   8.8.8.8 [SW1-ip-pool-20] gateway-list   192.168.20.1 [SW1-ip-pool-20] excluded-ip-address   192.168.20.201   192.168.20.254 [SW1-ip-pool-20] lease   day   7 [SW1-ip-pool-20] qmuri- -[SW1] vlan   batch   10   20   (batch creation vlan) [SW1] interface   GigabitEthernet   0Accord 0   (enter port   1) [SW1-GigabitEthernet0/0/1] port   link-type   access   (configure port   1   type) [SW1-GigabitEthernet0/0/1] port   default   vlan   10   (configure vlan   1   port) [] port   1   port [] port # vlan (exit) [ SW1] interface   GigabitEthernet   0Acer 2 [SW1-GigabitEthernet0/0/2] port   link-type access [SW1-GigabitEthernet0/0/2] port   default   vlan   20 [SW1-GigabitEthernet0/0/2] quit (clients under the   configuration VLANIF10 interface obtain IP addresses from the global address pool) [SW1] interface   Vlanif   10   (create vlanif   10) [SW1-Vlanif10] ip   address   192.168.10.1   24   (configure address address) [ SW1-Vlanif10] dhcp   select   global   (call the global address pool in vlanif   10 mode) [SW1-Vlanif10] display   this   (query current configuration parameters) # interface   Vlanif10ip   address   192.168.10.1   255.255.255.0dhcp   select   global#Return [SW1-Vlanif10] quitSW1 [SW1-Vlanif10] interface   Vlanif   20 [Vlanif] SW1-Vlanif20   SW1-Vlanif20   192.168.20.1   24 [ip] ip   ip   [] People [SW1] display   ip   pool   (view IP address pool configuration) [SW1] quitsave   (save configuration Write device)

3. Building DHCP Services in Windows system

Take 2008server as an example:

2008ser steps to build a DHCP server:

Step 1: install the Windows Server 2008 system as the server side; the client can install other Windows systems.

Step 2: enter the 2008ser system and set the IP manually (static IP is not set, and cannot continue later)

Step 3: open the server manager: click "start menu Program"-> Administrative tools-> Server Manager in the system

Step 4: enter the server manager, click "roles" on the left, and then click "add roles" on the right

Step 5: go to the next step of adding role guides by default

Step 6: server role interface, check DHCP server

Step 7: after checking the DHCP server, click the "next" button, and the DHCP server introduction window will pop up on the screen. The next step is the default.

Step 8: select the network connection binding and check the IP address; the installer will automatically check whether your server has a static IP address, and step 2 will be detected if it is set up.

Step 9: next to "IPv4DNS Settings", you need to enter your parent domain name and the IP address of the DNS server, this domain will be used for all the scopes we created on this DHCP server; when DHCP updates the IP address information, the corresponding DNS update will synchronize the computer name with the association of the IP address.

Step 10: whether to set the WINS server address parameter, the default "applications on this network do not need WINS" option; (if necessary, correctly set the IP address of the target WINS server.)

Step 11: in the next "DHCP scope" window, click "add" on the right. We can set the scope of the DHCP server according to the IP address allocation of the local local area network, select the "activate this scope" option, and click "OK" to finish adding.

Step 12: DHCPv6 stateless mode, select disable mode; support for next-generation IP address specification IPv6 has been added by default in Windows Server 2008, but IPv6 is rarely used in the current network situation, so you can choose to disable DHCPv6 stateless mode for this server.

Step 13: in the "confirm" interface, click install after confirmation to start the automatic installation. The progress bar is complete and the DHCP installation is complete.

Finally, if the client in the local area network is set to obtain the IP address automatically, the IP automatically assigned by DHCP can be obtained.

4. Build DHCP service under Linux system

Take ubuntu system as an example:

The network topology diagram is as follows:

The configuration steps are as follows:

Step 1: install isc-dhcp-server

Adopt the command: apt-get install isc-dhcp-server:

Step 1: configure isc-dhcp-server

First, set up the "ubuntu copy" as the DHCP server:

Step 3: enter the super user and edit the file / etc/default/isc-dhcp-server file:

Enter the name of the network card enp0s3 at INTERFACES= "":

Step 4: open the file and find that there are many examples that have been commented out. Choose an example, and the modified results are as follows:

Modify the local IP address, subnet mask, default gateway, DNS, etc.:

Restart the network card, restart the network, and turn on the DHCP service:

Step 5: Linux client configuration (virtual machine gets IP from virtual machine):

The network connection is set to obtain the IP address automatically:

Enter the dhclient command on the command line to reassign the IP address, and we find that the IP address has been successfully assigned. Figure 1 is the unassigned IP address, and figure 2 is the IP address 192.168.137.101 assigned by the DHCP server 192.168.137.2:

Through the analysis of wireshark grabbing packets, we can see that IP address 192.168.137.101 is indeed provided by DHCP server 192.168.137.2, and we can see the request-ack process between them.

This is the end of the introduction of "the principle and Construction of DHCP Service". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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