IP address management method and computing device
By monitoring the status of virtual machines and setting reserved IP addresses, the problem of low IP address allocation efficiency of DHCP servers in dynamic network environments is solved, stable management of virtual machine IP addresses is achieved, and resource waste and business interruption are avoided.
Patent Information
- Application Number
- CN202510902722.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-30
- Publication Date
- 2025-10-28
AI Technical Summary
Traditional DHCP servers are inefficient in allocating IP addresses in dynamic network environments, waste resources, and lack flexibility, leading to changes in virtual machine IP addresses and impacting business stability.
Monitor the running status of the virtual machine, set a reserved IP to avoid repeated IP allocation, and ensure that the IP does not change during the life cycle of the virtual machine by establishing a mapping relationship and dynamic IP resource pool management.
This effectively avoids service interruptions caused by changes in virtual machine IPs, reduces resource waste, and improves the accuracy and efficiency of IP address management.
Smart Images

Figure CN120856684A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an IP address management method and computing device. Background Art
[0002] In traditional networks, the allocation and management of Internet Protocol (IP) addresses by Dynamic Host Configuration Protocol (DHCP) servers have significant limitations in dynamic network environments, such as low allocation efficiency, resource waste, and lack of flexibility.
[0003] Therefore, developing an accurate and efficient IP address management method is of particular importance. Summary of the Invention
[0004] This application provides an IP address management method and computing device. When a virtual machine enters a target state, the virtual machine's IP address is set to a reserved IP address to avoid communication conflicts and data packet loss caused by repeated IP address allocation. This allows for accurate and efficient management of IP addresses and reduces resource waste.
[0005] To achieve the above objectives, the embodiments of this application adopt the following technical solutions:
[0006] Firstly, an IP address management method is provided, the method including:
[0007] Obtain the running status of the first virtual machine;
[0008] When the first virtual machine enters the target state, its IP address is set to a reserved IP address; the target state represents a non-running state; the reserved IP address indicates that it cannot be assigned to the second virtual machine; the second virtual machine refers to any virtual machine other than the first virtual machine.
[0009] The reserved IP address is sent to the Dynamic Host Configuration Protocol (DHCP) server.
[0010] As can be seen, in this embodiment, the running status of the virtual machine is monitored. When the virtual machine enters the target state, the effective IP is set as a reserved IP to prevent it from being assigned to other virtual machines. Therefore, when the virtual machine needs an IP allocation, the bound IP is reassigned to the virtual machine. This avoids changes to the virtual machine's IP due to virtual machine shutdowns and re-launches during its lifecycle, thus preventing any impact on the virtual machine's services.
[0011] In one possible implementation, the method also includes:
[0012] Obtain the effective IP address of the first virtual machine at runtime;
[0013] Establish the first mapping relationship between the effective IP and the first virtual machine.
[0014] As can be seen, in this embodiment, a first mapping relationship is established between the first virtual machine and the effective IP address. Therefore, when the first virtual machine has an IP allocation requirement, the effective IP address bound to it is assigned to each network interface card of the first virtual machine based on the first mapping relationship. This avoids changes to the virtual machine's IP address during its lifecycle, thereby preventing service interruptions and other problems.
[0015] In one possible implementation, the IP address of the first virtual machine is set to a reserved IP address, including:
[0016] If the IP address of the first virtual machine is stored in the dynamic IP resource pool, remove the IP address of the first virtual machine from the dynamic IP resource pool; the dynamic IP resource pool includes IP addresses that can be dynamically allocated.
[0017] Alternatively, add the IP of the first virtual machine to the reserved IP pool, which is used to accommodate IPs in the dynamic IP resource pool that are not allowed to be allocated dynamically.
[0018] As can be seen, by removing the IP address of the first virtual machine from the dynamic IP resource pool or adding it to the reserved IP pool, it is ensured that the IP address of the first virtual machine will not be assigned to other virtual machines. Therefore, when the first virtual machine has an IP allocation requirement, its IP address will be reassigned to it without causing duplicate IP allocation. This ensures that the first virtual machine's business operations are not affected and avoids the problem of duplicate IP allocation.
[0019] In one possible implementation, the method also includes:
[0020] In response to the IP allocation request of the first virtual machine, an effective IP address with a first mapping relationship with the first virtual machine is allocated to the first virtual machine.
[0021] It is evident that when the first virtual machine has an IP allocation requirement, based on the first mapping relationship, the effective IP corresponding to the first virtual machine can be allocated to the first virtual machine, avoiding changes in the IP of the first virtual machine during its life cycle, thereby ensuring the normal operation of the first virtual machine's services.
[0022] One possible implementation method also includes:
[0023] Determine the static IPs among the effective IPs; static IPs refer to IPs assigned using a static allocation method;
[0024] Obtain the port configuration information of the target network interface card; the target network interface card is the virtual network interface card with a static IP address in the first virtual machine.
[0025] Based on the port configuration information, if it is determined that the target network card has an inactive dynamic IP, the inactive dynamic IP will be reclaimed.
[0026] As can be seen, in this embodiment, when it is determined that the effective IP of the virtual machine is a static IP, the target network interface card corresponding to the static IP is determined, and it is further determined whether there are any inactive dynamic IPs on the target network interface card. If so, they are reclaimed. This allows inactive dynamic IPs to be reclaimed into the dynamic IP resource pool, which can then be used for dynamic allocation, reducing the waste of network resources.
[0027] In one possible implementation, the port configuration information includes a dynamic IP field, which records the dynamic IP address assigned to the target network interface card (NIC). Based on the port configuration information, it is determined whether the target NIC has an inactive dynamic IP address, including:
[0028] If the dynamic IP field records a dynamic IP, it indicates that the target network card has an inactive dynamic IP.
[0029] As can be seen, determining whether there are inactive dynamic IPs in the target network card based on the dynamic IP field of the port configuration information can accurately identify whether there are inactive dynamic IPs in the target network card, laying the foundation for subsequent IP recycling.
[0030] One possible implementation involves reclaiming the inactive dynamic IP address, including:
[0031] Remove the dynamic allocation flag from the port configuration information. The presence of the dynamic allocation flag indicates that the Dynamic Host Configuration Protocol (DHCP) server is in effect, which assigns dynamic IP addresses to the target network card.
[0032] Unused dynamic IPs will be recycled to the dynamic IP resource pool.
[0033] As can be seen in this embodiment, when an invalid dynamic IP is detected on the target network card, the dynamic allocation flag of the target network card is removed, rendering the DHCP server's function of allocating dynamic IPs to the target network card ineffective, and then the invalid dynamic IP is reclaimed. This avoids the DHCP server reallocating dynamic IPs to the target network card after reclaiming invalid dynamic IPs. Furthermore, the invalid dynamic IPs are returned to the dynamic IP resource pool, allowing them to be reused and reducing the waste of network resources.
[0034] One possible implementation method also includes:
[0035] In response to the fulfillment of the first condition, the effective IP is set as a reserved IP; the first condition is used to indicate that the dynamic IP allocation mechanism of the Dynamic Host Configuration Protocol (DHCP) server is not functioning properly; the DHCP server is used to assign dynamic IPs to newly created virtual machines.
[0036] As can be seen, in this embodiment, when the dynamic allocation mechanism of the DHCP server fails to function properly, the effective IP is set as a reserved IP. Furthermore, after each time the DHCP server is shut down, the effective IPs of each virtual machine are counted, and the counted effective IPs are added to the reserved IP pool to avoid duplicate IP allocation in extreme scenarios, which could lead to communication conflicts, packet loss, and other problems.
[0037] One possible implementation method also includes:
[0038] In response to the switch from satisfying the first condition to satisfying the second condition, a dynamic allocation identifier is configured for the third virtual machine so that the DHCP server allocates a dynamic IP to the third virtual machine based on the dynamic allocation identifier; wherein, the second condition is used to indicate that the dynamic IP allocation mechanism of the DHCP server has resumed normal operation; the third virtual machine is a virtual machine newly created during the period when the first condition is satisfied.
[0039] As can be seen in this embodiment, when a third virtual machine is created during the shutdown period of the DHCP server, a dynamic allocation identifier is configured for the third virtual machine. This enables the DHCP server to properly allocate a dynamic IP address to the third virtual machine when the dynamic IP allocation mechanism resumes normal operation. Therefore, it ensures that virtual machines created during the period from shutdown to restart of the DHCP server's dynamic IP allocation mechanism can also be allocated dynamic IP addresses, which helps improve the accuracy of IP address management.
[0040] In one possible implementation, the non-running state indicates that the first virtual machine is in a non-running business state, and is in a non-migrating and non-HA synchronization state.
[0041] Secondly, an IP address management device is provided, comprising: functional units for executing any of the methods provided in the first aspect, wherein the actions performed by each functional unit are implemented by hardware or by hardware executing corresponding software. For example, the IP address management device may include: an acquisition unit for acquiring the running state of a first virtual machine; a first processing unit for setting the IP address of the first virtual machine to a reserved IP address when the first virtual machine enters a target state; the target state represents a non-running state; the reserved IP address represents an IP address that is not allowed to be assigned to a second virtual machine; the second virtual machine represents any virtual machine other than the first virtual machine; and a second processing unit for sending the reserved IP address to a Dynamic Host Configuration Protocol (DHCP) server.
[0042] Thirdly, a computing device is provided, comprising: a processor and a memory; the processor being coupled to the memory; the memory being used for computer program instructions; and the processor being used to invoke the computer program instructions in the memory to cause the computing device to perform any of the methods provided in the first aspect above.
[0043] Fourthly, a computer-readable storage medium is provided, storing computer-executable instructions that, when executed on a computing device, cause the computing device to perform any of the methods provided in the first aspect above.
[0044] Fifthly, a computer program product is provided, comprising: computer execution instructions, which, when executed on a computing device, cause the computing device to perform any of the methods provided in the first aspect above.
[0045] The technical effects of any of the implementation methods in aspects two through five can be found in the technical effects of different implementation methods in aspect one, and will not be repeated here. Attached Figure Description
[0046] Figure 1 A schematic diagram of the system architecture for an exemplary application scenario of the IP address management method provided in the embodiments of this application;
[0047] Figure 2 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application;
[0048] Figure 3 A flowchart illustrating an IP address management method provided in an embodiment of this application;
[0049] Figure 4 A flowchart illustrating another IP address management method provided in an embodiment of this application;
[0050] Figure 5 A schematic diagram illustrating the port configuration information of the target network card provided in an embodiment of this application;
[0051] Figure 6 Another schematic diagram illustrating the port configuration information of the target network card provided in this application embodiment;
[0052] Figure 7 A flowchart illustrating another IP address management method provided in an embodiment of this application;
[0053] Figure 8 A schematic diagram of the system architecture for another exemplary application scenario of the IP address management method provided in the embodiments of this application;
[0054] Figure 9This is a possible schematic diagram of an IP address management device provided in an embodiment of this application. Detailed Implementation
[0055] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0056] In the description of this application, unless otherwise stated, " / " indicates that the objects before and after are in an "or" relationship. For example, A / B can mean A or B. "And / or" in this application is merely a description of the relationship between the related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. A and B can be singular or plural.
[0057] Furthermore, in the description of this application, unless otherwise stated, "multiple" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple.
[0058] Furthermore, to facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and that "first" and "second" are not necessarily different. Meanwhile, in the embodiments of this application, the terms "exemplary" or "for example" are used to indicate that something is being used as an example, illustration, or description. Any embodiment or design scheme described as "exemplary" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of terms such as "exemplary" or "for example" is intended to present related concepts in a concrete manner for ease of understanding.
[0059] The following is a brief introduction to the relevant terms used in the embodiments of this application.
[0060] Hyperconvergence is an information technology (IT) infrastructure architecture that integrates multiple components such as computing, storage, networking, and virtual machines into a single, easily managed system, upon which more applications and services can be added. Hyperconverged infrastructure consists of multiple nodes, each with computing, storage, and networking capabilities. These nodes are clustered together using software-defined virtualization technology and can scale to hundreds of nodes. Hyperconverged infrastructure typically utilizes advanced software-defined technologies such as virtualization, software-defined storage (SDS), and software-defined networking (SDN) to achieve high levels of automation and scalability.
[0061] A DHCP server is used to automatically assign IP addresses and other network configuration parameters to devices in a network. Its core function is to dynamically assign network configuration parameters to clients through automated and centralized management, simplifying network deployment and maintenance.
[0062] Dynamic IP refers to a temporary IP address automatically assigned to a device by a DHCP server on the network. Each time a device connects to the network, it may obtain a different IP address.
[0063] A static IP address is an IP address that a user manually sets and assigns to a device after entering the virtual machine. It will not change due to network restarts or device reconnection.
[0064] The following provides an exemplary description of the application scenarios of the embodiments of this application.
[0065] This application's embodiments can be applied to hyperconverged architectures, specifically for managing the IP addresses of virtual machines within a hyperconverged architecture. A hyperconverged architecture includes a virtual machine management platform, a DHCP server, and virtual machines, among other things.
[0066] In a hyperconverged architecture, after a virtual machine management platform creates a virtual machine, it assigns a dynamic IP address to the virtual machine via a DHCP server, or assigns a static IP address to the virtual machine in response to a user manually creating an IP address.
[0067] After a virtual machine is taken offline, the DHCP server may reclaim the IP address that was assigned to the virtual machine. When the virtual machine comes back online, a new IP address will be assigned. Since the change of the virtual machine's IP address may affect business operations, such as causing business interruption or production accidents, it may also have an impact.
[0068] In view of this, this application provides an IP address management method, the inventive concept of which is: firstly, binding the effective IP address of a virtual machine to the virtual machine during runtime; secondly, setting the effective IP address as a reserved IP address to prevent it from being assigned to other virtual machines. When a virtual machine needs an IP address, the bound IP address is reassigned to the virtual machine. This avoids changes to the virtual machine's IP address during its lifecycle due to virtual machine shutdowns and restarts.
[0069] Figure 1 This is a schematic diagram of the system architecture for an exemplary application scenario of the IP address management method provided in the embodiments of this application.
[0070] like Figure 1 As shown, the system architecture 100 may include a virtual machine management platform 101, virtual machines 102, an IP management device 103, and a DHCP server 104. The virtual machine management platform 101 is the management platform for the hyperconverged system architecture. It provides a management page for users and, in response to user actions on the management page, performs operations such as creating virtual machines, instructing virtual machines to power on, and powering off, thereby achieving overall control over the virtual machines 102 in the system architecture 100.
[0071] In this embodiment of the application, the IP management device 103 can execute the IP address management method provided in this embodiment of the application to manage the IP address of the virtual machine.
[0072] The system architecture of the embodiments of this application will be described below as an example.
[0073] Figure 2 This is a schematic diagram of the structure of a computing device provided in an embodiment of this application.
[0074] It needs to be explained that, Figure 2 The system architecture shown is merely illustrative and does not constitute a limitation on the system architecture of the computing device provided in the embodiments of this application.
[0075] In this embodiment, a computing device refers to a hardware system capable of performing data processing, storage, and communication tasks. A server is a computing device specifically designed to provide network services, possessing high reliability, high performance, and scalability, and is typically deployed in data centers or enterprise server rooms. A server can be a single physical server, or two or more physical servers sharing different responsibilities and working together to achieve the various functions of the server.
[0076] For example, the server can be a blade server, a high-density server, a rack server, or a tower server. The terminal device can include a personal digital assistant (PDA), an ultra-mobile personal computer (UMPC), a laptop, a netbook, a desktop computer, an all-in-one computer, etc.
[0077] The hardware of this computing device includes a processor, a basic input / output system (BIOS) chip, an out-of-band controller, and memory. The software primarily includes the BIOS, an out-of-band management module, and an operating system (OS). Figure 2 As shown.
[0078] A processor may include a central processing unit (CPU), which contains one or more CPU cores. All data processing operations of the CPU are performed by the CPU cores. The more CPU cores a CPU contains, the faster it can process data.
[0079] The BIOS chip is a chip located on the motherboard used for initializing and detecting various hardware components during the power-on process of a computing device. The BIOS chip includes a flash memory area.
[0080] The out-of-band management module is located within the out-of-band controller, while the operating system is located within the processor.
[0081] Out-of-band management modules can be management units for non-business modules. For example, an out-of-band management module can remotely maintain and manage computing devices through a dedicated data channel. This out-of-band management module is completely independent of the computing device's operating system and can communicate with the BIOS and operating system through the computing device's out-of-band management interface.
[0082] For example, the out-of-band management module may include a management unit for the operating status of the computing device, a management system in the management chip, a baseboard management controller (BMC), a system management mode (SMM), etc. It should be noted that the specific form of the out-of-band management module is not limited in the embodiments of this application; the above is merely an illustrative example.
[0083] An operating system (OS) is a computer program that manages and controls the hardware and software resources of a computing device. Any other software must run with the support of the operating system. After the computing device is powered on, the BIOS first performs a series of operations such as self-test and initialization, and then boots the OS, allowing the user to use the computing device normally.
[0084] BIOS is a set of programs embedded in the BIOS chip on the motherboard of a computing device. The main function of BIOS is to provide the lowest-level and most direct hardware settings and control for computing devices.
[0085] Memory, also known as internal memory or main memory, is installed in memory slots on the motherboard of a computing device.
[0086] It should be noted that the system architecture and application scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0087] For ease of understanding, the IP address management method provided in the embodiments of this application will be described exemplarily below with reference to the above system architecture and accompanying drawings.
[0088] Figure 3 This is a flowchart illustrating an IP address management method according to an exemplary embodiment. For example, this IP address management method can be applied to a computing device, and the method steps include the following S301-S303.
[0089] S301: Obtain the running status of the first virtual machine.
[0090] In this embodiment of the application, the IP management device can manage the IP addresses of multiple virtual machines at the same time. For ease of understanding, the management of the IP address of the first virtual machine is used as an example. The first virtual machine can be any virtual machine that has established a communication connection with the IP management device.
[0091] In this embodiment, the IP management device can set a scheduled task for monitoring the running status of virtual machines, such as a 15-second scheduled task. When triggered by the scheduled task, the running status of the first virtual machine is detected, and it is determined whether the first virtual machine has entered the target state. It should be noted that each virtual machine can be equipped with multiple network cards, and each network card can correspond to its own IP address. When the first virtual machine contains multiple network cards, obtaining the effective IP address of the first virtual machine during runtime specifically includes: obtaining the effective IP addresses of each network card of the first virtual machine during runtime.
[0092] S302: When the first virtual machine enters the target state, set the IP of the first virtual machine to a reserved IP; the target state represents a non-running state; the reserved IP indicates that it is not allowed to be assigned to the second virtual machine; the second virtual machine refers to any virtual machine other than the first virtual machine.
[0093] In this embodiment of the application, when the first virtual machine enters a non-running state, the IP address assigned to it may be reclaimed by the DHCP server and assigned to other virtual machines. Therefore, when the first virtual machine is detected to have entered the target state, the IP address of the first virtual machine is set to a reserved IP address.
[0094] Non-running states can include shutdown and hibernation states. For example, when the first virtual machine is detected to be in a shutdown or hibernation state, the IP address on the underlying logical switch port of the first virtual machine may be reclaimed by the DHCP server, and at this time, the IP address is set as a reserved IP address.
[0095] In some embodiments of this application, the non-running state indicates that the first virtual machine is in a non-running service state and is in a state of non-migration and non-high availability (HA) synchronization.
[0096] Specifically, when the first virtual machine is not running any services, the IP address on its underlying logical switch port may be reclaimed by the DHCP server, but there are some exceptions. For example, if the first virtual machine is in a migration or HA synchronization state and is not running any services, the IP address on its underlying logical switch port will not change. Therefore, in such cases, it is not necessary to set the IP address of the first virtual machine as a reserved IP address.
[0097] HA is an automated mechanism that, when the host (physical server) running virtual machines fails, restarts the affected virtual machines on other healthy hosts within the cluster, thereby restoring service.
[0098] Virtual machine migration refers to the process of moving a running virtual machine from one physical host to another.
[0099] When the first virtual machine is in a migration or HA synchronization state, it is not necessary to set the IP of the first virtual machine as a reserved IP.
[0100] In this embodiment of the application, setting the effective IP as a reserved IP means setting the effective IP as an IP that cannot be assigned to other virtual machines.
[0101] In some embodiments of this application, setting the effective IP as a reserved IP may specifically include: removing the IP of the first virtual machine from the dynamic IP resource pool when the IP of the first virtual machine is stored in the dynamic IP resource pool; the dynamic IP resource pool includes IPs that can be allocated dynamically; or, adding the IP of the first virtual machine to the reserved IP pool, the reserved IP pool being used to accommodate IPs in the dynamic IP resource pool that are not allowed to be allocated dynamically.
[0102] Specifically, the dynamic IP resource pool can be pre-configured and includes multiple IPs that can be dynamically allocated. When the DHCP server assigns a dynamic IP to a virtual machine, it selects an IP from the dynamic IP resource pool for allocation.
[0103] In this embodiment, setting the IP address of the first virtual machine as a reserved IP address can be achieved by removing the active IP address from the dynamic IP resource pool. For example, the IP address of the first virtual machine can be removed from the dynamic IP resource pool. Alternatively, a label can be set on the IP address of the first virtual machine to indicate that the IP address of the first virtual machine is not allowed to be dynamically allocated. Accordingly, when the DHCP server allocates a dynamic IP address to the virtual machine, it avoids the IP addresses of the first virtual machine with the aforementioned label in the dynamic IP resource pool.
[0104] Therefore, even if the IP of the first virtual machine has been recycled into the dynamic IP resource pool, the IP of the first virtual machine is not allowed to be assigned as a dynamic IP to other virtual machines besides the first virtual machine.
[0105] In this embodiment, setting the IP address of the first virtual machine as a reserved IP address can be achieved by adding the IP address of the first virtual machine to a reserved IP address pool. The reserved IP address pool is used to hold IP addresses from the dynamic IP address pool that are not allowed to be dynamically allocated. For example, a scheduled task can be set up to periodically add the IP address of the first virtual machine to the reserved IP address pool.
[0106] For example, after adding the IP of the first virtual machine to the reserved IP pool, when the DHCP server assigns a dynamic IP to the virtual machine, it selects an IP from the dynamic IP resource pool and further determines whether the selected IP belongs to the reserved IP pool. If it does, the IP is not allowed to be dynamically assigned, and an IP needs to be selected again from the dynamic IP resource pool.
[0107] As can be seen, by removing the IP address of the first virtual machine from the dynamic IP resource pool or adding it to the reserved IP pool, it is ensured that the IP address of the first virtual machine will not be assigned to other virtual machines. Therefore, when the first virtual machine has an IP allocation requirement, its IP address will be reassigned to it without causing duplicate IP allocation. This ensures that the first virtual machine's business operations are not affected and avoids the problem of duplicate IP allocation.
[0108] S303: Send the reserved IP address to the Dynamic Host Configuration Protocol (DHCP) server.
[0109] Specifically, when the IP management device determines that the first virtual machine has entered the target state, it will reserve the IP address and send it to the Dynamic Host Configuration Protocol (DHCP) server to ensure that the IP address of the first virtual machine will not be assigned to other virtual machines after entering the target state.
[0110] In this embodiment of the application, when the first virtual machine has an IP allocation requirement, in response to the IP allocation requirement of the first virtual machine, the IP management device allocates an IP corresponding to the first virtual machine.
[0111] As can be seen, in this embodiment, the running status of the virtual machine is monitored. When the virtual machine enters the target state, the effective IP is set as a reserved IP to prevent it from being assigned to other virtual machines. Therefore, when the virtual machine needs an IP allocation, the bound IP is reassigned to the virtual machine. This avoids changes to the virtual machine's IP due to virtual machine shutdowns and re-launches during its lifecycle, thus preventing any impact on the virtual machine's services.
[0112] In some embodiments of this application, the method further includes: obtaining the effective IP address of the first virtual machine during runtime; and establishing a first mapping relationship between the effective IP address and the first virtual machine.
[0113] Specifically, the first mapping relationship represents the binding relationship between the first virtual machine and the effective IP address corresponding to the first virtual machine.
[0114] It's understandable that an effective IP address refers to the IP address that a virtual machine actually uses for network communication at a specific moment and that can be accessed externally. Static IP addresses that have already been configured in the system and dynamic IP addresses assigned by a DHCP server are not necessarily effective IP addresses. Only IP addresses that are actually functioning on the network are considered effective IP addresses.
[0115] For example, a scheduled task can be set up to obtain the effective IP address of a virtual machine, such as a 15-second scheduled task. That is, every 15 seconds, triggered by the scheduled task, the effective IP address of each virtual machine at runtime is obtained. Specifically, this may include the following steps:
[0116] 1: Determine the effective IP address for each network interface card (NIC) of each virtual machine.
[0117] 2: Obtain the IP address dynamically assigned by the DHCP server from the effective IP addresses, and use it as the dynamic IP address.
[0118] 3: Remove dynamic IPs from the effective IPs, leaving only static IPs.
[0119] 4: Merge dynamic IPs and static IPs into used IPs and save them to the used IPs table.
[0120] Among them, the used IPs represent IPs that are being used normally by the network cards of the virtual machine; the used IPs table is used to persistently store the IP addresses of used IPs to prevent communication abnormalities caused by the loss of IP addresses.
[0121] It is understood that the aforementioned scheduled tasks for monitoring the running status of virtual machines and the scheduled tasks for obtaining the effective IP of virtual machines can be executed separately or synchronously, and this application embodiment does not limit this.
[0122] In this embodiment of the application, a first mapping relationship is established between the effective IP and the first virtual machine. Further, when the first virtual machine contains multiple network cards, a correspondence relationship is established between each network card of the first virtual machine and the effective IP.
[0123] For example, the first mapping relationship can be a network interface card (NIC) table, which is a table that records information related to NICs. The NIC table can record the relationships between multiple virtual machines and the effective IPs corresponding to the NICs within each virtual machine. Based on the first mapping relationship, the effective IP can be bound to the first virtual machine.
[0124] As can be seen, a primary mapping relationship is established between the first virtual machine and its effective IP address. Therefore, when the first virtual machine requires IP address allocation, the corresponding effective IP address is assigned to each network interface card (NIC) of the first virtual machine based on this primary mapping relationship. This prevents the virtual machine's IP address from changing during its lifecycle, thereby avoiding service interruptions and other issues.
[0125] In some embodiments of this application, the method further includes: in response to the IP allocation request of the first virtual machine, allocating an effective IP address that has a first mapping relationship with the first virtual machine to the first virtual machine.
[0126] Among them, IP allocation requirement represents the need for the first virtual machine to reacquire an IP address during its lifecycle, that is, it does not include the need to acquire an IP address when the first virtual machine is created.
[0127] The virtual machine lifecycle refers to the complete process from its creation to its deletion, which may include multiple stages such as running, pausing, suspending, and shutting down. The running stage indicates that the virtual machine is providing services normally; the pausing and suspending stages indicate that the virtual machine saves its current state to disk and releases resources; the shutdown stage indicates that the operating system shuts down normally, and the virtual machine's state is preserved.
[0128] In this embodiment, when the first virtual machine has an IP allocation requirement, the IP management device reallocates a valid IP address for the first virtual machine according to the first mapping relationship. This ensures that the valid IP address corresponding to the first virtual machine does not change throughout its lifecycle.
[0129] For example, when the first virtual machine is created, logical switch ports corresponding to the number of network cards in the first virtual machine are automatically created according to the virtual machine configuration template, and a unique identifier is generated for each port. The DHCP server identifies the identifiers in the ports of each network card of the first virtual machine and assigns dynamic IPs from the dynamic IP resource pool to each network card of the first virtual machine. At this time, the management platform sends an IP reporting message to the IP management device. The IP reporting message includes the dynamic IPs assigned to each network card by the DHCP server, thereby determining that the dynamic IP is an effective IP.
[0130] It is evident that when the first virtual machine has an IP allocation requirement, based on the first mapping relationship, the effective IP corresponding to the first virtual machine can be allocated to the first virtual machine, avoiding changes in the IP of the first virtual machine during its life cycle, thereby ensuring the normal operation of the first virtual machine's services.
[0131] See Figure 4 As a possible implementation of this application embodiment, the above method may further include:
[0132] S401: Determine the static IPs among the effective IPs; static IPs refer to IPs assigned using a static allocation method.
[0133] In this step, if the effective IP address was assigned statically, then the effective IP address is determined to be a static IP address. For example, by removing dynamic IP addresses from the effective IP addresses, the remaining IP addresses can be determined to be static IP addresses.
[0134] S402: Obtain the port configuration information of the target network card; the target network card is the virtual network card with a static IP address in the first virtual machine.
[0135] Specifically, if the effective IP is determined to be a static IP, the virtual network interface card (NIC) of the first virtual machine corresponding to the effective IP is identified as the target NIC, and then the port configuration information of the target NIC is obtained. This port configuration information includes a dynamic IP field, which records the dynamic IP assigned to the target NIC.
[0136] S403: Based on port configuration information, if it is determined that the target network card has an inactive dynamic IP, reclaim the inactive dynamic IP.
[0137] Specifically, the system identifies whether the target network card has any inactive dynamic IPs by checking the port configuration information. If so, the inactive dynamic IPs are reclaimed.
[0138] For example, a scheduled task can also be set up to reclaim inactive IPs, such as a 1-hour scheduled task. That is, every hour, when triggered by this scheduled task, the above steps S401-S403 are executed to reclaim inactive dynamic IPs.
[0139] As can be seen, in this embodiment, when it is determined that the effective IP of the virtual machine is a static IP, the target network interface card corresponding to the static IP is determined, and it is further determined whether there are any inactive dynamic IPs on the target network interface card. If so, they are reclaimed. This allows inactive dynamic IPs to be reclaimed into the dynamic IP resource pool, which can then be used for dynamic allocation, reducing the waste of network resources.
[0140] In some embodiments of this application, it is determined that the target network card has an inactive dynamic IP based on port configuration information. Specifically, this may include: if the dynamic IP field records a dynamic IP, it is determined that the target network card has an inactive dynamic IP.
[0141] Specifically, if the Dynamic IP field in the target network card's port configuration information records a dynamic IP address, it means that the DHCP server has assigned a dynamic IP address to the target network card, but this dynamic IP address has not taken effect. Therefore, it can be determined that the target network card has an inactive dynamic IP address. If the Dynamic IP field in the target network card's port configuration information is empty, it means that the DHCP server has not assigned a dynamic IP address to the target network card, and thus it can be determined that the target network card does not have an inactive dynamic IP address.
[0142] As can be seen, determining whether there are inactive dynamic IPs in the target network card based on the dynamic IP field of the port configuration information can accurately identify whether there are inactive dynamic IPs in the target network card, laying the foundation for subsequent IP recycling.
[0143] In this embodiment of the application, reclaiming ineffective dynamic IPs may specifically include: removing the dynamic allocation identifier from the port configuration information, the presence of which indicates that the Dynamic Host Configuration Protocol (DHCP) server is effective in allocating dynamic IPs to the target network card; and reclaiming ineffective dynamic IPs to the dynamic IP resource pool.
[0144] Specifically, when a target network interface card (NIC) has inactive dynamic IP addresses, these inactive dynamic IP addresses are reclaimed to avoid resource waste. The reclamation process involves removing the dynamic allocation flag from the target NIC's port configuration information and returning the inactive dynamic IP addresses to the dynamic IP resource pool. With the dynamic allocation flag removed from the target NIC's port configuration information, the DHCP server's function of assigning dynamic IP addresses to the target NIC is disabled; that is, the DHCP server will no longer dynamically assign dynamic IP addresses to the target NIC. The inactive dynamic IP addresses can then be returned to the dynamic IP resource pool.
[0145] For ease of understanding, combined with Figure 5 , Figure 6 Further explanation is needed. See also Figure 5 This is a diagram illustrating the port configuration information of the target network card. The dynamic IP field (dynamic_addresses) records the dynamic IP address, which is "192.168.200.2". The port configuration information also includes a dynamic allocation flag (dynamic flag). `dhcpv4_options` and `dhcpv6_options` are flexible sections used to pass additional network configuration parameters, allowing the DHCP server to dynamically assign various network settings to clients beyond basic IP addresses, making network configuration more flexible and automated.
[0146] Figure 6 This is another schematic diagram of the port configuration information of the target network card in an embodiment of this application. The dynamic allocation identifier in the port configuration information is removed, and the dynamic IP field of the port configuration information is empty.
[0147] As can be seen in this embodiment, when an invalid dynamic IP is detected on the target network card, the dynamic allocation flag of the target network card is removed, rendering the DHCP server's function of allocating dynamic IPs to the target network card ineffective, and then the invalid dynamic IP is reclaimed. This avoids the DHCP server reallocating dynamic IPs to the target network card after reclaiming invalid dynamic IPs. Furthermore, the invalid dynamic IPs are returned to the dynamic IP resource pool, allowing them to be reused and reducing the waste of network resources.
[0148] See Figure 7 As a possible implementation of this application embodiment, the above method may further include:
[0149] S701: In response to the fulfillment of the first condition, the effective IP is set to the reserved IP; the first condition is used to indicate that the dynamic IP allocation mechanism of the Dynamic Host Configuration Protocol (DHCP) server is not functioning properly; the DHCP server is used to allocate dynamic IPs to newly created virtual machines.
[0150] Specifically, in this embodiment of the application, the DHCP server function can be enabled and disabled. When the function is enabled, the dynamic IP allocation mechanism of the DHCP server operates normally; when the function is disabled, the dynamic IP allocation mechanism of the DHCP server cannot operate normally.
[0151] It should be noted that when the DHCP server is enabled, it records the lease information of assigned IP addresses, such as the lease duration. This ensures that an assigned IP address will not be reassigned before its lease expires.
[0152] In this embodiment of the application, the effective IP of each virtual machine can be obtained periodically by a scheduled task, and the effective IP can be added to the reserved IP pool to ensure that the effective IP is not allocated in a dynamic allocation manner.
[0153] However, scheduled tasks are triggered periodically, such as every 15 seconds. Therefore, the effective IPs counted based on scheduled tasks may be incomplete and may not include the effective IPs of newly created virtual machines. For example, if a new virtual machine is created within the next 5 seconds after a scheduled task has completed the count of effective IPs and is assigned a new dynamic IP by a DHCP server, then the dynamic IPs of the newly created virtual machines within those 5 seconds will only be counted when the next scheduled task is triggered.
[0154] For ease of description, the virtual machine created between two consecutive scheduled tasks is referred to as the target virtual machine, and the dynamic IP assigned by the DHCP server to the fourth virtual machine is referred to as the target IP.
[0155] If the DHCP server restarts after a brief shutdown between two consecutive scheduled tasks, the effective IP addresses of the target virtual machines created between these two tasks will not be fully counted, meaning the target IP address cannot be added to the reserved IP pool. Furthermore, the lease information for the target virtual machine may not be saved after the DHCP server restarts. Consequently, the DHCP server may treat the target IP address corresponding to the target virtual machine as an unassigned IP address in the dynamic IP resource pool. If a new virtual machine is created, the target IP address may be assigned to the newly created virtual machine, resulting in duplicate IP address allocation.
[0156] It is understandable that the above scenario represents an extreme situation that could lead to duplicate IP allocation. To avoid communication conflicts and data packet loss caused by duplicate IP allocation in this extreme scenario, this embodiment triggers the acquisition of effective IPs for each virtual machine after the DHCP server is shut down each time. This completes the statistics of effective IPs for the target virtual machines and adds all the counted effective IPs to the reserved IP pool. When the DHCP server restarts after being shut down, it avoids IPs in the reserved IP pool when assigning dynamic IPs to newly created virtual machines, thus preventing duplicate IP allocation.
[0157] As can be seen, in this embodiment, when the dynamic allocation mechanism of the DHCP server fails to function properly, the effective IP is set as a reserved IP. Furthermore, after each time the DHCP server is shut down, the effective IPs of each virtual machine are counted, and the counted effective IPs are added to the reserved IP pool to avoid duplicate IP allocation in extreme scenarios, which could lead to communication conflicts, packet loss, and other problems.
[0158] In some embodiments of this application, the above method may further include: in response to switching from satisfying a first condition to satisfying a second condition, configuring a dynamic allocation identifier for a third virtual machine, so that the DHCP server allocates a dynamic IP to the third virtual machine based on the dynamic allocation identifier; wherein, the second condition is used to characterize that the dynamic IP allocation mechanism for the DHCP server has resumed normal operation; the third virtual machine is a virtual machine newly created during the period when the first condition is satisfied.
[0159] Specifically, when the DHCP server's dynamic allocation mechanism switches from being unable to operate normally to operating normally again, and a new third virtual machine is created during this period, a dynamic allocation identifier is configured for the third virtual machine. When the DHCP server recognizes the dynamic allocation identifier of the third virtual machine, it will randomly select an IP address from the dynamic IP resource pool and assign a dynamic IP address to the third virtual machine in a dynamic allocation manner.
[0160] As can be seen in this embodiment, when a third virtual machine is created during the shutdown period of the DHCP server, a dynamic allocation identifier is configured for the third virtual machine. This enables the DHCP server to properly allocate a dynamic IP address to the third virtual machine when the dynamic IP allocation mechanism resumes normal operation. Therefore, it ensures that virtual machines created during the period from shutdown to restart of the DHCP server's dynamic IP allocation mechanism can also be allocated dynamic IP addresses, which helps improve the accuracy of IP address management.
[0161] For ease of understanding, the following will be explained... Figure 8 The scenarios described above are illustrated by example. Figure 8 The following steps are involved:
[0162] Step 1: Create virtual machine 102 on virtual machine management platform 101.
[0163] Step 2: DHCP server 104 assigns a dynamic IP address to virtual machine 102.
[0164] Step 3: The virtual machine management platform 101 records the dynamic IP assigned to the virtual machine 102 by the DHCP server 104 into the IP management device 103.
[0165] Step 4: The virtual machine management platform 101 shuts down virtual machine 102.
[0166] Step 5: The IP management device 103 keeps the record of the dynamic IP of the virtual machine 102 unchanged.
[0167] Step 6: IP management device 103 saves the dynamic IP of virtual machine 102 to the reserved IP pool of DHCP server 104.
[0168] Step 7: The virtual machine management platform 101 restarts the virtual machine 102.
[0169] Step 8: The IP management device 103 reassigns the saved dynamic IP of the virtual machine 102 to the virtual machine 102.
[0170] As can be seen, in this embodiment, on the one hand, a dynamic IP address is recorded for the virtual machine; on the other hand, the dynamic IP address is set as a reserved IP address to prevent it from being assigned to other virtual machines. Therefore, when a virtual machine needs an IP address, the bound IP address is reassigned to the virtual machine. This avoids changes to the virtual machine's IP address during its lifecycle due to virtual machine shutdowns and re-launches, thereby preventing any impact on the virtual machine's services.
[0171] The foregoing mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, the IP address management device includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0172] This application embodiment can, according to the above method, exemplarily divide the IP address management device into functional modules. For example, the IP address management device may include functional modules corresponding to each functional division, or two or more functions may be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division; in actual implementation, there may be other division methods.
[0173] For example, Figure 9 The diagram illustrates a possible embodiment of the IP address management device 900 described above. This IP address management device 900 may include an acquisition unit 901, a first processing unit 902, and a second processing unit 903. The acquisition unit 901 acquires the running status of a first virtual machine. The first processing unit 902 sets the IP address of the first virtual machine to a reserved IP address when the first virtual machine enters a target state. The target state represents a non-running state; the reserved IP address indicates that it cannot be assigned to a second virtual machine; the second virtual machine represents any virtual machine other than the first virtual machine. The second processing unit 903 sends the reserved IP address to a Dynamic Host Configuration Protocol (DHCP) server.
[0174] As can be seen, in this embodiment, the running status of the virtual machine is monitored. When the virtual machine enters the target state, the effective IP is set as a reserved IP to prevent it from being assigned to other virtual machines. Therefore, when the virtual machine needs an IP allocation, the bound IP is reassigned to the virtual machine. This avoids changes to the virtual machine's IP due to virtual machine shutdowns and re-launches during its lifecycle, thus preventing any impact on the virtual machine's services.
[0175] Optionally, the method also includes:
[0176] Obtain the effective IP address of the first virtual machine at runtime;
[0177] Establish the first mapping relationship between the effective IP and the first virtual machine.
[0178] As can be seen, in this embodiment, a first mapping relationship is established between the first virtual machine and the effective IP address. Therefore, when the first virtual machine has an IP allocation requirement, the effective IP address bound to it is assigned to each network interface card of the first virtual machine based on the first mapping relationship. This avoids changes to the virtual machine's IP address during its lifecycle, thereby preventing service interruptions and other problems.
[0179] Optionally, the IP address of the first virtual machine can be set to a reserved IP address, including:
[0180] If the IP address of the first virtual machine is stored in the dynamic IP resource pool, remove the IP address of the first virtual machine from the dynamic IP resource pool; the dynamic IP resource pool includes IP addresses that can be dynamically allocated.
[0181] Alternatively, add the IP of the first virtual machine to the reserved IP pool, which is used to accommodate IPs in the dynamic IP resource pool that are not allowed to be allocated dynamically.
[0182] As can be seen, by removing the IP address of the first virtual machine from the dynamic IP resource pool or adding it to the reserved IP pool, it is ensured that the IP address of the first virtual machine will not be assigned to other virtual machines. Therefore, when the first virtual machine has an IP allocation requirement, its IP address will be reassigned to it without causing duplicate IP allocation. This ensures that the first virtual machine's business operations are not affected and avoids the problem of duplicate IP allocation.
[0183] Optionally, the method also includes:
[0184] In response to the IP allocation request of the first virtual machine, an effective IP address with a first mapping relationship with the first virtual machine is allocated to the first virtual machine.
[0185] It is evident that when the first virtual machine has an IP allocation requirement, based on the first mapping relationship, the effective IP corresponding to the first virtual machine can be allocated to the first virtual machine, avoiding changes in the IP of the first virtual machine during its life cycle, thereby ensuring the normal operation of the first virtual machine's services.
[0186] Optionally, the method also includes:
[0187] Determine the static IPs among the effective IPs; static IPs refer to IPs assigned using a static allocation method;
[0188] Obtain the port configuration information of the target network interface card; the target network interface card is the virtual network interface card with a static IP address in the first virtual machine.
[0189] Based on the port configuration information, if it is determined that the target network card has an inactive dynamic IP, the inactive dynamic IP will be reclaimed.
[0190] As can be seen, in this embodiment, when it is determined that the effective IP of the virtual machine is a static IP, the target network interface card corresponding to the static IP is determined, and it is further determined whether there are any inactive dynamic IPs on the target network interface card. If so, they are reclaimed. This allows inactive dynamic IPs to be reclaimed into the dynamic IP resource pool, which can then be used for dynamic allocation, reducing the waste of network resources.
[0191] Optionally, the port configuration information includes a dynamic IP field, which records the dynamic IP assigned to the target network interface card (NIC). Based on the port configuration information, it is determined whether the target NIC has any inactive dynamic IPs, including:
[0192] If the dynamic IP field records a dynamic IP, it indicates that the target network card has an inactive dynamic IP.
[0193] As can be seen, determining whether there are inactive dynamic IPs in the target network card based on the dynamic IP field of the port configuration information can accurately identify whether there are inactive dynamic IPs in the target network card, laying the foundation for subsequent IP recycling.
[0194] Optionally, the inactive dynamic IP can be reclaimed, including:
[0195] Remove the dynamic allocation flag from the port configuration information. The presence of the dynamic allocation flag indicates that the Dynamic Host Configuration Protocol (DHCP) server is in effect, which assigns dynamic IP addresses to the target network card.
[0196] Unused dynamic IPs will be recycled to the dynamic IP resource pool.
[0197] As can be seen in this embodiment, when an invalid dynamic IP is detected on the target network card, the dynamic allocation flag of the target network card is removed, rendering the DHCP server's function of allocating dynamic IPs to the target network card ineffective, and then the invalid dynamic IP is reclaimed. This avoids the DHCP server reallocating dynamic IPs to the target network card after reclaiming invalid dynamic IPs. Furthermore, the invalid dynamic IPs are returned to the dynamic IP resource pool, allowing them to be reused and reducing the waste of network resources.
[0198] Optionally, the method also includes:
[0199] In response to the fulfillment of the first condition, the effective IP is set as a reserved IP; the first condition is used to indicate that the dynamic IP allocation mechanism of the Dynamic Host Configuration Protocol (DHCP) server is not functioning properly; the DHCP server is used to assign dynamic IPs to newly created virtual machines.
[0200] As can be seen, in this embodiment, when the dynamic allocation mechanism of the DHCP server fails to function properly, the effective IP is set as a reserved IP. Furthermore, after each time the DHCP server is shut down, the effective IPs of each virtual machine are counted, and the counted effective IPs are added to the reserved IP pool to avoid duplicate IP allocation in extreme scenarios, which could lead to communication conflicts, packet loss, and other problems.
[0201] Optionally, the method also includes:
[0202] In response to the switch from satisfying the first condition to satisfying the second condition, a dynamic allocation identifier is configured for the third virtual machine so that the DHCP server allocates a dynamic IP to the third virtual machine based on the dynamic allocation identifier; wherein, the second condition is used to indicate that the dynamic IP allocation mechanism of the DHCP server has resumed normal operation; the third virtual machine is a virtual machine newly created during the period when the first condition is satisfied.
[0203] As can be seen in this embodiment, when a third virtual machine is created during the shutdown period of the DHCP server, a dynamic allocation identifier is configured for the third virtual machine. This enables the DHCP server to properly allocate a dynamic IP address to the third virtual machine when the dynamic IP allocation mechanism resumes normal operation. Therefore, it ensures that virtual machines created during the period from shutdown to restart of the DHCP server's dynamic IP allocation mechanism can also be allocated dynamic IP addresses, which helps improve the accuracy of IP address management.
[0204] Optionally, the non-running state indicates that the first virtual machine is in a non-running business state and is in a non-migrating and non-HA synchronization state.
[0205] This application also provides a computing device, including: a processor and a memory; the processor is coupled to the memory; the memory is used for computer program instructions; the processor is used to call the computer program instructions in the memory to cause the computing device to execute any of the methods in the above embodiments.
[0206] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed on a computing device, cause the computing device to perform any of the methods described in the above embodiments.
[0207] For explanations of the relevant content and descriptions of the beneficial effects in any of the computer-readable storage media provided above, please refer to the corresponding embodiments described above, which will not be repeated here.
[0208] This application also provides a computer program product containing instructions that, when executed on a computing device, cause the computing device to perform any of the methods described in the above embodiments. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. It should be noted that the devices for storing computer instructions or computer programs provided in the embodiments of this application, such as, but not limited to, the aforementioned memory, computer-readable storage medium, and communication chip, are all non-transitory.
[0209] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software programs, it can be implemented, in whole or in part, as a computer program product. This computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
[0210] Computer instructions can be stored in or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. A computer-readable storage medium can be any available medium that a computer can access, or it can include one or more data storage devices such as servers or data centers that can be integrated with that medium. Available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
[0211] Although this application has been described in conjunction with specific features and embodiments, it is obvious that various modifications and combinations can be made thereto without departing from the spirit and scope of this application. Accordingly, this specification and drawings are merely exemplary illustrations of this application as defined by the appended claims, and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of this application. Clearly, those skilled in the art can make various alterations and modifications to this application without departing from the spirit and scope of this application. Thus, if such modifications and modifications of this application fall within the scope of the claims of this application and their equivalents, this application is also intended to include such modifications and modifications.
Claims
1. An IP address management method, characterized in that, The method includes: Obtain the running status of the first virtual machine; When the first virtual machine enters the target state, its IP address is set to a reserved IP address; the target state represents a non-running state; the reserved IP address indicates that it cannot be assigned to the second virtual machine; the second virtual machine refers to any virtual machine other than the first virtual machine. The reserved IP address is sent to the Dynamic Host Configuration Protocol (DHCP) server.
2. The IP address management method according to claim 1, characterized in that, The method further includes: Obtain the effective IP address of the first virtual machine during runtime; Establish a first mapping relationship between the effective IP and the first virtual machine.
3. The IP address management method according to claim 1, characterized in that, Setting the IP address of the first virtual machine as a reserved IP address includes: If the IP address of the first virtual machine is stored in a dynamic IP resource pool, the IP address of the first virtual machine is removed from the dynamic IP resource pool; the dynamic IP resource pool includes IP addresses that can be dynamically allocated. Alternatively, the IP address of the first virtual machine can be added to a reserved IP pool, which is used to accommodate IP addresses in the dynamic IP resource pool that are not allowed to be allocated dynamically.
4. The IP address management method according to claim 2, characterized in that, The method further includes: In response to the IP allocation request of the first virtual machine, an effective IP address with a first mapping relationship with the first virtual machine is allocated to the first virtual machine.
5. The IP address management method according to any one of claims 1-4, characterized in that, The method further includes: Determine the static IPs among the effective IPs; the static IPs refer to IPs allocated using a static allocation method; Obtain the port configuration information of the target network interface card; the target network interface card is the virtual network interface card in the first virtual machine whose effective IP is the static IP. Based on the port configuration information, if it is determined that the target network card has an inactive dynamic IP, the inactive dynamic IP will be reclaimed.
6. The IP address management method according to claim 5, characterized in that, The port configuration information includes a dynamic IP field, which is used to record the dynamic IP assigned to the target network card; Based on the port configuration information, it is determined that the target network interface card has an inactive dynamic IP address, including: If the dynamic IP is recorded in the dynamic IP field, it is determined that the target network card has an inactive dynamic IP.
7. The IP address management method according to claim 6, characterized in that, The process of reclaiming the inactive dynamic IP includes: Remove the dynamic allocation identifier from the port configuration information. The presence of the dynamic allocation identifier indicates that the Dynamic Host Configuration Protocol (DHCP) server is effective in allocating dynamic IP addresses to the target network card. The inactive dynamic IPs will be recycled to the dynamic IP resource pool.
8. The IP address management method according to claim 1, characterized in that, The method further includes: In response to the fulfillment of the first condition, the effective IP is set as the reserved IP; the first condition is used to indicate that the dynamic IP allocation mechanism of the Dynamic Host Configuration Protocol (DHCP) server is not functioning properly; the DHCP server is used to allocate dynamic IPs to newly created virtual machines.
9. The IP address management method according to claim 8, characterized in that, The method further includes: In response to switching from satisfying the first condition to satisfying the second condition, a dynamic allocation identifier is configured for the third virtual machine, so that the DHCP server allocates a dynamic IP to the third virtual machine based on the dynamic allocation identifier; wherein, the second condition is used to indicate that the dynamic IP allocation mechanism of the DHCP server has resumed normal operation; the third virtual machine is a virtual machine newly created during the period when the first condition is satisfied.
10. A computing device, characterized in that, include: Controller and memory; The controller is coupled to the memory; The memory is used for computer program instructions; The controller is configured to invoke computer program instructions in the memory to execute the method as described in any one of claims 1-9.