CN117527759A - IP address switching method, device, equipment and storage medium - Google Patents

IP address switching method, device, equipment and storage medium Download PDF

Info

Publication number
CN117527759A
CN117527759A CN202311627905.7A CN202311627905A CN117527759A CN 117527759 A CN117527759 A CN 117527759A CN 202311627905 A CN202311627905 A CN 202311627905A CN 117527759 A CN117527759 A CN 117527759A
Authority
CN
China
Prior art keywords
address
dynamic
static
switching
dhcp
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.)
Pending
Application number
CN202311627905.7A
Other languages
Chinese (zh)
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.)
Shenzhen Fengrunda Technology Co ltd
Original Assignee
Shenzhen Fengrunda Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Fengrunda Technology Co ltd filed Critical Shenzhen Fengrunda Technology Co ltd
Priority to CN202311627905.7A priority Critical patent/CN117527759A/en
Publication of CN117527759A publication Critical patent/CN117527759A/en
Pending legal-status Critical Current

Links

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
    • H04L61/5014Internet protocol [IP] addresses using dynamic host configuration protocol [DHCP] or bootstrap protocol [BOOTP]
    • 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/5046Resolving address allocation conflicts; Testing of addresses
    • 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/5053Lease time; Renewal aspects

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention relates to the field of computer communication, and discloses an IP address switching method, an IP address switching device and a storage medium, wherein the method comprises the following steps: when receiving an IP address acquisition request, acquiring an IP address configuration strategy; when the IP address configuration policy is a static priority configuration policy, acquiring a static IP address, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address; and when the IP address configuration policy is a dynamic priority configuration policy, requesting a dynamic IP address from a DHCP server, and when the dynamic IP address is not leased continuously, switching the dynamic IP address into a static IP address. The method and the device have the advantages that the IP address configuration is intelligently selected and switched according to the network environment, the network stability is improved, and the maintenance workload of a user is reduced.

Description

IP address switching method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer communications, and in particular, to a method, an apparatus, a device, and a storage medium for switching IP addresses.
Background
The existing equipment IP address setting is generally divided into static configuration and dynamic acquisition, and the common dynamic acquisition mode is DHCP. The static configuration is easy to generate address conflict, the dynamic acquisition is also affected by the network, if the DHCP server is abnormal or the connection with the DHCP server is interrupted, the equipment can not acquire the address all the time, so that the network can not be used, in the networking use, whether the network has the DHCP server or not can not be predicted, the condition that the network environment is newly added or removed from the DHCP server, the equipment needs to be subjected to IP address configuration again, the network stability is poor, and the maintenance workload of the user is large.
The foregoing is provided merely for the purpose of facilitating understanding of the technical solutions of the present invention and is not intended to represent an admission that the foregoing is prior art.
Disclosure of Invention
The invention mainly aims to provide an IP address switching method, an IP address switching device, IP address switching equipment and a storage medium, and aims to solve the technical problems of poor network stability and large user maintenance workload in the prior art.
In order to achieve the above object, the present invention provides an IP address switching method, the method comprising:
when receiving an IP address acquisition request, acquiring an IP address configuration strategy;
when the IP address configuration policy is a static priority configuration policy, acquiring a static IP address, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address;
and when the IP address configuration policy is a dynamic priority configuration policy, requesting a dynamic IP address from a DHCP server, and when the dynamic IP address is not leased continuously, switching the dynamic IP address into a static IP address.
Optionally, the static IP address has a conflict, including:
starting a timer, initiating an address resolution request to the network equipment, and judging that the static IP address has conflict when an address resolution protocol response message is detected.
Optionally, before the dynamic IP address is requested to the DHCP server and the static IP address is switched to the dynamic IP address, the method further includes:
starting a timer, initiating a DHCP discovery message, requesting a dynamic IP address from a DHCP server when detecting the DHCP offer message, and switching the static IP address to the dynamic IP address.
Optionally, after the static IP address is switched to the dynamic IP address, the method further includes:
periodically renting the IP;
when the IP lease is failed, switching to the static IP address;
and when the IP lease renews successfully, configuring a dynamic IP address.
Optionally, before the dynamic IP address is requested from the DHCP server, the method further includes:
starting a timer, initiating a DHCP discovery message, and requesting a dynamic IP address from a DHCP server when detecting the DHCP offer message.
Optionally, after the starting the timer and initiating the DHCP discovery message, the method further includes:
when the DHCP offer message is not detected, configuring a static IP address, starting a timer again, and initiating a DHCP discovery message.
Optionally, when the IP address configuration policy is a dynamic priority configuration policy, after requesting a dynamic IP address from the DHCP server, the method further includes:
when the dynamic IP address request fails to the DHCP server, configuring a static IP address;
when the dynamic IP address request from the DHCP server is successful, the dynamic IP address is configured.
In addition, to achieve the above object, the present invention also proposes an IP address switching apparatus, including:
the acquisition module is used for acquiring an IP address configuration strategy when receiving an IP address acquisition request;
the switching module is used for acquiring a static IP address when the IP address configuration policy is a static priority configuration policy, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address;
and the switching module is further used for requesting a dynamic IP address from a DHCP server when the IP address configuration policy is a dynamic priority configuration policy, and switching the dynamic IP address into a static IP address when the dynamic IP address is not leased continuously.
In addition, to achieve the above object, the present invention also proposes an IP address switching apparatus, the apparatus comprising: the system comprises a memory, a processor and an IP address switching program stored on the memory and executable on the processor, the IP address switching program being configured to implement the steps of the IP address switching method as described above.
In addition, in order to achieve the above object, the present invention also proposes a storage medium having stored thereon an IP address switching program which, when executed by a processor, implements the steps of the IP address switching method as described above.
The invention provides a method, a device, equipment and a storage medium for switching IP addresses, wherein the method comprises the following steps: when receiving an IP address acquisition request, acquiring an IP address configuration strategy; when the IP address configuration policy is a static priority configuration policy, acquiring a static IP address, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address; and when the IP address configuration policy is a dynamic priority configuration policy, requesting a dynamic IP address from a DHCP server, and when the dynamic IP address is not leased continuously, switching the dynamic IP address into a static IP address. Compared with the prior art, the invention improves the network stability and reduces the maintenance workload of users.
Drawings
Fig. 1 is a schematic structural diagram of an IP address switching device in a hardware operating environment according to an embodiment of the present invention;
fig. 2 is a flowchart of a first embodiment of an IP address switching method according to the present invention;
fig. 3 is a schematic overall flow chart of a first embodiment of the IP address switching method of the present invention;
fig. 4 is a flowchart of a second embodiment of the IP address switching method of the present invention;
fig. 5 is a flowchart of a third embodiment of an IP address switching method according to the present invention;
fig. 6 is a block diagram showing the structure of the IP address switching device of the present invention.
The achievement of the objects, functional features and advantages of the present invention will be further described with reference to the accompanying drawings, in conjunction with the embodiments.
Detailed Description
It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
Referring to fig. 1, fig. 1 is a schematic structural diagram of an IP address switching device of a hardware running environment according to an embodiment of the present invention.
As shown in fig. 1, the IP address switching apparatus may include: a processor 1001, such as a central processing unit (Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, a memory 1005. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display, an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a Wireless interface (e.g., a Wireless-Fidelity (Wi-Fi) interface). The Memory 1005 may be a high-speed random access Memory (Random Access Memory, RAM) or a stable nonvolatile Memory (NVM), such as a disk Memory. The memory 1005 may also optionally be a storage device separate from the processor 1001 described above.
Those skilled in the art will appreciate that the architecture shown in fig. 1 is not limiting of the IP address switching device and may include more or fewer components than shown, or may combine certain components, or may be a different arrangement of components.
As shown in fig. 1, an operating system, a network communication module, a user interface module, and an IP address switching program may be included in the memory 1005 as one type of storage medium.
In the IP address switching apparatus shown in fig. 1, the network interface 1004 is mainly used for data communication with a network server; the user interface 1003 is mainly used for data interaction with a user; the processor 1001 and the memory 1005 in the IP address switching apparatus of the present invention may be disposed in the IP address switching apparatus, and the IP address switching apparatus invokes an IP address switching program stored in the memory 1005 through the processor 1001 and executes the IP address switching method provided by the embodiment of the present invention.
An embodiment of the present invention provides an IP address switching method, and referring to fig. 2, fig. 2 is a schematic flow chart of a first embodiment of the IP address switching method of the present invention.
In this embodiment, the IP address switching method includes the following steps:
step S10: when receiving an IP address acquisition request, acquiring an IP address configuration strategy;
it should be noted that, the execution body of the method of this embodiment is a server or a gateway.
It is appreciated that under some specific network configuration systems, intelligent switching using dynamic IP addresses and static IP addresses may implement some specific functions and requirements. The following are examples of some network configuration systems that may require intelligent switching using dynamic IP addresses and static IP addresses: mobile network system, enterprise network system, and multi-network access system.
IP address acquisition requests typically occur in network communications for the purpose of acquiring the IP address of the device sending the request for statistical analysis, security auditing, access control, authentication, network traffic management, troubleshooting, and the like. By acquiring the IP address, network communications can be better managed and optimized.
It should be understood that the IP address configuration policies are classified into static priority configuration policies and dynamic priority configuration policies.
Static priority configuration policies refer to configuration in the network using static IP addresses first, and if no static IP addresses are available, then dynamic IP addresses. The static IP address is a fixed IP address which is manually designated and allocated, and is suitable for equipment which needs to use the same IP address for a long time. The advantage of static IP addresses is high stability, easy management and fast response. However, static IP addresses require manual configuration, occupy IP address resources, and are disadvantageous for mobile devices and the like that require frequent network replacement.
Dynamic priority configuration policies refer to configuration in the network using dynamic IP addresses first, and static IP addresses if no dynamic IP addresses are available. The dynamic IP address is an IP address automatically allocated by a Dynamic Host Configuration Protocol (DHCP) server, and is suitable for equipment needing flexible IP address allocation and management. The advantages of dynamic IP addresses are saving IP addresses, easy management and allowing devices to switch between different IP addresses quickly. However, dynamic IP addresses are more time-limited and may cause network connection interruption or delay in reassignment.
By combining the static priority configuration strategy and the dynamic priority configuration strategy, the requirements of different devices and network environments can be flexibly met. The combination mode can improve the utilization rate of IP address resources and the flexibility of network management while ensuring the stability of the network and the uniqueness of the equipment.
In a specific implementation, when receiving an IP address acquisition request, a server or gateway acquires a static priority or dynamic priority configuration policy selected by a user.
Step S20: when the IP address configuration policy is a static priority configuration policy, acquiring a static IP address, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address;
it is understood that a static IP address is a fixed IP address assigned to a user by a network service provider (ISP) at installation time. It is a fixed, unchanged IP address that will remain unchanged unless an administrator manually changes or a network service provider reassigns it. Static IP addresses are typically used for services or functions that require stable connections, such as websites, servers, etc.
The dynamic IP address is an IP address automatically acquired when the network is connected, so that the user can normally surf the Internet. Each time the network is connected, a dynamic IP address is automatically assigned to the user and may change each time the network is reconnected. The dynamic IP address is generally used in the scenes such as the inside of a local area network or a small enterprise network, and has lower requirement on security.
Static IP addresses typically require the application of purchases from the network service provider and follow an associated documenting process. The network service provider may assign a fixed IP address to the user, along with corresponding subnet mask and gateway information. The user needs to manually set the configuration information of the static IP addresses in the network configuration interface of the device so as to directly connect to the internet without acquiring the IP addresses.
To obtain the dynamic IP address, the device automatically sends a DHCP Discover message to a DHCP server in the network, requesting the IP address in a broadcast manner. After receiving the DHCP Discover message, the DHCP server selects an IP address from the available IP address pool, and sends a DHCP Offer message to the device to provide the available IP address. After receiving the DHCP Offer message, the device sends a DHCP Request message to the DHCP server, and confirms the IP address provided by the reception. After receiving the DHCP Request message, the DHCP server sends a DHCP Acknowledgement (ACK) message to the device, and confirms the IP address allocated to the device. After receiving the DHCP acknowledgement message, the device performs network communication using the allocated IP address.
It should be noted that a static IP address conflict refers to two or more devices being configured to use the same static IP address. To determine if there is a conflict in static IP addresses, the following steps may be taken:
checking other devices in the network: first, it is checked whether other devices in the network use the same static IP address. Such information may be obtained by looking at the network settings of the device or communicating with a network administrator.
Attempting a ping command: network connections with specific IP addresses may be tested using ping commands. In the command prompt or terminal window, a ping command is entered followed by the IP address to be tested. If there is an IP address collision, the ping command may display a connection timeout or other error message.
Checking network connection problems: this may be due to IP address collision if the device fails to connect properly to the network or other network connection problems occur. In this case, it may be attempted to change the static IP address of the device and check if the problem is resolved.
Using IP collision detection tools: there are tools that can help detect and resolve IP address collision problems. These tools can scan the network and identify devices with the same IP address. You can search and find IP conflict detection tools on the internet that fit your operating system and network environment.
In a specific implementation, when the current IP address configuration mode is static priority in a network configuration interface, firstly, using a static IP address configured by a user, periodically detecting whether static IP address conflict exists, if so, initiating a DHCP request to a DHCP server to acquire a dynamic address, and switching the static IP address to the dynamic IP address.
Step S30: and when the IP address configuration policy is a dynamic priority configuration policy, requesting a dynamic IP address from a DHCP server, and when the dynamic IP address is not leased continuously, switching the dynamic IP address into a static IP address.
In a specific implementation, under a dynamic priority configuration strategy, a DHCP request is initiated to acquire a dynamic address, the IP is leased periodically after being successfully acquired, and if the IP leasing fails, a static IP address configured by a user is used.
Further, the static IP address has a conflict, including: starting a timer, initiating an address resolution request to the network equipment, and judging that the static IP address has conflict when an address resolution protocol response message is detected.
It is understood that an address resolution request generally refers to a process in which a host or router needs to resolve IP addresses and MAC addresses of other hosts or devices in network communication. This is typically achieved by ARP (address resolution protocol). The ARP protocol is a TCP/IP protocol and its main function is to obtain a physical address from an IP address.
It should be understood that an Address Resolution Protocol (ARP) reply message is a message that is used to reply to an ARP request during address resolution. When a host receives the ARP request message, if finding that the host is the host corresponding to the target IP address in the request message, the host sends an ARP response message and provides the host with the MAC address.
In a specific implementation, a timer is started, an ARP request is initiated to detect the IP message, whether an ARP response message exists or not is detected, and if the IP address conflict is indicated.
Further, before the dynamic IP address is requested to the DHCP server and the static IP address is switched to the dynamic IP address, the method further includes: starting a timer, initiating a DHCP discovery message, requesting a dynamic IP address from a DHCP server when detecting the DHCP offer message, and switching the static IP address to the dynamic IP address.
It should be understood that a DHCP Discover message (DHCP Discover message) is a message used to find a DHCP server in a DHCP (dynamic host configuration protocol) process. When a host needs to acquire network configuration information such as an IP address, it sends a broadcast DHCP discover message to discover a DHCP server in the network.
It is understood that DHCP Offer message (DHCP Offer message) is a message type in DHCP (dynamic host configuration protocol) process for DHCP server to provide IP address and other configuration information to clients. After receiving the DHCP request message sent by the DHCP client, the DHCP server sends a DHCP offer message as a response if there is an available IP address and configuration information.
In a specific implementation, a timer is started, whether a DHCP Offer message is responded is detected by initiating a DHCP Discover message, if the response indicates that the network has a DHCP server or has a normal link with the DHCP server, and if the network does not have an application indicates that the network has no DHCP server or has an abnormal link with the DHCP server. When the DHCP Offer message responds, a dynamic IP address is requested to a DHCP server, and the static IP address of the equipment is switched to the dynamic IP address.
Further, before the dynamic IP address is requested from the DHCP server, the method further includes: starting a timer, initiating a DHCP discovery message, and requesting a dynamic IP address from a DHCP server when detecting the DHCP offer message.
In a specific implementation, a timer is started, a DHCP Discover message is initiated, whether a DHCP Offer message is responded or not is detected, and when the DHCP Offer message is responded, a dynamic IP address is requested to a DHCP server.
Further, after the starting the timer and initiating the DHCP discovery message, the method further includes: when the DHCP offer message is not detected, configuring a static IP address, starting a timer again, and initiating a DHCP discovery message.
In a specific implementation, when no DHCP Offer message is responded, the static IP address of the device is configured, the timer is started again, and a DHCP Discover message is initiated.
As shown in fig. 3, fig. 3 is a schematic overall flow chart in the first embodiment of the IP address switching method of the present invention, where a client configures a static IP address and selects static priority or dynamic priority, and when the static priority is given, the client configures the static IP address and starts a timer to periodically detect whether there is an IP conflict, if so, continues to detect whether there is a DHCP server, if so, initiates a DHCP request to obtain a dynamic address. And dynamically acquiring the IP and then periodically renting the IP again, and if the IP renting fails, recovering the static IP address configured by the user. This is repeated over and over; when dynamic priority is given, firstly, a periodical device is started to initiate a DHCP server to detect whether a DHCP server exists or not, if so, a DHCP request is initiated to acquire a dynamic address. And dynamically obtaining the IP and then periodically renting the IP again after success, if the IP renting fails, using a static IP address configured by a user, and restarting a periodical device to initiate a DHCP server to detect, so that the process is repeated.
In this embodiment, by adding a priority configuration, it is determined whether static priority or dynamic priority, in the static priority mode, a static IP address is used first, and when there is an IP conflict, a DHCP request is initiated to obtain a dynamic address, and the static IP address is switched to the dynamic IP address. In the dynamic priority mode, a DHCP request is initiated to acquire a dynamic address, the IP is leased periodically after the IP is successfully acquired, and if the IP leasing fails, a static IP address configured by a user is used. The whole operation process is intelligent and efficient, the stability of the network is greatly improved, and the maintenance workload of users is reduced.
Referring to fig. 4, fig. 4 is a flowchart illustrating a second embodiment of an IP address switching method according to the present invention.
Based on the first embodiment, in this embodiment, after the static IP address is switched to the dynamic IP address, the method further includes:
step S201: periodically renting the IP;
when using an IP address allocated by DHCP (dynamic host configuration protocol), the client periodically sends a lease renewal request to the DHCP server to extend the lease period of the IP address. DHCP lease refers to the expiration of the IP address assigned to a client by a DHCP server. When the lease reaches 50% of the validity period, the DHCP client unicast sends a DHCP Request message to the DHCP server, requesting to renew the lease of the IP address. If the server successfully renews lease, it will send DHCP Ack message as response to confirm renewal of IP address. By periodically renting IP, the client can maintain a continuous network connection and avoid network disruption caused by the expiration of the IP address. This is very important for devices that use the network for long periods of time.
Step S202: when the IP lease is failed, switching to the static IP address;
it should be appreciated that there may be a number of reasons for failure of an IP lease renewal, for example: DHCP server failure, network connection problems, IP address conflicts, DHCP configuration errors, and client setup problems.
Step S203: and when the IP lease renews successfully, configuring a dynamic IP address.
In a specific implementation, when the IP lease renewing is successful, the dynamic IP address of the device is configured.
According to the embodiment, the static IP address is periodically leased after being switched to the dynamic IP address, when the IP leasing fails, the static IP address is switched to the static IP address, and when the IP leasing is successful, the dynamic IP address is configured, so that the stability and the safety of the network are ensured.
Referring to fig. 5, fig. 5 is a flowchart illustrating a third embodiment of an IP address switching method according to the present invention.
Based on the first embodiment, in this embodiment, when the IP address configuration policy is a dynamic priority configuration policy, after requesting a dynamic IP address from a DHCP server, the method further includes:
step S301: when the dynamic IP address request fails to the DHCP server, configuring a static IP address;
it should be noted that there may be a plurality of reasons for failure to request a dynamic IP address from a DHCP server, for example: DHCP server configuration problems, network connection problems, IP address conflicts, DHCP server failures, firewalls, or security policies.
Step S302: when the dynamic IP address request from the DHCP server is successful, the dynamic IP address is configured.
In a specific implementation, after the dynamic IP address is successfully requested to the DHCP server, the dynamic IP address allocated by the DHCP server is used for IP configuration.
In the embodiment, the dynamic IP address is requested to the DHCP server, when the dynamic IP address is requested to fail, the static IP address is configured, when the dynamic IP address is requested to succeed, the dynamic IP address distributed by the DHCP server is used for carrying out IP configuration, so that the dynamic IP address can be automatically configured when the dynamic IP address can be acquired, otherwise, the static IP address is configured, IP address conflict is reduced, and network stability is improved.
Referring to fig. 6, fig. 6 is a block diagram showing the structure of the IP address switching device of the present invention.
As shown in fig. 6, the IP address switching apparatus provided in the embodiment of the present invention includes:
an obtaining module 601, configured to obtain an IP address configuration policy when receiving an IP address obtaining request;
a switching module 602, configured to obtain a static IP address when the IP address configuration policy is a static priority configuration policy, and when the static IP address has a conflict, request a dynamic IP address from a DHCP server, and switch the static IP address to the dynamic IP address;
the switching module 602 is further configured to request a dynamic IP address from a DHCP server when the IP address configuration policy is a dynamic priority configuration policy, and switch the dynamic IP address to a static IP address when the dynamic IP address is not leased successfully.
The embodiment obtains the IP address configuration strategy when receiving the IP address obtaining request; when the IP address configuration policy is a static priority configuration policy, acquiring a static IP address, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address; and when the IP address configuration policy is a dynamic priority configuration policy, requesting a dynamic IP address from a DHCP server, and when the dynamic IP address is not leased continuously, switching the dynamic IP address into a static IP address. The IP address configuration can be intelligently selected and switched according to the network environment change, and the maintenance workload of users is reduced.
In an embodiment, the obtaining module 601 is further configured to enable a timer, initiate an address resolution request to a network device, and determine that the static IP address has a conflict when an address resolution protocol response packet is detected.
In an embodiment, the switching module 602 is further configured to enable a timer, initiate a DHCP discover message, request a dynamic IP address from a DHCP server when detecting a DHCP offer message, and switch the static IP address to the dynamic IP address.
In an embodiment, the switching module 602 is further configured to periodically renew the IP;
when the IP lease is failed, switching to the static IP address;
and when the IP lease renews successfully, configuring a dynamic IP address.
In an embodiment, the switching module 602 is further configured to enable a timer, initiate a DHCP discover message, and request a dynamic IP address from a DHCP server when detecting a DHCP offer message.
In an embodiment, the switching module 602 is further configured to configure a static IP address and restart the timer when the DHCP offer message is not detected, and initiate a DHCP discover message.
In an embodiment, the switching module 602 is further configured to configure a static IP address when the dynamic IP address request from the DHCP server fails;
when the dynamic IP address request from the DHCP server is successful, the dynamic IP address is configured.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The foregoing embodiment numbers of the present invention are merely for the purpose of description, and do not represent the advantages or disadvantages of the embodiments.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product stored in a storage medium (e.g. read-only memory/random-access memory, magnetic disk, optical disk), comprising instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the method according to the embodiments of the present invention.
The foregoing description is only of the preferred embodiments of the present invention, and is not intended to limit the scope of the invention, but rather is intended to cover any equivalents of the structures or equivalent processes disclosed herein or in the alternative, which may be employed directly or indirectly in other related arts.

Claims (10)

1. An IP address switching method, the method comprising:
when receiving an IP address acquisition request, acquiring an IP address configuration strategy;
when the IP address configuration policy is a static priority configuration policy, acquiring a static IP address, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address;
and when the IP address configuration policy is a dynamic priority configuration policy, requesting a dynamic IP address from a DHCP server, and when the dynamic IP address is not leased continuously, switching the dynamic IP address into a static IP address.
2. The IP address switching method of claim 1, wherein said static IP address has a conflict, comprising:
starting a timer, initiating an address resolution request to the network equipment, and judging that the static IP address has conflict when an address resolution protocol response message is detected.
3. The IP address switching method of claim 1, wherein before requesting a dynamic IP address from the DHCP server and switching the static IP address to the dynamic IP address, further comprising:
starting a timer, initiating a DHCP discovery message, requesting a dynamic IP address from a DHCP server when detecting the DHCP offer message, and switching the static IP address to the dynamic IP address.
4. The IP address switching method of claim 1, wherein after said switching said static IP address to said dynamic IP address, further comprising:
periodically renting the IP;
when the IP lease is failed, switching to the static IP address;
and when the IP lease renews successfully, configuring a dynamic IP address.
5. The IP address switching method of claim 1, wherein before the dynamic IP address is requested from the DHCP server, further comprising:
starting a timer, initiating a DHCP discovery message, and requesting a dynamic IP address from a DHCP server when detecting the DHCP offer message.
6. The IP address switching method of claim 5, wherein after the enabling the timer and initiating the DHCP discover message, further comprising:
when the DHCP offer message is not detected, configuring a static IP address, starting a timer again, and initiating a DHCP discovery message.
7. The IP address switching method of claim 1, wherein when the IP address configuration policy is a dynamic priority configuration policy, after requesting a dynamic IP address from a DHCP server, further comprising:
when the dynamic IP address request fails to the DHCP server, configuring a static IP address;
when the dynamic IP address request from the DHCP server is successful, the dynamic IP address is configured.
8. An IP address switching apparatus, comprising:
the acquisition module is used for acquiring an IP address configuration strategy when receiving an IP address acquisition request;
the switching module is used for acquiring a static IP address when the IP address configuration policy is a static priority configuration policy, requesting a dynamic IP address from a DHCP server when the static IP address has conflict, and switching the static IP address into the dynamic IP address;
and the switching module is further used for requesting a dynamic IP address from a DHCP server when the IP address configuration policy is a dynamic priority configuration policy, and switching the dynamic IP address into a static IP address when the dynamic IP address is not leased continuously.
9. An IP address switching apparatus, the apparatus comprising: a memory, a processor and an IP address switching program stored on the memory and executable on the processor, the IP address switching program being configured to implement the steps of the IP address switching method of any one of claims 1 to 7.
10. A storage medium having stored thereon an IP address switching program which, when executed by a processor, implements the steps of the IP address switching method according to any one of claims 1 to 7.
CN202311627905.7A 2023-11-29 2023-11-29 IP address switching method, device, equipment and storage medium Pending CN117527759A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311627905.7A CN117527759A (en) 2023-11-29 2023-11-29 IP address switching method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311627905.7A CN117527759A (en) 2023-11-29 2023-11-29 IP address switching method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117527759A true CN117527759A (en) 2024-02-06

Family

ID=89743622

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311627905.7A Pending CN117527759A (en) 2023-11-29 2023-11-29 IP address switching method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117527759A (en)

Similar Documents

Publication Publication Date Title
US9756052B2 (en) Method and apparatus for dual stack access
EP2919444B1 (en) Method, relay device, and system for acquiring internet protocol address in network
US9344397B2 (en) Client aware DHCP lease management
US8230067B2 (en) DHCP proxy in a subscriber environment
US6195706B1 (en) Methods and apparatus for determining, verifying, and rediscovering network IP addresses
US20100223655A1 (en) Method, System, and Apparatus for DHCP Authentication
US10142159B2 (en) IP address allocation
JP2008028914A (en) Device and method for reducing communication load, and program
AU6767398A (en) User-based binding of network stations to broadcast domains
EP2888863B1 (en) Method and apparatus for configuring dhcp client
US10979360B2 (en) Resource obtaining method and apparatus
EP2658206B1 (en) Ip address configuration method, device and system
US20040039821A1 (en) Method and apparatus for automatic IP allocation bootstrapping of embedded network management cards used in networked uninterruptible power supplies and other supported devices
WO2021135795A1 (en) Message processing method, relay device, system, and storage medium
US20150229520A1 (en) Network monitoring system, communication device, network management method
US7529815B2 (en) Methods and apparatus supporting configuration in a network
JP6445408B2 (en) Communication system and setting method
US20080201477A1 (en) Client side replacement of DNS addresses
CN117527759A (en) IP address switching method, device, equipment and storage medium
KR101124748B1 (en) Apparatus for establishing network and Method thereof
US20140344449A1 (en) Ip address allocation for wi-fi clients
EP3273666A1 (en) Method and apparatus for configuring network parameters of local area network
CN108667944B (en) DHCP configuration method and DHCP client
KR100513296B1 (en) Apparatus, system and method for controlling network access
US20240314103A1 (en) Detection and solution of misdirected domain name system requests

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