IP address allocation conflict detection method based on multi-protocol ARP data acquisition
By using multiple protocols to obtain ARP table information in DHCP services, forming and updating MAC-IP mapping tables, the risk of IP address conflicts in multi-DHCP server environments is solved, and higher network stability and reliability are achieved.
Patent Information
- Application Number
- CN202411801195.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-03-18
AI Technical Summary
In the case of multi-DHCP server environment or primary and secondary DHCP handover, there is a problem of relying on the device to actively respond or synchronization delay, resulting in an increase in the risk of IP address conflicts.
When the DHCP service is started, ARP table information is obtained from network devices using SNMP, SSH or RESTfulAPI protocols, forming a MAC-IP mapping table, and regularly updates to detect and prevent IP address conflicts in real time.
It effectively avoids IP address conflicts caused by device changes or lease synchronization delay, improves network stability and reliability, and ensures the accuracy and real-timeness of IP address allocation.
Smart Images

Figure CN119652868A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an IP address allocation conflict detection method based on multi-protocol ARP data collection. Background Art
[0002] With the rapid development of information technology and the widespread popularity of network applications, the allocation and management of IP addresses in modern networks has become a key issue to ensure network stability and efficient operation. In many network environments, especially in large enterprise and data center networks, Dynamic Host Configuration Protocol (DHCP) is widely used to automatically allocate IP addresses. DHCP services reduce manual configuration errors and improve network management efficiency by automatically allocating IP addresses.
[0003] However, in an environment where multiple DHCP servers coexist, or in some networks where IP addresses need to be manually assigned, the risk of IP address conflicts increases significantly due to the lack of effective coordination between different allocation sources. Such conflicts may cause devices to fail to connect to the Internet normally, communication interruptions, and even lead to serious security issues. In addition, in a high-availability network environment, the problem of delayed or missing lease information synchronization during the switchover between the primary and backup DHCP servers further increases the possibility of IP address conflicts.
[0004] The current solutions mainly include the following methods:
[0005] Lease synchronization between active and standby nodes: The lease synchronization mechanism between the active and standby DHCP servers ensures the consistency of lease information. However, when a network failure or device recovery occurs, lease synchronization may be delayed, resulting in information asynchrony, which increases the risk of IP conflicts.
[0006] Ping-based conflict detection: The traditional IP conflict detection method uses the Ping command to detect whether the target IP address is accessible, thereby determining whether a conflict has occurred. The disadvantage of this method is that some terminal devices may disable the Ping response, or the device in the network is unreachable due to routing problems, resulting in Ping detection failure, missed reports or false reports.
[0007] ARP-based conflict detection: In some networks, ARP (Address Resolution Protocol) is used to detect whether a device conflicts with a certain IP address. This method relies on the ARP request and response of the device in the network. However, the traditional ARP conflict detection mechanism is usually passive, and only detects and handles IP conflicts after they occur, lacking proactive prevention of conflicts.
[0008] Although existing technologies can detect and avoid IP address conflicts to a certain extent, existing methods rely on active responses from devices or have synchronization delays and other issues, and cannot completely eliminate the risk of IP conflicts. In a multi-DHCP server environment or when the primary and backup DHCP servers are switched, the occurrence of IP address conflicts may affect the normal operation of the network and the stability of services. Summary of the invention
[0009] The present application provides an IP address allocation conflict detection method, apparatus, computer equipment and storage medium based on multi-protocol ARP data collection, aiming to solve the problems that the existing methods rely on active response of the device or have synchronization delays.
[0010] A method for detecting IP address allocation conflicts based on multi-protocol ARP data collection, the method comprising:
[0011] When the DHCP service is started, the ARP table information is obtained from the network device through the SNMP protocol, the SSH protocol or the RESTful API protocol, and the network device is a switch or a router;
[0012] The ARP table information is aggregated to form a MAC-IP mapping table, and the corresponding relationship between the MAC address of each device and its assigned IP address is recorded;
[0013] Upon receiving an IP allocation request, checking whether the MAC address of the requesting terminal device exists in the MAC-IP mapping table;
[0014] If the MAC address of the requesting terminal device exists in the MAC-IP mapping table, the IP address is directly allocated to the terminal;
[0015] If the MAC address of the requesting terminal device is not in the MAC-IP mapping table, a new IP address is allocated to the terminal from the available IP pool;
[0016] Before allocating an IP address, by comparing the information in the MAC-IP mapping table, determine whether there is a risk of IP address conflict in the current network environment;
[0017] The ARP table information of the network device is obtained periodically through multiple protocols to update the MAC-IP mapping table.
[0018] In the above scheme, optionally, the step of obtaining the ARP table information by the SNMP protocol is specifically: using SNMP credentials to communicate with the network device, pulling the ARP table information, and obtaining the ARP table from the switch or router through a get request of the SNMP protocol.
[0019] In the above scheme, optionally, the step of obtaining ARP table information through the SSH protocol is specifically: using SSH credentials to establish an encrypted connection with the network device, and executing a command through the SSH protocol to obtain ARP table data, wherein the command is a configurable custom command that can return the ARP table content of the network device.
[0020] In the above scheme, optionally, the step of obtaining the ARP table information by the RESTful API protocol is specifically as follows: through the RESTful API calling interface, the ARP table information of the network device is returned as response data, and the API interface includes the IP address, port, authentication information and URL path of querying the ARP table of at least one device.
[0021] In the above solution, optionally, each mapping information recorded in the MAC-IP mapping table includes a MAC address, a corresponding IP address, an allocation timestamp of the IP address, and a usage status of the IP address.
[0022] In the above solution, optionally, the IP address conflict risk judgment step includes:
[0023] Compare the MAC address of the requesting terminal device with the existing MAC-IP mapping table;
[0024] If the MAC address already exists in the mapping table and the corresponding IP address is the same as the requested IP address, the request is considered non-conflicting;
[0025] If the MAC address exists in the mapping table and the corresponding IP address is different from the requested IP address, an IP address conflict alarm is issued.
[0026] In the above scheme, optionally, the periodically updating the MAC-IP mapping table includes:
[0027] Send ARP table acquisition requests to network devices via SNMP, SSH, or RESTful API protocols at predetermined time intervals;
[0028] The acquired ARP table information is merged with the existing MAC-IP mapping table, the correspondence between the MAC address and the IP address in the mapping table is updated, and invalid or expired IP addresses are cleared.
[0029] In the above scheme, optionally, the network device is at least one switch or router, and the switch or router provides mapping information between MAC addresses and IP addresses in its network through an ARP table, and the ARP table information includes physical interface information of the device.
[0030] In the above solution, optionally, the IP address conflict risk judgment further includes:
[0031] Check the matching of the assigned IP address and the current MAC address in the network, and confirm whether the assigned IP address is correct according to the ARP table information. If the MAC address is inconsistent with the IP address, the system will automatically issue a warning and record the conflict event.
[0032] In the above scheme, optionally, the IP address allocation conflict detection is used in a network environment where multiple DHCP servers coexist, and the MAC-IP mapping table is updated when the primary and backup DHCP servers switch to avoid IP address conflicts caused by unsynchronized lease information, and different IP address allocation strategies are supported, including a hybrid mode of static allocation and dynamic allocation.
[0033] Compared with the prior art, this application has at least the following beneficial effects:
[0034] Based on further analysis and research of the prior art problems, the present application recognizes that the existing methods rely on active responses of the device or have problems such as synchronization delay. When the DHCP service is started, the present solution obtains ARP table information from the core devices (such as switches and routers) in the network through multiple protocols (such as SNMP, SSH, RESTfulAPI). The ARP table records the correspondence between the MAC address of the network device and its assigned IP address. After obtaining this information, it is summarized and formed into a MAC-IP mapping table and stored in the system. When the terminal device requests the DHCP server to allocate an IP address, it first checks whether the MAC address of the device already exists in the MAC-IP mapping table. If the MAC address of the device already exists and is consistent with the IP address in the mapping table, it means that the IP address has not been used by other devices and the IP address can be directly allocated. If the MAC address of the device does not exist in the mapping table, a new IP address is allocated from the IP pool. In order to avoid IP address conflicts, the method of the present invention also includes conflict detection by comparing the requested IP address with the existing MAC-IP mapping table. Before allocating the IP address, the system will compare the correspondence between the existing MAC address in the network and the requested IP address to determine whether a conflict may occur. Finally, the system periodically pulls ARP table information from network devices and updates the local MAC-IP mapping table to ensure that the MAC-IP mapping relationship in the network is always kept up to date, thereby effectively avoiding IP address conflicts caused by device changes or lease synchronization delays.
[0035] The present application solves the various problems existing in the traditional IP address conflict detection method mentioned in the background technology by introducing a multi-protocol data acquisition mechanism. First, by regularly pulling the ARP table information of the network device, the conflict problem caused by the lease information being out of sync or the inability to update in time when the device is restored is avoided. Through this real-time update mechanism, it is ensured that the MAC-IP mapping relationship of each device in the network is always kept up to date. Secondly, the traditional Ping detection method is easily affected by the terminal device disabling Ping or the unreachable network, resulting in the failure of conflict detection. The present invention can bypass this limitation through conflict detection based on the ARP table, and can still accurately detect IP address conflicts even if the terminal device disables Ping or is in a state where the network route is unreachable. In addition, there is a delay problem in the passive conflict detection in the traditional method, and the active conflict detection mechanism of the present invention can prejudge risks before the IP address is allocated, thereby greatly reducing the probability of IP conflicts and improving the stability and reliability of the network. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 A flowchart of an IP address allocation conflict detection method based on multi-protocol ARP data collection provided by an embodiment of the present application;
[0037] Figure 2 A business processing flow chart of an IP address allocation conflict detection method based on multi-protocol ARP data collection provided by one embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0039] In one embodiment, Figure 1 As shown, a method for detecting IP address allocation conflicts based on multi-protocol ARP data collection is provided, comprising the following steps:
[0040] When the DHCP service is started, the ARP table information is obtained from the network device through the SNMP protocol, the SSH protocol or the RESTful API protocol, and the network device is a switch or a router;
[0041] The ARP table information is aggregated to form a MAC-IP mapping table, and the corresponding relationship between the MAC address of each device and its assigned IP address is recorded;
[0042] Upon receiving an IP allocation request, checking whether the MAC address of the requesting terminal device exists in the MAC-IP mapping table;
[0043] If the MAC address of the requesting terminal device exists in the MAC-IP mapping table, the IP address is directly allocated to the terminal;
[0044] If the MAC address of the requesting terminal device is not in the MAC-IP mapping table, a new IP address is allocated to the terminal from the available IP pool;
[0045] Before allocating an IP address, by comparing the information in the MAC-IP mapping table, determine whether there is a risk of IP address conflict in the current network environment;
[0046] The ARP table information of the network device is obtained periodically through multiple protocols to update the MAC-IP mapping table.
[0047] In this embodiment, when the DHCP service is started, the ARP table information is obtained from the core devices (such as switches and routers) in the network through multiple protocols (such as SNMP, SSH, and RESTful API). The ARP table records the correspondence between the MAC address of the network device and the IP address assigned to it. After obtaining this information, it is summarized and formed into a MAC-IP mapping table and stored in the system. Next, when the terminal device requests the DHCP server to allocate an IP address, it first checks whether the MAC address of the device already exists in the MAC-IP mapping table. If the MAC address of the device already exists and is consistent with the IP address in the mapping table, it means that the IP address has not been used by other devices and the IP address can be directly allocated. If the MAC address of the device does not exist in the mapping table, a new IP address is allocated from the IP pool. In order to avoid IP address conflicts, this embodiment also includes conflict detection comparing the requested IP address with the existing MAC-IP mapping table. Before allocating an IP address, the system will compare the correspondence between the existing MAC address in the network and the requested IP address to determine whether a conflict may occur. The system periodically pulls ARP table information from network devices and updates the local MAC-IP mapping table to ensure that the MAC-IP mapping relationship in the network is always kept up to date, thereby effectively avoiding IP address conflicts caused by device changes or lease synchronization delays.
[0048] This embodiment solves the various problems of the traditional IP address conflict detection method mentioned in the background technology by introducing a multi-protocol data acquisition mechanism. First, by regularly pulling the ARP table information of the network device, the conflict problem caused by the lease information being out of sync or the inability to update in time when the device is restored is avoided. Through this real-time update mechanism, it is ensured that the MAC-IP mapping relationship of each device in the network is always kept up to date. Secondly, the traditional Ping detection method is easily affected by the terminal device disabling Ping or the unreachable network, resulting in the failure of conflict detection. The present invention can bypass this limitation through conflict detection based on the ARP table, and can still accurately detect IP address conflicts even if the terminal device disables Ping or is in a state where the network route is unreachable. In addition, there is a delay problem in the passive conflict detection in the traditional method, and the active conflict detection mechanism of the present invention can prejudge risks before the IP address is allocated, thereby greatly reducing the probability of IP conflicts and improving the stability and reliability of the network.
[0049] In this embodiment, the step of obtaining the ARP table information by the SNMP protocol is specifically as follows: using SNMP credentials to communicate with the network device, pulling the ARP table information, and obtaining the ARP table from the switch or router through a get request of the SNMP protocol.
[0050] This embodiment establishes communication with a network device (such as a switch or router) through SNMP credentials (such as version information, port information, and community word information), and uses the SNMP protocol to send a get request to obtain the ARP table information of the network device. At this time, the SNMP protocol will return the ARP table to the requester and provide the corresponding device status data through the management information base (MIB) in the network. In order to ensure the accuracy and integrity of the acquired data, the use of the SNMP protocol requires strict identity authentication and encryption to avoid potential network security risks. After the management interface of the network device is configured with SNMP credentials, these credentials can be used on the DHCP server to communicate securely with the switch or router, obtain the mapping relationship between the MAC address and the IP address of all devices in the current network, and organize this information into a MAC-IP mapping table.
[0051] This embodiment uses the SNMP protocol to obtain ARP table information, and can achieve remote management and status monitoring of network devices without directly connecting to the network devices. This enables the present invention to efficiently and real-time obtain the MAC-IP mapping relationship of devices in the network in a large-scale network environment, thereby reducing the complexity and maintenance cost of device management. The SNMP protocol uses a standardized communication mechanism to enable switches and routers of different brands and models to be monitored and data collected under the same management framework, thereby improving the versatility and adaptability of the system. Compared with traditional manual configuration or conflict detection mechanisms that rely on fixed protocols, the SNMP protocol can obtain ARP information of network devices more quickly and accurately, providing more timely and reliable data support for conflict detection.
[0052] In this embodiment, the step of obtaining ARP table information through the SSH protocol is specifically: using SSH credentials to establish an encrypted connection with the network device, and executing a command through the SSH protocol to obtain ARP table data, wherein the command is a configurable custom command that can return the ARP table content of the network device.
[0053] This embodiment uses the SSH protocol to obtain ARP table information. In specific implementation, the DHCP server establishes a secure encrypted connection with the network device through SSH credentials (such as port information, user name, password). Through the SSH protocol, the DHCP server can remotely log in to the switch or router, execute the corresponding command, and obtain the ARP table information of the device. The data transmitted through the SSH protocol is encrypted to ensure the security and confidentiality of the data and avoid the risk of network attacks or data leakage that may be suffered during the transmission process. After obtaining the ARP table information, the system will parse the ARP table, extract the mapping relationship between the MAC address and the IP address, and update the local MAC-IP mapping table.
[0054] In this embodiment, the SSH protocol, as an encrypted transmission protocol, has high security and can effectively prevent malicious attacks and information leakage in the network. Compared with other protocols (such as HTTP or FTP), the SSH protocol can provide stronger data encryption and identity authentication mechanisms to ensure the integrity and confidentiality of information during transmission. This is especially important for scenarios where sensitive network data needs to be protected (such as large-scale enterprise networks or data centers). Remotely obtaining ARP table information through the SSH protocol can not only ensure data security, but also avoid the inconvenience caused by physical access to network devices, making network management more efficient and convenient. In addition, the SSH protocol also has strong cross-platform compatibility and can adapt to the requirements of different operating systems and network devices, so that this embodiment can be applied in various network environments.
[0055] In this embodiment, the steps of obtaining ARP table information through the RESTful API protocol are specifically as follows: calling the interface through the RESTful API, returning the ARP table information of the network device as response data, and the API interface includes the IP address, port, authentication information and URL path of querying the ARP table of at least one device.
[0056] In this embodiment, the DHCP server interacts with the network device through a RESTful API. The network device returns ARP table information through a predefined RESTful interface, which includes the device IP address, port, authentication information, etc., and uses an HTTP request method (such as a GET request) to obtain ARP table data.
[0057] As a lightweight Web service protocol, RESTful API supports stateless communication based on HTTP protocol and can efficiently transmit data between various operating systems and devices. When using RESTful API, the system sends API requests to network devices and obtains JSON or XML format data of the ARP table. The obtained ARP table information will be parsed and stored in the MAC-IP mapping table.
[0058] The RESTful API protocol is efficient and easy to implement, and can easily interact with various network devices. Its communication method based on the HTTP protocol makes cross-platform integration easier and can adapt to different types of operating systems, hardware devices, and network environments.
[0059] Using RESTful API to obtain ARP table information makes the conflict detection method of the present invention more flexible and adaptable to various types of network devices and management systems. Compared with traditional SNMP and SSH protocols, RESTful API can better support device management in cloud computing and virtualized environments, and has great advantages in scalability and maintainability.
[0060] In this embodiment, each mapping information recorded in the MAC-IP mapping table includes a MAC address, a corresponding IP address, an allocation timestamp of the IP address, and a usage status of the IP address.
[0061] The MAC-IP mapping table not only records the MAC address and corresponding IP address of the device, but also includes the allocation timestamp and status information of the IP address. This information helps to accurately track the usage of IP addresses in the network. For example, each time a new IP address is allocated, the system records the allocation time and the usage status of the current IP address (such as "allocated" or "unassigned"). In addition, the MAC-IP mapping table also supports regular cleanup of expired IP addresses, especially when the DHCP lease expires or the device is delisted, to ensure that the MAC-IP mapping table in the network always remains accurate. Each time the MAC-IP mapping table is updated, the system will delete the expired data in it and synchronize it with the latest ARP table information.
[0062] This embodiment records the allocation timestamp and usage status of the IP address. The MAC-IP mapping table not only improves the accuracy of conflict detection, but also ensures that in a dynamically changing network environment, the allocation of IP addresses can reflect the status of the network in real time, avoiding conflicts caused by network changes or device changes. By regularly cleaning up expired IPs, long-term invalid IP mappings are avoided, further improving the efficiency and accuracy of the system.
[0063] In this embodiment, the IP address conflict risk determination step includes:
[0064] Compare the MAC address of the requesting terminal device with the existing MAC-IP mapping table;
[0065] If the MAC address already exists in the mapping table and the corresponding IP address is the same as the requested IP address, the request is considered non-conflicting;
[0066] If the MAC address exists in the mapping table and the corresponding IP address is different from the requested IP address, an IP address conflict alarm is issued.
[0067] In the DHCP service, the ARP table information of network devices is obtained regularly through various protocols (such as SNMP, SSH, RESTfulAPI), and the local MAC-IP mapping table is refreshed based on this information. Specifically, the system sends data requests to the core devices in the network regularly (such as every hour or every day), obtains its latest ARP table, parses the MAC-IP mapping relationship, and compares and updates the new information with the existing mapping table.
[0068] In terms of implementation, this embodiment automatically performs ARP table pull and update operations through a scheduled task (such as using a cron task). When new ARP table information is obtained, the system will determine whether there is a new MAC address mapping relationship or whether a device has been disconnected from the network, so as to update the records in the mapping table in a timely manner. If there is a new MAC address or IP address combination, the system will add it to the mapping table; if it is found that the lease of some IP addresses has expired or the device has been disconnected, the system will remove the expired mapping items.
[0069] This embodiment regularly obtains and updates the MAC-IP mapping table, which can ensure that the IP address allocation information of the devices in the network is always up to date, avoiding IP conflicts caused by device changes or network status changes. In addition, the regular update mechanism also ensures the automated management of the system, reduces manual intervention, and reduces the complexity of operation and maintenance.
[0070] By regularly synchronizing ARP table data, the system can respond to changes in the network in real time and update the usage of IP addresses in a timely manner, thereby reducing conflicts caused by information lag or device status not being synchronized in time. This regular update mechanism improves the stability and reliability of the entire network and ensures that the allocation of IP addresses is always accurate.
[0071] In this embodiment, the periodic updating of the MAC-IP mapping table includes:
[0072] Send ARP table acquisition requests to network devices via SNMP, SSH, or RESTful API protocols at predetermined time intervals;
[0073] The acquired ARP table information is merged with the existing MAC-IP mapping table, the correspondence between the MAC address and the IP address in the mapping table is updated, and invalid or expired IP addresses are cleared.
[0074] When the DHCP service detects that the MAC address of the assigned IP address is inconsistent with the ARP table information pulled during the lease period, a mechanism to issue an alarm in time. Specifically, after the DHCP server assigns an IP address, the system will check the MAC address corresponding to each assigned IP address in the network regularly or on demand. If the MAC address of an IP address is found to be inconsistent with the previous record when regularly obtaining the ARP table, the system will trigger an alarm mechanism to remind the network administrator to check the usage of this IP address.
[0075] The alarm mechanism can be implemented in a variety of ways, such as sending emails to administrators, generating system logs, triggering SNMP traps, etc. Administrators can further analyze the alarm information to confirm whether an IP address conflict has occurred, or whether there is device misuse or IP reuse.
[0076] This embodiment detects in real time and issues an alarm for inconsistencies between IP addresses and MAC addresses. The present invention can identify potential IP conflict risks in a timely manner before a conflict occurs. The alarm mechanism not only improves the efficiency of network management, but also enables network administrators to quickly locate and solve problems, thereby reducing the time and impact of network failures. The alarm mechanism enhances the monitoring capability of the system and ensures the accuracy and real-time performance of the IP address allocation process. Compared with traditional methods, the present invention can respond in the early stage of a conflict to prevent the interruption of network services and the decline of user experience.
[0077] In this embodiment, the network device is at least one switch or router, and the switch or router provides mapping information between MAC addresses and IP addresses in its network through an ARP table, and the ARP table information includes physical interface information of the device.
[0078] By using the conflict detection method of this embodiment in a multi-DHCP server environment, the conflict problem caused by overlapping IP address allocation between different servers can be effectively avoided. Through the centrally managed MAC-IP mapping table, all DHCP servers can share the IP address usage of all devices in the network, and realize the coordinated management of multiple DHCP servers. This mechanism improves the reliability of the system and avoids the repeated allocation of IP addresses in a high-concurrency network environment, thereby ensuring that the IP address management in the entire network environment is more efficient and stable.
[0079] In this embodiment, the IP address conflict risk judgment further includes:
[0080] Check the matching of the assigned IP address and the current MAC address in the network, and confirm whether the assigned IP address is correct according to the ARP table information. If the MAC address is inconsistent with the IP address, the system will automatically issue a warning and record the conflict event.
[0081] In this embodiment, the IP address allocation conflict detection is used in a network environment where multiple DHCP servers coexist, and the MAC-IP mapping table is updated when the primary and backup DHCP servers switch to avoid IP address conflicts caused by unsynchronized lease information. Different IP address allocation strategies are supported, including a hybrid mode of static allocation and dynamic allocation.
[0082] In one embodiment, Figure 2As shown, a method for detecting IP address allocation conflicts based on multi-protocol ARP data collection is provided. By collecting ARP table information of switches or routers in the network, the corresponding relationship between MAC addresses and IP addresses in the current network can be quickly grasped. This method is not only applicable to the active-standby DHCP switching scenario, but also can detect and prevent IP conflicts in real time in networks where multiple DHCP servers coexist or manual allocation exists.
[0083] This embodiment provides a multi-protocol based ARP data collection method to perform conflict detection before IP allocation. For the convenience of the following description, we define some terms used here:
[0084] SNMP credentials: SNMP protocol version information, port information, community word information. Combined with these SNMP credentials, you can communicate with network devices securely and effectively through the SNMP protocol to achieve functions such as device status monitoring, data collection, and configuration management. For example, in DHCP configuration, these credentials can be used to access the ARP table information of the switch.
[0085] SSH credentials: port information, username information, and password information used by the SSH protocol. By combining these SSH credentials, you can establish a secure and reliable encrypted connection with network devices through the SSH protocol to achieve remote device access, status monitoring, and configuration management. For example, in DHCP configuration, these credentials can be used to access network devices through SSH, obtain their ARP table information, ensure the accuracy of IP address allocation, and reduce potential conflicts.
[0086] RESTful API interface information: basic URL, port, authentication information, used to establish a secure connection. This interface information can be used to access network devices through RESTful API to obtain ARP table information.
[0087] Lease: When the DHCP service assigns an IP address to a client, it usually comes with a lease. The lease indicates how long the client can use the IP address. For example, the lease can be set to 24 hours, 7 days, etc.
[0088] The specific steps of this embodiment are as follows:
[0089] Multi-protocol ARP table information acquisition: When the DHCP service is started, ARP table information is pulled from network devices (such as switches and routers) through multiple protocols based on the configured core network device IP address information, SNMP credentials, SSH credentials, and RESTful API interface information.
[0090] Summarize the ARP table information to form a MAC-IP mapping table, process the marked IP address status, and write the file record.
[0091] MAC address verification: When the DHCP service receives an IP allocation request, it first checks whether the MAC address of the terminal device appears in the MAC-IP mapping table.
[0092] Address allocation logic:
[0093] If a match exists, the terminal MAC address is mapped to a specific IP address in the MAC-IP mapping table. The IP address is directly assigned.
[0094] No match: If no corresponding relationship is found in the MAC-IP mapping table, a new IP address is allocated to the terminal from the available IP pool.
[0095] IP address conflict prevention: Before allocating IP addresses, the system compares the information with the MAC-IP mapping table to timely predict the risk of conflicts and reduce the possibility of IP address conflicts caused by lease asynchrony or multi-server allocation.
[0096] Regular update of MAC-IP mapping table information: During operation, the DHCP service can regularly obtain the ARP table information of network devices through various protocols, refresh the cached MAC-IP mapping table, and ensure real-time understanding of the IP allocation status in the network.
[0097] When the DHCP service detects that the MAC address of the allocated IP address is inconsistent with the ARP table information pulled during the lease period, an alarm is issued in a timely manner.
[0098] The key technical points of this embodiment are:
[0099] Multi-protocol ARP table information collection: Acquire network device ARP table data by supporting multi-protocol data collection to increase applicability so that the MAC-IP correspondence relationship can be grasped in real time in a variety of network environments.
[0100] Add MAC-IP verification in DHCP address allocation: Before allocating IP addresses, check whether the terminal MAC address already exists in the MAC-IP mapping table to prevent conflicts.
[0101] Dynamic IP allocation adjustment: Automatically adjust the terminal's IP allocation strategy based on the MAC-IP mapping table verification results to ensure that the terminal obtains a suitable IP address.
[0102] Timely detection of IP address conflicts: When the MAC address of the allocated IP address is detected to be inconsistent with the ARP table information pulled during the lease period, an alarm is issued in a timely manner.
[0103] Compatible with various allocation scenarios: Applicable to environments with multiple DHCP servers in parallel and manually configured IP address conflict detection.
[0104] The method of this embodiment has the following advantages:
[0105] Timely conflict detection: Based on multi-protocol collection, ARP information can be quickly acquired and updated to effectively prevent address conflicts.
[0106] Wide applicability: It supports use in multiple scenarios such as active-standby switching, multiple DHCP servers, and manual allocation, which improves the universality of conflict detection.
[0107] Improve network stability: Real-time verification of ARP table information during DHCP address allocation greatly reduces the possibility of address conflicts and ensures the stability and reliability of network services.
[0108] Automated management: Avoids manual intervention or complex configuration adjustments, simplifies high-availability deployment of DHCP services, and improves the automation level of the system.
[0109] In a specific example, two DHCP servers, active and standby, are deployed in a certain enterprise network. When the active node fails, the standby node automatically starts and takes over the DHCP service. After the standby node starts, it pulls the ARP table information of the three core switches in the network through multiple protocols. The MAC address of a terminal device corresponds to the IP address 192.168.1.10 in the ARP table, so the standby node directly assigns 192.168.1.10 to the device when assigning an address. If other new devices are not in the ARP table, the standby node assigns a new IP address to the device from the free IP address pool to ensure that no address conflicts occur.
[0110] In practical applications, the solution of this embodiment greatly improves the high availability and stability of the DHCP service during the active-standby switching process, significantly reduces the occurrence of IP address allocation conflicts, and improves the service quality of the network.
[0111] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for detecting IP address allocation conflicts based on multi-protocol ARP data collection, characterized in that: The method comprises: When the DHCP service is started, the ARP table information is obtained from the network device through the SNMP protocol, the SSH protocol or the RESTful API protocol, and the network device is a switch or a router; The ARP table information is aggregated to form a MAC-IP mapping table, and the corresponding relationship between the MAC address of each device and its assigned IP address is recorded; Upon receiving an IP allocation request, checking whether the MAC address of the requesting terminal device exists in the MAC-IP mapping table; If the MAC address of the requesting terminal device exists in the MAC-IP mapping table, the IP address is directly allocated to the terminal; If the MAC address of the requesting terminal device is not in the MAC-IP mapping table, a new IP address is allocated to the terminal from the available IP pool; Before allocating an IP address, by comparing the information in the MAC-IP mapping table, determine whether there is a risk of IP address conflict in the current network environment; The ARP table information of the network device is obtained periodically through multiple protocols to update the MAC-IP mapping table.
2. The method according to claim 1, characterized in that The steps of obtaining the ARP table information by the SNMP protocol are specifically as follows: using the SNMP credentials to communicate with the network device, pulling the ARP table information, and obtaining the ARP table from the switch or router through a get request of the SNMP protocol.
3. The method according to claim 1, characterized in that The step of obtaining the ARP table information through the SSH protocol is specifically: using the SSH credential to establish an encrypted connection with the network device, and executing a command through the SSH protocol to obtain the ARP table data, wherein the command is a configurable custom command that can return the ARP table content of the network device.
4. The method according to claim 1, characterized in that: The steps of obtaining ARP table information through the RESTful API protocol are specifically as follows: calling the interface through the RESTful API to return the ARP table information of the network device as response data, and the API interface includes the IP address, port, authentication information and URL path of querying the ARP table of at least one device.
5. The method according to claim 1, characterized in that Each mapping information recorded in the MAC-IP mapping table includes a MAC address, a corresponding IP address, an allocation timestamp of the IP address, and a usage status of the IP address.
6. The method according to claim 1, characterized in that The IP address conflict risk determination step includes: Compare the MAC address of the requesting terminal device with the existing MAC-IP mapping table; If the MAC address already exists in the mapping table and the corresponding IP address is the same as the requested IP address, the request is considered non-conflicting; If the MAC address exists in the mapping table and the corresponding IP address is different from the requested IP address, an IP address conflict alarm is issued.
7. The method according to claim 1, characterized in that The periodic updating of the MAC-IP mapping table includes: Send ARP table acquisition requests to network devices via SNMP, SSH, or RESTful API protocols at predetermined time intervals; The acquired ARP table information is merged with the existing MAC-IP mapping table, the correspondence between the MAC address and the IP address in the mapping table is updated, and invalid or expired IP addresses are cleared.
8. The method according to claim 1, characterized in that The network device is at least one switch or router, and the switch or router provides mapping information between MAC addresses and IP addresses in its network through an ARP table, and the ARP table information includes physical interface information of the device.
9. The method according to claim 1, characterized in that: The IP address conflict risk judgment also includes: Check the matching between the assigned IP address and the current MAC address in the network, and confirm whether the assigned IP address is correct based on the ARP table information; if the MAC address is inconsistent with the IP address, the system automatically issues a warning and records the conflict event.
10. The method according to claim 1, characterized in that The IP address allocation conflict detection is used in a network environment where multiple DHCP servers coexist, and updates the MAC-IP mapping table when the primary and backup DHCP servers switch to avoid IP address conflicts caused by unsynchronized lease information. Different IP address allocation strategies are supported, including a hybrid mode of static allocation and dynamic allocation.
Citation Information
Cited By
Remote login method, electronic device, storage medium and program product
CN119865492A
Method for automatically detecting and solving repeated IP address conflict in distributed cluster
CN120223669A