CN112217913B - Method and device for negotiating IP address - Google Patents

Method and device for negotiating IP address Download PDF

Info

Publication number
CN112217913B
CN112217913B CN202010972913.5A CN202010972913A CN112217913B CN 112217913 B CN112217913 B CN 112217913B CN 202010972913 A CN202010972913 A CN 202010972913A CN 112217913 B CN112217913 B CN 112217913B
Authority
CN
China
Prior art keywords
address
equipment
network
message
network card
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.)
Active
Application number
CN202010972913.5A
Other languages
Chinese (zh)
Other versions
CN112217913A (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.)
DBAPPSecurity Co Ltd
Original Assignee
DBAPPSecurity 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 DBAPPSecurity Co Ltd filed Critical DBAPPSecurity Co Ltd
Priority to CN202010972913.5A priority Critical patent/CN112217913B/en
Publication of CN112217913A publication Critical patent/CN112217913A/en
Application granted granted Critical
Publication of CN112217913B publication Critical patent/CN112217913B/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/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • 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/25Mapping addresses of the same type
    • H04L61/2503Translation of Internet protocol [IP] addresses
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2101/00Indexing scheme associated with group H04L61/00
    • H04L2101/60Types of network addresses
    • H04L2101/618Details of network addresses
    • H04L2101/622Layer-2 addresses, e.g. medium access control [MAC] addresses

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The application relates to a method, a device, an electronic device and a storage medium for negotiating an IP address, wherein the method for negotiating the IP address comprises the following steps: controlling the first equipment to send an ARP packet to a network card in a local area network and receiving a return message; if the network segment of the second device returning the message is different from that of the first device, the network segment of the device with the high MAC address is adjusted to be consistent with that of the device with the low MAC address in the second device and the first device; and selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address, and replacing the IP address of the equipment with the high MAC address by the new IP address in the IP pool corresponding to the network segment of the equipment with the low MAC address. By the method and the device, the problem of low efficiency of establishing negotiation communication between the devices is solved, and the negotiation communication is quickly established between the devices.

Description

Method and device for negotiating IP address
Technical Field
The present application relates to the field of wireless communications, and in particular, to a method, an apparatus, an electronic apparatus, and a storage medium for negotiating an IP address.
Background
With the progress of the internet era, a network communication protocol is a network common language and is also an important means in network communication. The network communication protocol provides communication support for interconnecting networks that connect different operating systems and different hardware architectures.
In the related art, a network communication protocol is widely applied to a device of an enterprise network to perform session synchronization between the devices. However, when the session between the devices is synchronized, the negotiation modes of the two parties need to be set in advance, so that the purpose of information exchange can be realized at the ports of the two parties; if the negotiation mode between the two parties is not set in advance, when one party of equipment is not in the negotiation mode, the other party cannot receive the information of the opposite terminal, and therefore the purpose of message exchange cannot be achieved.
At present, no effective solution is provided for the problem of low efficiency of establishing negotiation communication between devices in the related art.
Disclosure of Invention
The embodiment of the application provides a method, a device, an electronic device and a storage medium for negotiating an IP address, so as to at least solve the problem of low efficiency of device negotiation communication in the related art.
In a first aspect, an embodiment of the present application provides a method for negotiating an IP address, where the method includes: controlling the first equipment to send an ARP packet to a network card in a local area network and receiving a return message; if the network segment of the second device returning the message is different from that of the first device, the network segment of the device with the high MAC address is adjusted to be consistent with that of the device with the low MAC address in the second device and the first device; and selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address, and replacing the IP address of the equipment with the high MAC address by the new IP address in the IP pool corresponding to the network segment of the equipment with the low MAC address.
In some embodiments, after the controlling the first device sends an ARP packet to a network card in the local area network and receives a return message, the method further includes: and if the network segments of the second equipment returning the message are the same as those of the first equipment and the IP addresses are different, establishing communication connection between the second equipment and the first equipment.
In some embodiments, after the controlling the first device sends an ARP packet to a network card in the local area network and receives a return message, the method further includes: and if the network segments and the IP addresses of the second equipment returning the message are the same as those of the first equipment, selecting a new IP address from the IP pool to replace the IP address of the equipment with higher MAC address in the second equipment and the first equipment.
In some embodiments, before the controlling the first device sends an ARP packet to a network card in a local area network and receives a return message, the method further includes: controlling the first equipment to send an ARP packet to a network card of the first equipment and receiving a return message; and if the network card of the return message is different from the network segment of the first equipment, selecting a new IP address from the IP pool corresponding to the network segment of the first equipment, and replacing the IP address of the network card of the return message by the new IP address.
In some embodiments, after the controlling the first device sends an ARP packet to its network card and receives a return message, the method further includes: if the network card of the return message is the same as the network segment of the first equipment, performing hash check on the network card of the return message; and under the condition that the hash check is successful, establishing communication connection between the first equipment and the network card for returning the message.
In some embodiments, the hash check method includes: performing hash operation on the MAC address of the network card of the returned message to obtain a hash operation result, dividing the hash operation result by the network segment length of the network card of the returned message to obtain a remainder, and comparing the remainder with the IP address of the network card of the returned message; if the comparison results are consistent, the Hash check is proved to be successful; and if the comparison result is inconsistent, the hash check is proved to be failed.
In some embodiments, after performing hash check on the network card of the return message if the network card of the return message is the same as the network segment of the first device, the method further includes: and under the condition that the Hash check fails, selecting a new IP address from the IP pool corresponding to the network segment of the first equipment, replacing the IP address of the network card returning the message with the new IP address in the IP pool corresponding to the network segment of the first equipment, and establishing communication connection between the first equipment and the network card returning the message.
In a second aspect, an embodiment of the present application provides an apparatus for negotiating an IP address, where the apparatus includes: the system comprises a broadcasting module, an adjusting module and a replacing module; the broadcast module is used for controlling the first equipment to send an ARP packet to a network card in the local area network and receiving a return message; the adjusting module is used for adjusting the network segment of the device with the high MAC address to be consistent with the network segment of the device with the low MAC address in the second device and the first device if the network segment of the second device returning the message is different from the network segment of the first device; the replacing module is used for selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address and replacing the IP address of the equipment with the high MAC address with the new IP address. In a third aspect, an embodiment of the present application provides an electronic apparatus, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the processor implements a method for negotiating an IP address as described in the first aspect.
In a fourth aspect, the present application provides a storage medium, on which a computer program is stored, where the program is executed by a processor to implement a method for negotiating an IP address according to the first aspect.
Compared with the related art, the method, the device, the electronic device and the storage medium for negotiating the IP address provided by the embodiment of the application send the ARP packet to the network card in the local area network by controlling the first equipment and receive the return message; if the network segment of the second device returning the message is different from that of the first device, the network segment of the device with the high MAC address is adjusted to be consistent with that of the device with the low MAC address in the second device and the first device; and selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address, and replacing the IP address of the equipment with the high MAC address by using the new IP address in the IP pool corresponding to the network segment of the equipment with the low MAC address. The problem of low negotiation communication efficiency of the equipment is solved, and the effect of rapid negotiation communication between the equipment is realized.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the application and together with the description serve to explain the application and not to limit the application. In the drawings:
fig. 1 is a block diagram of a hardware structure of an application terminal of a method for negotiating an IP address according to an embodiment of the present invention;
FIG. 2 is a flow diagram of a method of negotiating an IP address according to an embodiment of the present invention;
FIG. 3 is a flow diagram of another method of negotiating an IP address according to an embodiment of the present invention;
FIG. 4 is a flow chart of yet another method of negotiating an IP address according to an embodiment of the present invention;
fig. 5 is a block diagram of an apparatus for negotiating an IP address according to an embodiment of the present invention;
fig. 6 is a block diagram of a computer device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be described and illustrated below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments provided in the present application without any inventive step are within the scope of protection of the present application. Moreover, it should be appreciated that in the development of any such actual implementation, as in any engineering or design project, numerous implementation-specific decisions must be made to achieve the developers' specific goals, such as compliance with system-related and business-related constraints, which may vary from one implementation to another.
Reference in the specification to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the specification. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is to be expressly and implicitly understood by one of ordinary skill in the art that the embodiments described herein may be combined with other embodiments without conflict.
Unless otherwise defined, technical or scientific terms referred to herein should have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The use of the terms "a" and "an" and "the" and similar referents in the context of describing the invention (including a single reference) are to be construed in a non-limiting sense as indicating either the singular or the plural. The present application is directed to the use of the terms "including," "comprising," "having," and any variations thereof, which are intended to cover non-exclusive inclusions; for example, a process, method, system, article, or apparatus that comprises a list of steps or modules (elements) is not limited to only those steps or elements but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus. Reference to "connected," "coupled," and the like in this application is not intended to be limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Reference herein to "a plurality" means greater than or equal to two. "and/or" describes an association relationship of associated objects, meaning that three relationships may exist, for example, "A and/or B" may mean: a exists alone, A and B exist simultaneously, and B exists alone. Reference herein to the terms "first," "second," "third," and the like, are merely to distinguish similar objects and do not denote a particular ordering for the objects.
The method provided by the embodiment can be executed in a terminal, a computer or a similar operation device. Taking the operation on the terminal as an example, fig. 1 is a hardware structure block diagram of an application terminal of a method for negotiating an IP address according to an embodiment of the present invention. As shown in fig. 1, the terminal may include one or more (only one shown in fig. 1) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, and optionally, a transmission device 106 for communication functions and an input-output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the terminal. For example, the terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be used to store a computer program, for example, a software program and a module of application software, such as a computer program corresponding to a method for negotiating an IP address in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, so as to implement the method described above. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to the terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used to receive or transmit data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the terminal. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 may be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
In the related art, when the device of the network performs session synchronization between the devices, the negotiation modes of the two devices need to be set in advance, so as to achieve the purpose of quickly establishing negotiation communication between the devices; if the negotiation mode between the two parties is not set in advance, when one party of equipment is not in the negotiation mode, the other party cannot receive the information of the opposite end, and therefore the purpose of message exchange cannot be achieved.
The existing two devices exchange and synchronize information, and it is necessary that the two devices have auto-negotiation capability to enable the two devices to receive the information of the other party, so a negotiation mechanism is needed to be set up to enable the two parties to modify their own network cards and addresses through the network cards and addresses of the other party under the condition that the two parties do not have negotiation, thereby achieving the condition of negotiation and further implementing information exchange. If the negotiation mechanism can not be modified, when one party does not work in the automatic negotiation mode, only one party sends the message, so that the negotiation with the opposite end can not be carried out, and the purpose of information exchange can not be achieved.
In the related art, when two devices communicate with each other, only the negotiation mode is set in advance. Under the condition that one or both parties do not have negotiation, the obtained opposite-end information is compared with the self information, if the comparison result is inconsistent, the self data can be modified to realize the negotiation consistency, and the purpose of mutual communication is achieved. The present invention provides a new negotiation method, which solves the problem of low device negotiation communication efficiency, and the following embodiments are specific embodiments for solving this problem.
Fig. 2 is a flowchart of a method for negotiating an IP address according to an embodiment of the present invention, and as shown in fig. 2, the flowchart includes the following steps:
step S201, controlling the first device to send an ARP packet to a network card in the local area network and receiving a return message;
wherein a computer network is a collection of interconnected computing devices that can exchange data and share resources. The computer network is divided into seven layers, the network protocol is at the second layer L2, ethernet is an example of the L2 communication protocol, and the network switch is an example of the L2 device that participates in the data exchange. A device can communicate with other devices connected to the network switch if it has access to a port of the network switch.
The ARP is an address resolution protocol, which is a TCP/IP protocol that obtains a physical address from an IP address. When the host sends information, the ARP request containing the target IP address is broadcasted to all the hosts on the local area network, and the return message is received, so that the physical address of the target is determined; after receiving the return message, the IP address and the physical address are stored in the local ARP cache and are kept for a certain time, and the ARP cache is directly inquired when the next request is made so as to save resources.
Specifically, the first device is the own device, the second device is the opposite device, the own device is controlled to perform the ARP broadcast first, and then the opposite device sends a returned message after receiving the ARP broadcast, and the own device can obtain the IP address of the opposite device by analyzing the returned message.
Step S202, if the network segment of the second device returning the message is different from the network segment of the first device, in the second device and the first device, the network segment of the device with high MAC address is adjusted to be consistent with the network segment of the device with low MAC address;
if the network segments of the device and the opposite device are different, the IP pools of the two devices are proved not to be the same network segment.
Specifically, the IP pool with a high MAC address is replaced with the IP pool with a low MAC address.
Step S203, a new IP address is selected from the IP pool corresponding to the network segment of the device with low MAC address, and the IP address of the device with high MAC address is replaced by the new IP address in the IP pool corresponding to the network segment of the device with low MAC address.
Through the steps S201 to S203, the present invention solves the problem that one or both of the two devices do not work in the negotiation mode, and the above method is used to realize that the ports of both of the two devices have the capability of negotiation communication, and the present invention randomly selects an IP address from the IP pool with low MAC address to allocate to the device with high MAC address to replace the original IP address, so that the two devices can send broadcast messages to all computers in the same network segment, that is, in the same broadcast domain, so that the computers in the network segment do not need devices such as routers, etc., to directly establish negotiation communication, which simplifies the method for negotiation communication between the two devices, solves the problem of low efficiency of negotiation communication established between the devices, and realizes the rapid establishment of negotiation communication between the devices.
In some embodiments, the network cable direct connection device synchronization interface is used by deploying one device on each link; then configuring two same devices, proxy server address, and operating the negotiation communication function of the devices, wherein one device is not in the negotiation condition in the negotiation process, and the two devices can reach the negotiation condition through the method, thereby the two devices can continuously meet the negotiation condition, and the rapid establishment of the negotiation communication between the devices is realized.
This embodiment provides a method for negotiating an IP address, fig. 3 is a flowchart of another method for negotiating an IP address according to an embodiment of the present invention, and as shown in fig. 3, after controlling a first device to send an ARP packet to a network card in a local area network and receive a return message in step S201, the process includes the following steps:
step S301, if the network segment of the second device returning the message is the same as the network segment of the first device and the IP address is different, establishing a communication connection between the second device and the first device.
If the network segment of the device returning the message is consistent with the network segment of the device, the communication can be established between the two devices, if the IP of the two devices is consistent, the IP address allocation is wrong, the IP address allocation needs to be reallocated, and if the IP addresses of the two devices are not consistent, the normal communication can be performed. The communication session can be normal by establishing communication connection between the two devices, and efficient information transmission is realized.
This embodiment provides a method for negotiating an IP address, fig. 4 is a flowchart of another method for negotiating an IP address according to an embodiment of the present invention, and as shown in fig. 4, after controlling a first device to send an ARP packet to a network card in a local area network in step S201 and receiving a return message, the process includes the following steps:
step S401, if the network segment and the IP address of the second device returning the message are the same as those of the first device, selecting a new IP address from the IP pool to replace the IP address of the device with a higher MAC address in the second device and the first device.
The IP address of the equipment with the higher MAC address is replaced by the network segment with the lower MAC address, and one IP address is selected from the new IP pool to replace the IP address with the higher MAC address, so that the communication between the equipment can be realized efficiently.
In some embodiments, before the controlling the first device sends the ARP packet to the network card in the local area network and receives the return message, the method further includes: controlling the first equipment to send an ARP packet to the network card of the first equipment and receiving a return message; and if the network card of the return message is different from the network segment of the first equipment, selecting a new IP address from the IP pool corresponding to the network segment of the first equipment, and replacing the IP address of the network card of the return message by the new IP address.
Before the communication between the equipment and the external equipment is established, the equipment needs to detect the IP address of the network card of the equipment, the detection method is that an ARP packet is sent to the network card in the equipment, whether the IP addresses of the network card in the equipment are all in the same network segment is judged, if the IP addresses are in the same network segment, the normal communication between the network cards of the equipment is proved, if the IP address of the network card of the equipment is not in the same network segment, the error of the currently allocated IP address is proved, so the IP address is reallocated to the network card in the equipment, and the reallocated IP address of the network card is consistent with the network segment of the equipment, so the normal communication of the equipment can be ensured.
In some embodiments, after the controlling first device sends an ARP packet to its network card and receives a return message, the method further includes: if the network card of the return message is the same as the network segment of the first equipment, performing hash check on the network card of the return message; and under the condition that the hash check is successful, establishing communication connection between the first equipment and the network card of the return message. And under the condition that the hash check fails, selecting a new IP address from the IP pool corresponding to the network segment of the first equipment, replacing the IP address of the network card returning the message with the new IP address in the IP pool corresponding to the network segment of the first equipment, and establishing communication connection between the first equipment and the network card returning the message.
If the network segments are different and the equipment is not distributed in the initialization process, randomly selecting an IP from the IP pool and replacing the IP; if the network segments are the same, a Hash algorithm comparison is carried out, and the specific algorithm principle is that a network segment with a fixed length is set, because each network segment has a specific MAC address; performing Hash calculation on the MAC address, dividing the obtained numerical value by the network segment length to obtain a calculation result, wherein the calculation result comprises an integer part and a remainder part, comparing the remainder with the IP allocated by the equipment, and if the comparison result is consistent, considering that the IP address is normal; otherwise the IP address is not normal. By the steps, whether the IP address of the equipment network card is normal or not can be quickly verified, and smoothness of connection establishment is guaranteed.
In some embodiments, the hash check method includes: performing hash operation on the MAC address of the network card of the returned message to obtain a hash operation result, dividing the hash operation result by the network segment length of the network card of the returned message to obtain a remainder, and comparing the remainder with the IP address of the network card of the returned message; if the comparison results are consistent, the Hash check is proved to be successful; if the comparison result is not consistent, the hash check is proved to be failed.
Through the verification of the Hash algorithm, whether the IP address of the network card of the equipment is normal or not can be known, and the smoothness of connection establishment is ensured.
Fig. 5 is a block diagram of a structure of an apparatus for negotiating an IP address according to an embodiment of the present invention, where the apparatus is used to implement the foregoing embodiment and preferred embodiments, and details of the foregoing description are omitted. As used hereinafter, the terms "module," "unit," "subunit," and the like may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware, or a combination of software and hardware is also possible and contemplated.
The device for negotiating the IP comprises: a broadcasting module 501, an adjusting module 502 and a replacing module 503; the broadcast module 501 is configured to control the first device to send an ARP packet to a network card in the local area network, and receive a return message; the adjusting module 502 is configured to, if a network segment of a second device returning a message is different from a network segment of the first device, adjust a network segment of a device with a high MAC address to be consistent with a network segment of a device with a low MAC address in the second device and the first device; the replacing module 502 is configured to select a new IP address from an IP pool corresponding to a network segment of a device with a low MAC address, and replace the IP address of the device with the high MAC address with the new IP address.
Fig. 6 is a block diagram of a computer device according to an embodiment of the present invention, and as shown in the drawing, the computer device includes a memory and a processor, the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any of the method embodiments.
Optionally, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Optionally, in this embodiment, the processor may be configured to execute the following steps by a computer program:
step S1, controlling a first device to send an ARP packet to a network card in a local area network and receiving a return message;
s2, if the network segment of the second device returning the message is different from that of the first device, in the second device and the first device, the network segment of the device with the high MAC address is adjusted to be consistent with that of the device with the low MAC address;
and S3, selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address, and replacing the IP address of the equipment with the high MAC address by the new IP address in the IP pool corresponding to the network segment of the equipment with the low MAC address.
It should be understood that although the various steps described above are written in order, the steps are not necessarily performed in order. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps described above may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is a block diagram of only a portion of the architecture associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as a particular computing device may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the steps in the method of negotiating an IP address provided by the above embodiments.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous Link DRAM (SLDRAM), rambus (Rambus) direct RAM (RDRAM), direct Rambus Dynamic RAM (DRDRAM), and Rambus Dynamic RAM (RDRAM), among others.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent application shall be subject to the appended claims.

Claims (9)

1. A method of negotiating an IP address, the method comprising:
controlling the first equipment to send an ARP packet to a network card of the first equipment and receiving a return message;
if the network card of the return message is different from the network segment of the first device, selecting a new IP address from an IP pool corresponding to the network segment of the first device, and replacing the IP address of the network card of the return message with the new IP address;
controlling the first equipment to send an ARP packet to a network card in a local area network and receiving a return message;
if the network segment of the second device returning the message is different from that of the first device, the network segment of the device with the high MAC address is adjusted to be consistent with that of the device with the low MAC address in the second device and the first device;
and selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address, and replacing the IP address of the equipment with the high MAC address by using the new IP address in the IP pool corresponding to the network segment of the equipment with the low MAC address.
2. The method of claim 1, wherein after the controlling the first device sends an ARP packet to a network card in the local area network and receives a return message, the method further comprises:
and if the network segments of the second equipment returning the message are the same as those of the first equipment and the IP addresses are different, establishing communication connection between the second equipment and the first equipment.
3. The method of claim 1, wherein after the controlling the first device sends an ARP packet to a network card in the local area network and receives a return message, the method further comprises:
and if the network segments and the IP addresses of the second equipment returning the message are the same as those of the first equipment, selecting a new IP address from the IP pool to replace the IP address of the equipment with higher MAC address in the second equipment and the first equipment.
4. The method according to claim 1, wherein after the controlling first device sends an ARP packet to its network card and receives a return message, the method further comprises:
if the network card of the return message is the same as the network segment of the first equipment, performing hash check on the network card of the return message;
and under the condition that the hash check is successful, establishing communication connection between the first equipment and the network card for returning the message.
5. The method of claim 4, wherein the hash check method comprises:
performing hash operation on the MAC address of the network card of the returned message to obtain a hash operation result, dividing the hash operation result by the network segment length of the network card of the returned message to obtain a remainder, and comparing the remainder with the IP address of the network card of the returned message;
if the comparison results are consistent, the Hash check is proved to be successful;
and if the comparison result is inconsistent, the hash check is proved to be failed.
6. The method of claim 4, wherein after performing a hash check on the network card of the return message if the network card of the return message is the same as the network segment of the first device, the method further comprises:
and under the condition that the Hash check fails, selecting a new IP address from the IP pool corresponding to the network segment of the first equipment, replacing the IP address of the network card returning the message with the new IP address in the IP pool corresponding to the network segment of the first equipment, and establishing communication connection between the first equipment and the network card returning the message.
7. An apparatus for negotiating an IP address, the apparatus comprising: the device comprises a control module, a selection module, a broadcasting module, an adjustment module and a replacement module;
the control module is used for controlling the first equipment to send an ARP packet to the network card of the first equipment and receiving a return message;
the selecting module is used for selecting a new IP address from an IP pool corresponding to the network segment of the first device and replacing the IP address of the network card of the return message with the new IP address if the network card of the return message is different from the network segment of the first device;
the broadcast module is used for controlling the first equipment to send an ARP packet to a network card in a local area network and receiving a return message;
the adjusting module is used for adjusting the network segment of the equipment with the high MAC address to be consistent with the network segment of the equipment with the low MAC address in the second equipment and the first equipment if the network segments of the second equipment returning the message are different from the network segment of the first equipment;
and the replacing module is used for selecting a new IP address from the IP pool corresponding to the network segment of the equipment with the low MAC address and replacing the IP address of the equipment with the high MAC address by using the new IP address.
8. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and the processor is configured to execute the computer program to perform a method of negotiating an IP address according to any one of claims 1 to 6.
9. A storage medium having stored thereon a computer program, wherein the computer program is arranged to perform a method of negotiating an IP address as claimed in any one of claims 1 to 6 when executed.
CN202010972913.5A 2020-09-16 2020-09-16 Method and device for negotiating IP address Active CN112217913B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010972913.5A CN112217913B (en) 2020-09-16 2020-09-16 Method and device for negotiating IP address

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010972913.5A CN112217913B (en) 2020-09-16 2020-09-16 Method and device for negotiating IP address

Publications (2)

Publication Number Publication Date
CN112217913A CN112217913A (en) 2021-01-12
CN112217913B true CN112217913B (en) 2023-04-18

Family

ID=74049479

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010972913.5A Active CN112217913B (en) 2020-09-16 2020-09-16 Method and device for negotiating IP address

Country Status (1)

Country Link
CN (1) CN112217913B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115567632B (en) * 2022-09-08 2024-02-23 闪耀现实(无锡)科技有限公司 Method and device for establishing data path, system, vehicle, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105577853A (en) * 2016-03-09 2016-05-11 上海斐讯数据通信技术有限公司 Method and device for automatically solving IP network segment conflict
CN105744012A (en) * 2016-03-09 2016-07-06 上海斐讯数据通信技术有限公司 Automatic solving method and device for IP (Internet Protocol) network segment conflicts of multiple WAN (wide area network) and LAN (local area network)
CN106850869A (en) * 2016-12-16 2017-06-13 浙江宇视科技有限公司 The collocation method and the network equipment of a kind of IP address
CN108881178A (en) * 2018-05-29 2018-11-23 网易(杭州)网络有限公司 Method for sending information and device, equipment, storage medium and electronic device

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6895443B2 (en) * 2001-11-02 2005-05-17 Microsoft Corporation Method and system for facilitating communication between nodes on different segments of a network

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105577853A (en) * 2016-03-09 2016-05-11 上海斐讯数据通信技术有限公司 Method and device for automatically solving IP network segment conflict
CN105744012A (en) * 2016-03-09 2016-07-06 上海斐讯数据通信技术有限公司 Automatic solving method and device for IP (Internet Protocol) network segment conflicts of multiple WAN (wide area network) and LAN (local area network)
CN106850869A (en) * 2016-12-16 2017-06-13 浙江宇视科技有限公司 The collocation method and the network equipment of a kind of IP address
CN108881178A (en) * 2018-05-29 2018-11-23 网易(杭州)网络有限公司 Method for sending information and device, equipment, storage medium and electronic device

Also Published As

Publication number Publication date
CN112217913A (en) 2021-01-12

Similar Documents

Publication Publication Date Title
CN110113441B (en) Computer equipment, system and method for realizing load balance
US8737388B2 (en) Method, apparatus and system for processing packets
CN111512611B (en) Design method of MPTCP (Multi-protocol Transmission control protocol) aware load balancer and load balancer using design method
US10862859B2 (en) Highly available DHCP service by running DHCP servers on a blockchain network
JP6715425B2 (en) Device and method for assigning internetwork addresses
US11800587B2 (en) Method for establishing subflow of multipath connection, apparatus, and system
CN111786867B (en) Data transmission method and server
US20140095733A1 (en) Method and device for controlling address configuration mode
CN112217913B (en) Method and device for negotiating IP address
WO2023168287A1 (en) Synchronizing dynamic host configuration protocol snoop information
CN113301144B (en) Concurrent access processing method and device for Nginx server, server and storage medium
CN104780201A (en) Data packet processing method and device for use in IPVS (Internet Protocol Virtual Server) cluster
CN110022383B (en) Address management method and system
WO2023071522A1 (en) Connection establishment method and device, storage medium and electronic device
CN109257227B (en) Coupling management method, device and system in data transmission
CN107659673B (en) equipment communication method, device and system
CN114760242B (en) Migration method and device of virtual router, electronic equipment and storage medium
CN116302618B (en) Session information processing method and device
WO2024131514A1 (en) Built-in session binding support function query method and system
CN116471226A (en) Message processing method and related equipment
CN115514798A (en) Multi-device multi-port connection method, system, electronic device and storage medium
CN115333999A (en) Port-based data transmission device and method, computer equipment and medium
CN114827027A (en) Message processing method and related device
CN115941374A (en) Network sharing method, device and storage medium
EP3085039A1 (en) Allocation of resources during split brain conditions

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