CN115460176A - Invalid address recovery method, device, equipment and medium for DHCP server - Google Patents

Invalid address recovery method, device, equipment and medium for DHCP server Download PDF

Info

Publication number
CN115460176A
CN115460176A CN202211201649.0A CN202211201649A CN115460176A CN 115460176 A CN115460176 A CN 115460176A CN 202211201649 A CN202211201649 A CN 202211201649A CN 115460176 A CN115460176 A CN 115460176A
Authority
CN
China
Prior art keywords
address
client
dhcp server
invalid
invalid address
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211201649.0A
Other languages
Chinese (zh)
Other versions
CN115460176B (en
Inventor
李兵
袁福利
陈翔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Suzhou Inspur Intelligent Technology Co Ltd
Original Assignee
Suzhou Inspur Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Suzhou Inspur Intelligent Technology Co Ltd filed Critical Suzhou Inspur Intelligent Technology Co Ltd
Priority to CN202211201649.0A priority Critical patent/CN115460176B/en
Publication of CN115460176A publication Critical patent/CN115460176A/en
Application granted granted Critical
Publication of CN115460176B publication Critical patent/CN115460176B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/09Mapping addresses
    • H04L61/10Mapping addresses of different types
    • H04L61/103Mapping addresses of different types across network layers, e.g. resolution of network layer into physical layer addresses or address resolution protocol [ARP]

Abstract

The application discloses a method, a device, equipment and a medium for recovering invalid addresses of a DHCP server, which relate to the technical field of computers and comprise the following steps: sending an ARP request to all clients which are allocated with IP addresses, and detecting whether a DHCP server receives response information returned by the clients aiming at the ARP request; if detecting that the DHCP server does not receive response information returned by the client aiming at the ARP request, marking the lease state of the client as temp; carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if the lease state of the client is detected to be unchanged; and performing invalid address release on the IP address of the client marked as negative based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server. The problem of slow release of invalid addresses is solved, IP address resources are efficiently recycled, and the utilization rate of address pool resources is improved.

Description

Invalid address recovery method, device, equipment and medium for DHCP server
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device, equipment and a medium for recovering invalid addresses of a DHCP server.
Background
When a DHCP Client (DHCP Client) goes offline in a network environment, because a network failure fails to send a DHCP Release message to a DHCP Server, and at this time, in an address pool of the DHCP Server (DHCP Server), the address of the DHCP Client cannot be allocated to other clients, so an invalid lease exists, the prior art is defined in the DHCP protocol specification, and when the DHCP lease of a Client is located at 50% of the lease time, or at 87.5% of the lease time, a Renew message is reinitiated for renewal, and if the DHCP Server does not receive the DHCP Renew message within 87.5% of the lease time, the allocated address is considered invalid and then recovered. The lease time is appointed in the DHCP Server, after the lease time is appointed, whether the address is an invalid address or not can be calculated according to the lease time, 87.5% of the lease time is required to be spent for deleting, and after the operation and maintenance personnel find that the allocated address is invalid, the invalid address cannot be timely recovered, so that the waste of DHCP address resources is caused.
In summary, under the condition that the existing DHCP address resources are relatively tense, how to efficiently recycle the address pool resources and ensure the utilization rate of the address pool resources becomes a technical problem to be solved in the field.
Disclosure of Invention
In view of the above, an object of the present invention is to provide a method, an apparatus, a device, and a medium for recovering an invalid address of a DHCP server, which can efficiently recover address pool resources and ensure a utilization rate of the address pool resources under a condition that existing DHCP address resources are relatively insufficient. The specific scheme is as follows:
in a first aspect, the present application discloses a DHCP server invalid address recovery method, including:
sending ARP requests to all clients with allocated IP addresses, and detecting whether a DHCP server receives response information returned by the clients aiming at the ARP requests;
if detecting that the DHCP server does not receive response information returned by the client machine aiming at the ARP request, marking the lease state of the client machine as temp;
carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if the lease state of the client is detected to be unchanged;
and releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server.
Optionally, the sending an ARP request to all clients to which an IP address has been allocated includes:
traversing an IP address distribution table stored by a DHCP server, and sending an ARP request to a client of the IP address in the IP address distribution table.
Optionally, after detecting whether the DHCP server receives response information returned by the client for the ARP request, the method further includes:
and if detecting that a DHCP server receives response information returned by the client aiming at the ARP request, marking the lease state of the client as positive, and determining the address of the client as an effective address.
Optionally, after the periodic detection of the client marked as temp, the method further includes:
and if the lease state of the client is detected to be changed into positive, marking the lease state of the client as positive, and determining the address of the client as an effective address.
Optionally, after the periodic detection is performed on the client marked as temp, the method further includes:
and when the period detection is finished, the step of sending the ARP request to all the clients with the allocated IP addresses is carried out by jumping again.
Optionally, the performing invalid address release on the IP address of the client marked as negative based on the preset invalid address release manner includes:
and sending a refusal response message to the client marked as negative based on a manual invalid address release mode, and releasing the invalid address of the IP address of the client.
Optionally, the performing, based on a preset invalid address releasing manner, invalid address release on the IP address of the client marked as negative includes:
and sending a response rejection message to the client marked as negative in the period based on a period detection invalid address release mode, and releasing the invalid address of the IP address of the client.
In a second aspect, the present application discloses a DHCP server invalid address recovery apparatus, including:
the information receiving module is used for sending ARP requests to all clients which are allocated with IP addresses and detecting whether a DHCP server receives response information returned by the clients aiming at the ARP requests;
the first state marking module is used for marking the lease state of the client as temp if detecting that a DHCP server does not receive response information returned by the client for the ARP request;
the second state marking module is used for carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if the lease state of the client is detected to be unchanged;
and the address release module is used for releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode and completing the recovery of the invalid address of the DHCP server.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the DHCP server invalid address reclamation method disclosed in the foregoing.
In a fourth aspect, the present application discloses a computer readable storage medium for storing a computer program; wherein the computer program when executed by a processor implements the steps of the DHCP server invalid address reclamation method disclosed above.
Therefore, the application discloses a method for recovering invalid addresses of a DHCP server, which comprises the following steps: sending ARP requests to all clients with allocated IP addresses, and detecting whether a DHCP server receives response information returned by the clients aiming at the ARP requests; if detecting that the DHCP server does not receive response information returned by the client machine aiming at the ARP request, marking the lease state of the client machine as temp; carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if the lease state of the client is detected to be unchanged; and releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server. It can be seen that an ARP request is sent to a client that has been assigned an IP address, a lease status of the corresponding client is determined by detecting whether a response message of the ARP request is received, in order to avoid misjudgment, periodic detection is performed on all clients marked as temp, and then the lease status of the client is determined again, and then an invalid address release operation is performed on the IP addresses of all clients whose lease status is negative, so that it is not necessary to wait for a lease time that takes 87.5% of a lease to be performed for an invalid address release operation, thereby solving the problem of slow release of the invalid address, efficiently recovering IP address resources, and improving the utilization rate of address pool resources.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart illustrating a method for recovering an invalid address of a DHCP server according to the present disclosure;
fig. 2 is a flowchart illustrating a specific method for recovering an invalid address of a DHCP server according to the present disclosure;
fig. 3 is a flowchart illustrating another specific DHCP server invalid address recovery method disclosed in the present application;
fig. 4 is a schematic structural diagram of an invalid address recovery apparatus for a DHCP server disclosed in the present application;
fig. 5 is a block diagram of an electronic device disclosed in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
When a DHCP Client goes offline in a network environment, because a network failure fails to send a DHCP Release message to a DHCP Server, and at this time, the address of the DHCP Client cannot be allocated to other clients in an address pool of the DHCP Server, so an invalid lease exists, where the prior art is defined in the DHCP protocol specification, and when the DHCP lease of a Client is located in 50% of the lease time or is located in 87.5% of the lease time, the DHCP Server re-initiates a Renew message for renewal, and if the DHCP Server does not receive the DHCP Renew message in 87.5% of the lease time, the allocated address is considered invalid and then recovered. The lease time is appointed in the DHCP Server, after the lease time is appointed, whether the address is an invalid address or not can be calculated according to the lease time, 87.5% of the lease time is required to be spent for deleting, and after the operation and maintenance personnel find that the allocated address is invalid, the invalid address cannot be timely recovered, so that the waste of DHCP address resources is caused.
Therefore, the method and the device for recovering the invalid address of the DHCP server provide a recovery scheme of the invalid address of the DHCP server, and can efficiently recover the address pool resource and ensure the utilization rate of the address pool resource under the condition that the existing DHCP address resource is tense.
Referring to fig. 1, an embodiment of the present invention discloses a method for recovering an invalid address of a DHCP server, including:
step S11: and sending an ARP request to all clients which are allocated with IP addresses, and detecting whether a DHCP server receives response information returned by the clients for the ARP request.
In this embodiment, an IP address allocation table stored in a DHCP server is traversed, and an ARP request is sent to a client of an IP address in the IP address allocation table. It can be understood that, while the DHCP server allocates the IP address, the DHCP server records the allocated IP address and forms an IP address allocation table, that is, a record of the IP address allocated to the client taken from the IP address pool, and it should be noted that all the unallocated IP addresses or the IP addresses that have been successfully recovered and reach the lease are recorded in the IP address pool. Because the DHCP server can allocate IP addresses to clients existing in the local area network or the public network, the specific allocation modes are three, and the allocation modes are automatic allocation, manual allocation and dynamic allocation, wherein the dynamic allocation mode is adopted in the embodiment, when the DHCP server allocates addresses in the dynamic allocation mode, time limit is generated on the corresponding allocated IP addresses, and after the service life of the IP addresses expires, the clients need to re-apply for renewing the lease of the IP addresses, or can actively release the IP addresses. Through traversing the IP Address in the IP Address allocation table, an ARP (Address Resolution Protocol) request is sent to the client corresponding to the IP Address in the IP Address allocation table, that is, the MAC Address of the client is inquired through the IP Address of the client, so as to ensure smooth communication and ensure smooth communication between the client and the DHCP server.
In this embodiment, it is understood that, after the DHCP server sends an ARP request to a client corresponding to an IP address in an IP address allocation table, it is detected whether the DHCP server receives response information for the ARP request sent by the client, and the detection results are two types, and if it is detected that the DHCP server receives the response information returned by the client for the ARP request, the lease status of the client is marked as positive, and positive indicates an effective lease, so that the address of the client is determined as an effective address based on the effective lease information. It can be understood that, when the response information about the ARP request is received, it indicates that the ARP request sent by the DHCP server at this time can successfully determine the corresponding client by using the IP address recorded in the IP address allocation table, that is, the client at this time uses the IP address normally, and there is no invalid IP address.
In this embodiment, if there is no DHCP server in the local network, that is, the response information returned to the ARP request cannot be received currently, at this time, a DHCP Relay agent is set, and the DHCP Relay agent can be used to eliminate the need for a DHCP server in each physical network segment, and can transmit a message to a DHCP server not in the same physical subnet, or transmit a message of the server back to a DHCP client not in the same physical subnet. The procedure for editing the DHCP Relay is as follows: when the DHCP Client starts and carries out DHCP initialization, the DHCP Client broadcasts a configuration request message in a local network. If the local network has a DHCP server, the DHCP configuration can be directly carried out without the need of DHCP Relay. If the local network does not have the DHCP server, the network equipment with the DHCP Relay function connected with the local network receives the broadcast message, and then the broadcast message is processed appropriately and forwarded to the DHCP server on the appointed other network. And the DHCP server performs corresponding configuration according to the information provided by the DHCP Client and sends the configuration information to the DHCP Client through the DHCP Relay to complete the dynamic configuration of the DHCP Client. In the process of message transmission between the DHCP server and the client, the DHCP Relay modifies the corresponding field in the DHCP message through the DHCP Relay device, changes the broadcast packet of the DHCP into a unicast packet and is responsible for conversion between the DHCP server and the client, wherein the DHCP Relay device can specifically use a netcore router.
Step S12: and if detecting that the DHCP server does not receive the response information returned by the client machine for the ARP request, marking the lease state of the client machine as temp.
In this embodiment, if it is detected that the DHCP server does not receive the response information returned by the client for the ARP request, it indicates that the ARP request sent by the DHCP server cannot successfully determine the corresponding client through the IP address recorded in the IP address allocation table at this time, that is, the client uses the IP address abnormally at this time, an invalid IP address may exist, and the lease status of the client needs to be marked as temp.
Step S13: and carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if detecting that the lease state of the client is not changed.
In this embodiment, a client marked as temp is subjected to period detection, where temp, that is, a temporary lease, indicates that lease state information of the current client is ambiguous, and an allocated IP address may be an effective address or an invalid address, so that after traversing the entire IP address allocation table and sending an ARP request, first-pass lease state information detection and marking are performed, and meanwhile, a client marked as temp is subjected to period detection to detect an IP address lease state of its client, and if the IP address of the client is found to be temp all the time in the period detection process, the IP address of the client is marked as negative, which indicates an invalid lease, and accordingly, the IP address of the client is an invalid address.
In this embodiment, if it is detected that the lease status of the client is changed to positive, the lease status of the client is marked as positive, and the address of the client is determined as an effective address. It can be understood that, in the process of periodic detection, if the IP address of the client is found to be positive, the IP address of the client is marked as negative, and accordingly, the IP address of the client is a valid address.
In this embodiment, after the cycle detection is finished, the step of sending the ARP request to all clients assigned with IP addresses is performed by skipping again. It can be understood that after the lease of the allocated IP address recorded in the IP address allocation table in the current DHCP server is periodically checked, marked and released, the IP address recorded in the IP address allocation table in the DHCP server at this time may have been updated, and there is an IP address that is not checked, so that the method jumps to the step of sending ARP request to all clients to which IP addresses are allocated again, and performs the next periodic checking, marking and releasing operation.
Step S14: and releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server.
In this embodiment, the IP address of the client marked as negative is subjected to the invalid address release based on the invalid address release manner, that is, the client marked as negative does not perform a renewal operation with the corresponding IP address, which indicates that the IP address of the current client is expired, the client is subjected to the invalid address release operation, and the IP address is recovered to the IP address pool, so that the resource recovery work of the invalid IP address is completed.
Therefore, the application discloses a method for recovering invalid addresses of a DHCP server, which comprises the following steps: sending an ARP request to all clients with allocated IP addresses, and detecting whether a DHCP server receives response information returned by the clients for the ARP request; if detecting that a DHCP server does not receive response information returned by the client machine for the ARP request, marking the lease state of the client machine as temp; carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if detecting that the lease state of the client is unchanged; and releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server. It can be seen that an ARP request is sent to a client that has been assigned an IP address, a lease status of the corresponding client is determined by detecting whether a response message of the ARP request is received, in order to avoid misjudgment, periodic detection is performed on all clients marked as temp, and then the lease status of the client is determined again, and then an invalid address release operation is performed on the IP addresses of all clients whose lease status is negative, so that it is not necessary to wait for a lease time that takes 87.5% of a lease to be performed for an invalid address release operation, thereby solving the problem of slow release of the invalid address, efficiently recovering IP address resources, and improving the utilization rate of address pool resources.
Referring to fig. 2, an embodiment of the present invention discloses a specific method for recovering an invalid address of a DHCP server, and this embodiment further describes and optimizes the technical solution with respect to the previous embodiment. Specifically, the method comprises the following steps:
step S21: and sending an ARP request to all clients which are allocated with IP addresses, and detecting whether a DHCP server receives response information returned by the clients for the ARP request.
Step S22: and if detecting that the DHCP server does not receive the response information returned by the client machine for the ARP request, marking the lease state of the client machine as temp.
Step S23: and carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if detecting that the lease state of the client is not changed.
For a more detailed processing procedure in steps S21, S22, and S23, please refer to the content of the foregoing disclosed embodiments, which is not described herein again.
Step S24: and sending a rejection response message to the client marked as negative based on a manual invalid address release mode, and releasing the invalid address of the IP address of the client.
In this embodiment, when the DHCP Server release mode is set as the manual invalid address release mode, the operation of releasing the invalid lease is executed, and after the manual invalid address release is executed, the DHCP Server traverses the Client whose state is the lease state negative, and sends a DHCP Nak message to the Client, and actively releases the invalid address, thereby completing the resource recovery operation of the invalid address.
Therefore, when a manual invalid address release mode is set, the response message of sending rejection of the Client with the lease status of negative can be controlled to release the current IP address by the corresponding Client, the detection of the lease of the IP address is started without waiting for the preset fixed lease detection time, the idle waiting time of the invalid IP address is reduced, and the resource utilization of the invalid IP address is improved.
Referring to fig. 3, an embodiment of the present invention discloses a specific method for recovering an invalid address of a DHCP server, and this embodiment further describes and optimizes the technical solution in comparison with the previous embodiment. Specifically, the method comprises the following steps:
step S31: and sending an ARP request to all clients which are allocated with IP addresses, and detecting whether a DHCP server receives response information returned by the clients for the ARP request.
Step S32: and if detecting that the DHCP server does not receive the response information returned by the client machine for the ARP request, marking the lease state of the client machine as temp.
Step S33: and periodically detecting the client marked as temp, and marking the lease state of the client as negative if detecting that the lease state of the client is not changed.
For a more detailed processing procedure in steps S31, S32, and S33, please refer to the content of the foregoing disclosed embodiments, which is not described herein again.
Step S34: and sending a response rejection message to the client marked as negative in the period based on a period detection invalid address release mode, and releasing the invalid address of the IP address of the client.
In this embodiment, when the DHCP Server release mode is set as the automatic invalid address release mode, the lease state is periodically detected, and a lease detection result with a positive or negative detection result is obtained, when the lease detection result detected in the period is positive, no processing is performed, when the lease detection result detected in the period is negative, an operation of sending a DHCP Nak message to a corresponding Client is performed, and an invalid address is actively released, so that a resource recovery operation of the invalid address is completed.
In the process of releasing the periodic detection invalid address, the state of the lease is periodically detected, and the time period can be set according to actual requirements, for example: the method comprises the steps of carrying out detection operation on the lease state of the IP address of the client once every 5 minutes, carrying out lease release operation on an invalid address every time the lease state is detected to be negative in the process of periodically detecting the state of the lease, and then continuously checking the lease states of other IP addresses after ending the lease release with the lease state of negative.
Therefore, the release of the periodic detection invalid address refers to the state monitoring by utilizing a periodic detection lease state mode, so that the automatic periodic release of the invalid address is realized, the problem that the invalid address cannot be timely recovered due to the fact that lease state detection is carried out only when a fixed lease time point is reached is solved, and the recovery rate of the invalid IP address is improved.
Referring to fig. 4, an embodiment of the present invention discloses a specific DHCP server invalid address recovery apparatus, including:
the information receiving module 11 is configured to send an ARP request to all clients that have been assigned IP addresses, and detect whether a DHCP server receives response information returned by the client for the ARP request;
a first status marking module 12, configured to mark the lease status of the client as temp if it is detected that the DHCP server does not receive response information returned by the client for the ARP request;
a second status marking module 13, configured to perform periodic detection on the client marked as temp, and mark the lease status of the client as negative if it is detected that the lease status of the client is not changed;
and the address release module 14 is configured to release the invalid address of the IP address of the client marked as negative based on a preset invalid address release manner, so as to complete the recovery of the invalid address of the DHCP server.
The information receiving module 11 is specifically configured to traverse an IP address allocation table stored by a DHCP server, and send an ARP request to a client of an IP address in the IP address allocation table. It can be understood that, while the DHCP server allocates the IP address, the DHCP server records the allocated IP address and forms an IP address allocation table, that is, a record of the IP address allocated to the client taken from the IP address pool, and it should be noted that all the IP addresses that are not allocated or that have been successfully recovered and reach the lease are recorded in the IP address pool. Because the DHCP server can perform IP address allocation to the client existing in the local area network or the public network, the specific allocation modes are three, and automatic allocation, manual allocation, and dynamic allocation are performed, wherein the dynamic allocation mode is adopted in this embodiment, when the DHCP server performs address allocation through the dynamic allocation mode of the IP address, a time limit is generated on the corresponding allocated IP address, and after the lifetime of the IP address expires, the client needs to re-apply for renewing the lease of the IP address, or may actively release the IP address. The IP address in the IP address distribution table is traversed, the ARP request is sent to the client corresponding to the IP address in the IP address distribution table, namely, the MAC address of the client is inquired through the IP address of the client, so that the smooth proceeding of communication is ensured, and the smooth communication between the client and the DHCP server is ensured. It can be understood that after the DHCP server sends an ARP request to a client corresponding to an IP address in an IP address allocation table, it is detected whether the DHCP server receives response information for the ARP request sent by the client, and the detection results are two types, and if it is detected that the DHCP server receives the response information returned by the client for the ARP request, the lease status of the client is marked as positive, which indicates a valid lease, so the address of the client is determined to be a valid address based on the valid lease information. It can be understood that, when the response information about the ARP request is received, it indicates that the ARP request sent by the DHCP server at this time can successfully determine the corresponding client by using the IP address recorded in the IP address allocation table, that is, the client at this time uses the IP address normally, and there is no invalid IP address. If the DHCP server does not exist in the local network, that is, the response information returned to the ARP request cannot be received currently, at this time, a DHCP Relay is set, and the DHCP Relay agent can remove the need of having a DHCP server in each physical network segment, can transmit a message to a DHCP server not in the same physical subnet, and can also transmit a message of the server back to a DHCP client not in the same physical subnet. The procedure for editing the DHCP Relay is as follows: when the DHCP Client starts and performs DHCP initialization, it broadcasts a configuration request message in the local network. If the local network has a DHCP server, DHCP configuration can be directly carried out without DHCP Relay. If the local network does not have the DHCP server, the network equipment with the DHCP Relay function connected with the local network receives the broadcast message, and then the broadcast message is processed appropriately and forwarded to the DHCP server on the appointed other network. And the DHCP server performs corresponding configuration according to the information provided by the DHCP Client and sends the configuration information to the DHCP Client through the DHCP Relay to complete the dynamic configuration of the DHCP Client. In the process of message transmission between the DHCP server and the client, the DHCP Relay modifies the corresponding field in the DHCP message through the DHCP Relay equipment, changes the broadcast packet of the DHCP into a unicast packet and is responsible for conversion between the DHCP server and the client, wherein the DHCP Relay equipment can specifically use a netcore router.
The second status marking module 13 is specifically configured to perform periodic detection on a client marked as temp, where temp, that is, a temporary lease, indicates that lease status information of a current client is ambiguous, and an allocated IP address may be an effective address or an invalid address, so that after traversing the entire IP address allocation table and sending an ARP request, first-pass lease status information detection and marking are performed, and meanwhile, a client marked as temp performs periodic detection to detect an IP address lease status of its client, and if an IP address of the client is found to be temp all the time in the periodic detection process, the IP address of the client is marked as negative, negative indicates an invalid lease, and accordingly, the IP address of the client is an invalid address. And if the lease state of the client is detected to be changed into positive, marking the lease state of the client as positive, and determining the address of the client as an effective address. It can be understood that, if the IP address of the client is found to become positive in the process of periodic detection, the IP address of the client is marked as negative, and accordingly, the IP address of the client is a valid address. And when the period detection is finished, re-skipping to execute the step of sending the ARP request to all the clients with the allocated IP addresses. It can be understood that after the lease of the allocated IP address recorded in the IP address allocation table in the current DHCP server is periodically checked, marked and released, the IP address recorded in the IP address allocation table in the DHCP server at this time may have been updated, and there is an IP address that is not checked, so that the method jumps to the step of sending ARP request to all clients to which IP addresses are allocated again, and performs the next periodic checking, marking and releasing operation.
Therefore, the application discloses a method for recovering invalid addresses of a DHCP server, which comprises the following steps: sending ARP requests to all clients with allocated IP addresses, and detecting whether a DHCP server receives response information returned by the clients aiming at the ARP requests; if detecting that a DHCP server does not receive response information returned by the client machine for the ARP request, marking the lease state of the client machine as temp; carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if detecting that the lease state of the client is unchanged; and releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server. It can be seen that an ARP request is sent to a client that has been assigned an IP address, a lease status of the corresponding client is determined by detecting whether a response message of the ARP request is received, in order to avoid misjudgment, periodic detection is performed on all clients marked as temp, and then the lease status of the client is determined again, and then an invalid address release operation is performed on the IP addresses of all clients whose lease status is negative, so that it is not necessary to wait for a lease time that takes 87.5% of a lease to be performed for an invalid address release operation, thereby solving the problem of slow release of the invalid address, efficiently recovering IP address resources, and improving the utilization rate of address pool resources.
In some specific embodiments, the information receiving module 11 may specifically include:
and the request sending unit is used for traversing the IP address distribution table stored by the DHCP server and sending an ARP request to the client of the IP address in the IP address distribution table.
In some specific embodiments, the DHCP server invalid address recycling apparatus may specifically include:
and the first address determination unit is used for marking the lease status of the client as positive and determining the address of the client as an effective address if detecting that a DHCP server receives response information returned by the client for the ARP request.
In some specific embodiments, the DHCP server invalid address recycling apparatus may specifically include:
and the second address determining unit is used for marking the lease status of the client as positive and determining the address of the client as an effective address if the lease status of the client is detected to be changed into positive.
In some specific embodiments, the DHCP server invalid address recycling apparatus may specifically include:
and the program jumping unit is used for jumping again to execute the step of sending the ARP request to all the clients with the allocated IP addresses after the period detection is finished.
In some specific embodiments, the address releasing module 14 may specifically include:
and the release mode selection unit is used for sending a rejection response message to the client marked as negative based on a manual invalid address release mode and releasing the invalid address of the IP address of the client.
In some specific embodiments, the address releasing module 14 may specifically include:
and the address release unit is used for sending a response rejection message to the client marked as negative in the period based on the period detection invalid address release mode and releasing the invalid address of the IP address of the client.
Further, an electronic device is disclosed in the embodiments of the present application, and fig. 5 is a block diagram of the electronic device 20 according to an exemplary embodiment, which should not be construed as limiting the scope of the application.
Fig. 5 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present disclosure. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. The memory 22 is configured to store a computer program, and the computer program is loaded and executed by the processor 21 to implement relevant steps in the DHCP server invalid address reclamation method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide a working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and a communication protocol followed by the communication interface is any communication protocol applicable to the technical solution of the present application, and is not specifically limited herein; the input/output interface 25 is configured to acquire external input data or output data to the outside, and a specific interface type thereof may be selected according to specific application requirements, which is not specifically limited herein.
The processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor 21 may be implemented in at least one hardware form of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor, where the main processor is a processor for Processing data in an awake state, and is also called a Central Processing Unit (CPU); a coprocessor is a low power processor for processing data in a standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content required to be displayed on the display screen. In some embodiments, the processor 21 may further include an AI (Artificial Intelligence) processor for processing a calculation operation related to machine learning.
In addition, the storage 22 is used as a carrier for resource storage, and may be a read-only memory, a random access memory, a magnetic disk or an optical disk, etc., and the resources stored thereon may include an operating system 221, a computer program 222, etc., and the storage manner may be a transient storage or a permanent storage.
The operating system 221 is used for managing and controlling each hardware device and the computer program 222 on the electronic device 20, so as to realize the operation and processing of the mass data 223 in the memory 22 by the processor 21, and may be Windows Server, netware, unix, linux, and the like. The computer program 222 may further include a computer program that can be used to perform other specific tasks in addition to the computer program that can be used to perform the DHCP server invalid address reclamation method performed by the electronic device 20 disclosed in any of the foregoing embodiments. The data 223 may include data received by the electronic device and transmitted from an external device, or may include data collected by the input/output interface 25 itself.
Further, the present application also discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the DHCP server invalid address reclamation method disclosed above. For the specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, which are not described herein again.
In the present specification, the embodiments are described in a progressive manner, and each embodiment focuses on differences from other embodiments, and the same or similar parts between the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative components and steps have been described above generally in terms of their functionality in order to clearly illustrate this interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the technical solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application. The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
The method, apparatus, device and medium for recovering the invalid address of the DHCP server provided by the present invention are described in detail above, and a specific example is applied in the present disclosure to explain the principle and the implementation of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A DHCP server invalid address recovery method is characterized by comprising the following steps:
sending an ARP request to all clients with allocated IP addresses, and detecting whether a DHCP server receives response information returned by the clients for the ARP request;
if detecting that a DHCP server does not receive response information returned by the client machine for the ARP request, marking the lease state of the client machine as temp;
carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if the lease state of the client is detected to be unchanged;
and releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode, and completing the recovery of the invalid address of the DHCP server.
2. The method for recovering invalid address of DHCP server according to claim 1, wherein the sending ARP request to all clients having assigned IP address comprises:
traversing an IP address distribution table stored by a DHCP server, and sending an ARP request to a client of the IP address in the IP address distribution table.
3. The method for recovering invalid address of DHCP server according to claim 1, wherein after detecting whether DHCP server receives the response information returned by the client for the ARP request, the method further comprises:
and if detecting that a DHCP server receives response information returned by the client aiming at the ARP request, marking the lease state of the client as positive, and determining the address of the client as an effective address.
4. The method for recovering invalid address of DHCP server according to claim 1, wherein after the periodically detecting the client marked as temp, further comprising:
and if the lease state of the client is detected to be changed into positive, marking the lease state of the client as positive, and determining the address of the client as an effective address.
5. The method for recovering invalid address of DHCP server according to any of claims 1 to 4, wherein after the periodic detection of the client marked as temp, the method further comprises:
and when the period detection is finished, re-skipping to execute the step of sending the ARP request to all the clients with the allocated IP addresses.
6. The method for recovering the invalid address of the DHCP server according to claim 1, wherein the performing the invalid address release on the IP address of the client marked as negative based on a preset invalid address release manner includes:
and sending a rejection response message to the client marked as negative based on a manual invalid address release mode, and releasing the invalid address of the IP address of the client.
7. The DHCP server invalid address reclaiming method according to claim 1, wherein the performing invalid address release for the IP address of the client marked as negative based on a preset invalid address release manner includes:
and sending a response rejection message to the client marked as negative in the period based on a period detection invalid address release mode, and releasing the invalid address of the IP address of the client.
8. An invalid address recycling device for a DHCP server, comprising:
the information receiving module is used for sending ARP requests to all clients which are allocated with IP addresses and detecting whether a DHCP server receives response information returned by the clients aiming at the ARP requests;
the first state marking module is used for marking the lease state of the client as temp if detecting that the DHCP server does not receive the response information returned by the client aiming at the ARP request;
the second state marking module is used for carrying out periodic detection on the client marked as temp, and marking the lease state of the client as negative if the lease state of the client is detected to be unchanged;
and the address release module is used for releasing the invalid address of the IP address marked as negative of the client based on a preset invalid address release mode and completing the recovery of the invalid address of the DHCP server.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the steps of the DHCP server invalid address reclamation method as recited in any one of claims 1 to 7.
10. A computer-readable storage medium for storing a computer program; wherein the computer program realizes the steps of the DHCP server invalid address reclamation method as recited in any one of claims 1 to 7 when executed by a processor.
CN202211201649.0A 2022-09-29 2022-09-29 Method, device, equipment and medium for recovering invalid address of DHCP server Active CN115460176B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211201649.0A CN115460176B (en) 2022-09-29 2022-09-29 Method, device, equipment and medium for recovering invalid address of DHCP server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211201649.0A CN115460176B (en) 2022-09-29 2022-09-29 Method, device, equipment and medium for recovering invalid address of DHCP server

Publications (2)

Publication Number Publication Date
CN115460176A true CN115460176A (en) 2022-12-09
CN115460176B CN115460176B (en) 2023-10-03

Family

ID=84308314

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211201649.0A Active CN115460176B (en) 2022-09-29 2022-09-29 Method, device, equipment and medium for recovering invalid address of DHCP server

Country Status (1)

Country Link
CN (1) CN115460176B (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020198881A1 (en) * 2001-06-26 2002-12-26 International Business Machines Corporation Method and system for recovering DHCP data
KR20030093428A (en) * 2002-06-03 2003-12-11 주식회사 케이티 Apparatus for assignment of DHCP dynamic IP address and Method therefor
US20060218252A1 (en) * 2005-03-22 2006-09-28 Cisco Technology, Inc., A Corporation Of California Remote survivable DHCP for a DHCP relay agent
CN101237460A (en) * 2008-03-05 2008-08-06 杭州华三通信技术有限公司 Processing method, system and device upon lease status change of DHCP Server
CN101572712A (en) * 2009-06-09 2009-11-04 杭州华三通信技术有限公司 Method for preventing attack of counterfeit message and repeater equipment thereof
CN101997920A (en) * 2010-11-18 2011-03-30 中兴通讯股份有限公司 DHCP lease processing method and device
CN102299932A (en) * 2011-09-22 2011-12-28 杭州华三通信技术有限公司 Backup method for DHCP (Dynamic Host Configuration Protocol) server and DHCP server

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020198881A1 (en) * 2001-06-26 2002-12-26 International Business Machines Corporation Method and system for recovering DHCP data
KR20030093428A (en) * 2002-06-03 2003-12-11 주식회사 케이티 Apparatus for assignment of DHCP dynamic IP address and Method therefor
US20060218252A1 (en) * 2005-03-22 2006-09-28 Cisco Technology, Inc., A Corporation Of California Remote survivable DHCP for a DHCP relay agent
CN101237460A (en) * 2008-03-05 2008-08-06 杭州华三通信技术有限公司 Processing method, system and device upon lease status change of DHCP Server
CN101572712A (en) * 2009-06-09 2009-11-04 杭州华三通信技术有限公司 Method for preventing attack of counterfeit message and repeater equipment thereof
CN101997920A (en) * 2010-11-18 2011-03-30 中兴通讯股份有限公司 DHCP lease processing method and device
CN102299932A (en) * 2011-09-22 2011-12-28 杭州华三通信技术有限公司 Backup method for DHCP (Dynamic Host Configuration Protocol) server and DHCP server

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李荣玮;李海彬;邓智;陈冠霖;: "基于报文窥探的DHCP欺骗过滤机制", 视听, no. 12 *

Also Published As

Publication number Publication date
CN115460176B (en) 2023-10-03

Similar Documents

Publication Publication Date Title
US9736005B2 (en) Duplicate IP address detection by a DHCP relay agent
US20170195282A1 (en) Address Processing Method, Related Device, and System
US20210119965A1 (en) Address Management Method and Apparatus
CN108337333B (en) IP address management method, management device, network video recorder and storage medium
CN103856569A (en) Method and device for synchronizing domain name system resource information
CN101951417A (en) Method, system and trunk equipment for assigning multiple server addresses
CN108429824B (en) Address allocation method and device
CN112261175B (en) Asset information updating method, device, equipment and medium
JP6896722B2 (en) Resource configuration method and equipment
CN112492063A (en) IP address pool allocation and application method, device, equipment and medium
CN107517150B (en) Intranet resource access method and device based on virtual private network VPN
CN102299932A (en) Backup method for DHCP (Dynamic Host Configuration Protocol) server and DHCP server
CN115460176A (en) Invalid address recovery method, device, equipment and medium for DHCP server
CN106899456B (en) Method for realizing link detection and repair
KR100606005B1 (en) Method of IP Address Management For IPC
CN104519145A (en) An address resource managing method, system and DHCP server
US20050080927A1 (en) Method and apparatus for managing IP addresses and name mappings for wireless clients
CN113420029A (en) Global ID generation method, device, equipment and medium for distributed system
CN102523316B (en) A kind of address distribution method and equipment
CN111600971A (en) Equipment management method and equipment management device
CN110661902B (en) Method for monitoring client renewal
CN115499414A (en) Address allocation method and device
CN104410727A (en) Address distributing method, client terminal, server and address distributing system
CN114356925A (en) Identification generation method and device, electronic equipment and storage medium
CN110933199B (en) Address allocation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant