Automatic routing configuration method and device for multiple elastic network cards of cloud server
Through the combination of Udev device manager and DHCP client, the automated routing configuration of multi-elastic network cards of cloud servers is realized, solving the problems of low manual configuration efficiency and error-prone in the existing technology, and improving the configuration efficiency and reliability of network communication.
Patent Information
- Application Number
- CN202510066620.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2045-01-16
AI Technical Summary
In the multi-elastic network card configuration, existing cloud servers lack automated routing configuration mechanisms, resulting in network blockage and low manual configuration efficiency, which is prone to configuration errors.
Through the combination of Udev device manager and DHCP client, the routing table and policy routing of cloud server multi-elastic network cards are automatically configured to ensure that each elastic network card has an independent routing configuration.
It realizes the automatic routing configuration of multi-elastic network cards of cloud servers, improves configuration efficiency, reduces operation and maintenance costs, avoids manual configuration errors, and ensures normal network communication.
Smart Images

Figure CN119966871A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of cloud servers, and in particular to a method and device for automatically configuring multi-elastic network card routing of a cloud server. Background Art
[0002] Cloud computing is one of the hottest topics in the IT infrastructure field in recent years. Its virtualization abstraction of various resources such as computing, networking, and storage provides users with extremely convenient resource usage and flexible resource expansion capabilities.
[0003] Currently, the tenant cloud servers provided by the cloud platform can be associated with multiple elastic network cards to provide services and realize communication between cloud servers in different networks. However, because multiple elastic network card devices of the cloud server's Linux operating system use the same default routing table, when the first device recognized by the operating system is started, the default route configured by the system through the dynamic host configuration protocol service points to the first device. Without manual intervention, the inbound network traffic of other elastic network card devices will also match the default route and eventually point to the first network card device, which will cause network disconnection due to inconsistent MAC addresses of the sending and receiving devices.
[0004] By manually configuring policy routing, the incoming network traffic of the same elastic network card can be sent out by the network card, so that multiple elastic network cards on the same cloud server can be accessed. However, manual configuration of multiple elastic network cards for a large number of cloud servers is time-consuming and inefficient, and manual input errors may result in the unavailability of the elastic network card.
[0005] In order to improve configuration efficiency and reduce operation and maintenance costs, the present invention proposes a method and device for automatically configuring multi-elastic network card routing of a cloud server. Summary of the invention
[0006] In order to overcome the defects of the prior art, the present invention provides a simple and efficient cloud server multi-elastic network card routing automatic configuration method and device.
[0007] The present invention is achieved through the following technical solutions:
[0008] A method for automatically configuring routing of multiple elastic network cards of a cloud server. After the cloud server is started, when an elastic network card is added, the Udev device manager persistently adds the device name of the elastic network card, and calls a custom script provided in the solution through a device event notification to implement the entry of the network card management configuration file of the newly added elastic network card device.
[0009] After receiving the device event notification sent by the Udev device manager, the custom script calls the DHCP client, triggers the DHCP Hook mechanism, and configures and manages the policy routing for the corresponding network card device.
[0010] When a new elastic network card is added to the cloud server, the steps for automatic routing configuration are as follows:
[0011] Step S1.1, when the cloud server mounts the elastic network card for the first time or the cloud server is started, the Udev device manager detects the elastic network card device and notifies the network card policy routing configuration tool of the corresponding solution of the detected elastic network card device addition event;
[0012] Step S1.2: When the network card policy routing configuration tool receives a message about a newly added network card, it starts up the elastic network card by calling a Linux system command;
[0013] Step S1.3: Use the DHCP client to send a request to the DHCP server to configure the IP address information of the elastic network card;
[0014] Step S1.4: When the DHCP client receives the message, the DHCP Hook mechanism is triggered to determine the message type. If the message type is to bind and obtain a lease or to renew a lease, policy routing configuration is performed on the corresponding elastic network card.
[0015] In step S1.4, the DHCP client performs policy routing configuration on the elastic network card, and the steps are as follows:
[0016] Step S1.4.1, create a separate routing table for the elastic network card;
[0017] Step S1.4.2, add a default route to the newly created routing table and specify the egress as the corresponding elastic network card;
[0018] Step S1.4.3, add policy routing to direct the exit of all traffic entering from the newly added elastic network card to the elastic network card.
[0019] After completing the above steps, the IP address of the ENIC can be accessed from outside the cloud server.
[0020] When the ENIC on the cloud server is removed, the related configurations added by the solution when adding the ENIC also need to be cleaned up, otherwise they will remain. The processing steps are as follows:
[0021] Step S2.1, after the Udev device manager detects that the elastic network card device is removed, it deletes the corresponding device file and notifies the script of the network card policy routing configuration tool of the device event;
[0022] Step S2.2: When the script receives the notification, it calls the DHCP client to release the lease of the corresponding elastic network card;
[0023] Step S2.3: When the DHCP client receives the message that the elastic network card lease is released, the DHCP hook is triggered, and the elastic network card policy routing configuration tool executes the command to clean up the policy routing and routing table added for the elastic network card to prevent residual configuration from affecting subsequent use.
[0024] After the preceding steps are completed, the newly added configurations when adding the elastic network card are cleared.
[0025] A cloud server multi-elastic network card routing automatic configuration device, including a Udev device manager, a network card policy routing configuration tool and a DHCP client;
[0026] The Udev device manager is responsible for persistently adding the device name of the elastic network card when an elastic network card device is detected, and notifying the network card policy routing configuration tool of the corresponding solution of the detected elastic network card device addition event by calling the custom script provided in the solution through the device event notification;
[0027] The network card policy routing configuration tool is responsible for starting the elastic network card by calling the Linux system command when receiving the message of the newly added network card, entering the network card management configuration file of the newly added elastic network card device in the script, and calling the DHCP client;
[0028] The DHCP client is responsible for configuring and managing the policy routing of the corresponding network card device by triggering the DHCP Hook mechanism.
[0029] The Udev device manager is also responsible for deleting the corresponding device file after detecting that the elastic network card device is removed, and notifying the script of the network card policy routing configuration tool of the device event;
[0030] The script of the network card policy routing configuration tool is responsible for calling the DHCP client after receiving the notification to release the lease of the corresponding elastic network card.
[0031] The DHCP client is responsible for initiating a request to the DHCP server to configure the IP address information of the elastic network card, triggering the DHCPHook mechanism, and judging the message type. If the message type is to bind to obtain a lease or renew a lease, the corresponding elastic network card is configured with policy routing;
[0032] In addition, the DHCP client is also responsible for triggering DHCPhook upon receiving the message of releasing the lease of the elastic network card, and the elastic network card policy routing configuration tool executes commands to clean up the policy routing and routing table added for the elastic network card to prevent residual configuration from affecting subsequent use.
[0033] The DHCP client is responsible for configuring policy routing for the elastic network card. The steps are as follows:
[0034] Step S1.4.1, create a separate routing table for the elastic network card;
[0035] Step S1.4.2, add a default route to the newly created routing table and specify the egress as the corresponding elastic network card;
[0036] Step S1.4.3, add policy routing to direct the exit of all traffic entering from the newly added elastic network card to the elastic network card.
[0037] A cloud server multi-elastic network card routing automatic configuration device is characterized by comprising a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the above method steps when executing the computer program.
[0038] A readable storage medium, characterized in that: a computer program is stored on the readable storage medium, and the computer program implements the above method steps when executed by a processor.
[0039] The beneficial effect of the present invention is that the method and device for automatically configuring routing of multiple elastic network cards of a cloud server can achieve the availability of the network card without additional manual operation under the premise that the operating system supports hot plugging. When operating the elastic network cards of the cloud server in batches, the manual configuration time is saved and the configuration accuracy is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Attached Figure 1 Schematic diagram of the method for automatically configuring routing of multiple elastic network cards in a cloud server according to the present invention.
[0042] Attached Figure 2 Schematic diagram of a method for automatically cleaning up the data left over by a network card after the network card is unplugged according to the present invention DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0044] Tenant cloud servers provided by the cloud platform can be associated with multiple elastic network cards to meet the needs of multi-network card device access or network output. Since most cloud servers provide Linux operating systems, when the Linux operating system processes multiple elastic network card devices, it puts all these network card devices into the default network space and uses the same default routing table. In this way, because there can only be one default route in the default routing table, when a random address accesses multiple elastic network cards of the device, the same routing rules are matched, and the traffic can only be sent from the same network card device. This will cause communication failure due to the inconsistency between the destination MAC address accessed and the returned source MAC address.
[0045] The Dynamic Host Configuration Protocol (DHCP) service of the Linux operating system generally supports the Hook mechanism, which is used to insert custom code or scripts into the workflow of the DHCP protocol so as to perform specific operations when specific DHCP events occur. The network card management tools used by the current mainstream Linux operating system distributions are all integrated with DHCP clients and support the DHCP hook mechanism.
[0046] Udev is a Linux subsystem for dynamic device detection and management, available since Linux kernel version 2.6. It propagates information about devices or changes to their state to user space at boot time or when devices are added to or removed from the system.
[0047] The main functions and features of Udev include:
[0048] 1). Dynamic device node management: When a device is connected to the system or removed, Udev will automatically create or delete the corresponding device node.
[0049] 2). Rule files: Udev uses rule files (usually located in the / etc / udev / rules.d / directory) to determine how to name device nodes and what operations to perform (such as setting permissions, ownership, etc.).
[0050] 3). Device event notification: Udev can trigger events. When devices are added, removed, or their properties change, other system components (such as daemons or scripts) can receive these events and perform corresponding operations.
[0051] 4). Support persistent device naming: By using rule files, Udev can assign persistent names to devices, which will not change even if the physical connection order of the devices or the system is restarted.
[0052] The cloud server multi-elastic network card routing automatic configuration method, after the cloud server is started, when a new elastic network card is added, the Udev device manager persistently adds the device name of the elastic network card, and calls the custom script provided in the solution through the device event notification to realize the entry of the network card management configuration file of the newly added elastic network card device;
[0053] After receiving the device event notification sent by the Udev device manager, the custom script calls the DHCP client, triggers the DHCP Hook mechanism, and configures and manages the policy routing for the corresponding network card device.
[0054] When a new elastic network card is added to the cloud server, the steps for automatic routing configuration are as follows:
[0055] Step S1.1, when the cloud server mounts the elastic network card for the first time or the cloud server is started, the Udev device manager detects the elastic network card device and notifies the network card policy routing configuration tool of the corresponding solution of the detected elastic network card device addition event;
[0056] Step S1.2: When the network card policy routing configuration tool receives a message about a newly added network card, it starts up the elastic network card by calling a Linux system command;
[0057] Step S1.3: Use the DHCP client to send a request to the DHCP server to configure the IP address information of the elastic network card;
[0058] Step S1.4: When the DHCP client receives the message, the DHCP Hook mechanism is triggered to determine the message type. If the message type is to bind and obtain a lease or to renew a lease, policy routing configuration is performed on the corresponding elastic network card.
[0059] In step S1.4, the DHCP client performs policy routing configuration on the elastic network card, and the steps are as follows:
[0060] Step S1.4.1, create a separate routing table for the elastic network card;
[0061] Step S1.4.2, add a default route to the newly created routing table and specify the egress as the corresponding elastic network card;
[0062] Step S1.4.3, add policy routing to direct the exit of all traffic entering from the newly added elastic network card to the elastic network card.
[0063] After completing the above steps, the IP address of the ENIC can be accessed from outside the cloud server.
[0064] When the ENIC on the cloud server is removed, the related configurations added by the solution when adding the ENIC also need to be cleaned up, otherwise they will remain. The processing steps are as follows:
[0065] Step S2.1, after the Udev device manager detects that the elastic network card device is removed, it deletes the corresponding device file and notifies the script of the network card policy routing configuration tool of the device event;
[0066] Step S2.2: When the script receives the notification, it calls the DHCP client to release the lease of the corresponding elastic network card;
[0067] Step S2.3: When the DHCP client receives the message that the elastic network card lease is released, the DHCP hook is triggered, and the elastic network card policy routing configuration tool executes the command to clean up the policy routing and routing table added for the elastic network card to prevent residual configuration from affecting subsequent use.
[0068] After the preceding steps are completed, the newly added configurations when adding the elastic network card are cleared.
[0069] The cloud server multi-elastic network card routing automatic configuration device includes a Udev device manager, a network card policy routing configuration tool and a DHCP client;
[0070] The Udev device manager is responsible for persistently adding the device name of the elastic network card when an elastic network card device is detected, and notifying the network card policy routing configuration tool of the corresponding solution of the detected elastic network card device addition event by calling the custom script provided in the solution through the device event notification;
[0071] The network card policy routing configuration tool is responsible for starting the elastic network card by calling the Linux system command when receiving the message of the newly added network card, entering the network card management configuration file of the newly added elastic network card device in the script, and calling the DHCP client;
[0072] The DHCP client is responsible for configuring and managing the policy routing of the corresponding network card device by triggering the DHCP Hook mechanism.
[0073] The Udev device manager is also responsible for deleting the corresponding device file after detecting that the elastic network card device is removed, and notifying the script of the network card policy routing configuration tool of the device event;
[0074] The script of the network card policy routing configuration tool is responsible for calling the DHCP client after receiving the notification to release the lease of the corresponding elastic network card.
[0075] The DHCP client is responsible for initiating a request to the DHCP server to configure the IP address information of the elastic network card, triggering the DHCPHook mechanism, and judging the message type. If the message type is to bind to obtain a lease or renew a lease, the corresponding elastic network card is configured with policy routing;
[0076] In addition, the DHCP client is also responsible for triggering DHCPhook upon receiving the message of releasing the lease of the elastic network card, and the elastic network card policy routing configuration tool executes commands to clean up the policy routing and routing table added for the elastic network card to prevent residual configuration from affecting subsequent use.
[0077] The DHCP client is responsible for configuring policy routing for the elastic network card. The steps are as follows:
[0078] Step S1.4.1, create a separate routing table for the elastic network card;
[0079] Step S1.4.2, add a default route to the newly created routing table and specify the egress as the corresponding elastic network card;
[0080] Step S1.4.3, add policy routing to direct the exit of all traffic entering from the newly added elastic network card to the elastic network card.
[0081] The cloud server multi-elastic network card routing automatic configuration device comprises a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the above method steps when executing the computer program.
[0082] The readable storage medium stores a computer program, and when the computer program is executed by a processor, the above method steps are implemented.
[0083] The cloud server multi-elastic network card routing automatic configuration method and device triggers the interface of the Linux system event notification subsystem udev when the cloud server is started or an elastic network card is added to ensure that the elastic network card is started. When the Linux operating system detects the elastic network card device and starts the network card device through the network card device management system, the hook method provided by the system's supporting dynamic host management protocol service can receive the basic information of the network card, and configure the routing policy of the newly added elastic network card device through the policy routing configuration tool, so that the network traffic entering through the elastic network card is sent out from the same elastic network card.
[0084] The cloud server multi-elastic network card routing automatic configuration method and device are used to automatically configure the elastic network card policy routing based on the Linux device event notification subsystem Udev and the dynamic host configuration protocol system, and no manual intervention is required in the configuration process; not only can it ensure that in the Linux system, regardless of whether the network management service is installed, the network card can be self-started, but also the use complexity and configuration error probability of the cloud server using multiple elastic network cards can be reduced, thereby improving the use efficiency of multiple elastic network cards.
[0085] The embodiment described above is only one specific implementation of the present invention. Common changes and substitutions made by those skilled in the art within the scope of the technical solution of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for automatically configuring multi-elastic network card routing for a cloud server, characterized in that: After the cloud server is started, when a new elastic network card is added, the Udev device manager persistently adds the device name of the elastic network card, and calls the custom script provided in the solution through the device event notification to implement the entry of the network card management configuration file of the newly added elastic network card device; After receiving the device event notification sent by the Udev device manager, the custom script calls the DHCP client, triggers the DHCPHook mechanism, and configures and manages the policy routing for the corresponding network card device.
2. The method for automatically configuring multi-elastic network card routing for a cloud server according to claim 1, characterized in that: When a new elastic network card is added to a cloud server, the steps for automatic routing configuration are as follows: Step S1.1, when the cloud server mounts the elastic network card for the first time or the cloud server is started, the Udev device manager detects the elastic network card device and notifies the network card policy routing configuration tool of the corresponding solution of the detected elastic network card device addition event; Step S1.2: When the network card policy routing configuration tool receives a message about a newly added network card, it starts up the elastic network card by calling a Linux system command; Step S1.3: Use the DHCP client to send a request to the DHCP server to configure the IP address information of the elastic network card; Step S1.4: When the DHCP client receives the message, the DHCP Hook mechanism is triggered to determine the message type. If the message type is to bind and obtain a lease or to renew a lease, policy routing configuration is performed on the corresponding elastic network card.
3. The method for automatically configuring multi-elastic network card routing for a cloud server according to claim 2, characterized in that: In step S1.4, the DHCP client performs policy routing configuration on the elastic network card, and the steps are as follows: Step S1.4.1, create a separate routing table for the elastic network card; Step S1.4.2, add a default route to the newly created routing table and specify the egress as the corresponding elastic network card; Step S1.4.3, add policy routing to direct the egress of all traffic entering from the newly added elastic network card to the elastic network card.
4. The method for automatically configuring multi-elastic network card routing for a cloud server according to claim 1, characterized in that: When the ENI on a cloud server is removed, the following steps are performed: Step S2.1, after the Udev device manager detects that the elastic network card device is removed, it deletes the corresponding device file and notifies the script of the network card policy routing configuration tool of the device event; Step S2.2: When the script receives the notification, it calls the DHCP client to release the lease of the corresponding elastic network card; Step S2.3: When the DHCP client receives the message that the elastic network card lease is released, the DHCP hook is triggered, and the elastic network card policy routing configuration tool executes the command to clean up the policy routing and routing table added for the elastic network card to prevent residual configuration from affecting subsequent use.
5. A cloud server multi-elastic network card routing automatic configuration device, characterized in that: Includes Udev device manager, network card policy routing configuration tool and DHCP client; The Udev device manager is responsible for persistently adding the device name of the elastic network card when an elastic network card device is detected, and notifying the network card policy routing configuration tool of the corresponding solution of the detected elastic network card device addition event by calling the custom script provided in the solution through the device event notification; The network card policy routing configuration tool is responsible for starting the elastic network card by calling the Linux system command when receiving the message of the newly added network card, entering the network card management configuration file of the newly added elastic network card device in the script, and calling the DHCP client; The DHCP client is responsible for configuring and managing the policy routing of the corresponding network card device by triggering the DHCP Hook mechanism.
6. The cloud server multi-elastic network card routing automatic configuration device according to claim 5, characterized in that: The Udev device manager is also responsible for deleting the corresponding device file after detecting that the elastic network card device is removed, and notifying the script of the network card policy routing configuration tool of the device event; The script of the network card policy routing configuration tool is responsible for calling the DHCP client after receiving the notification to release the lease of the corresponding elastic network card.
7. The cloud server multi-elastic network card routing automatic configuration device according to claim 5, characterized in that: The DHCP client is responsible for initiating a request to the DHCP server to configure the IP address information of the elastic network card, triggering the DHCPHook mechanism, and judging the message type. If the message type is to bind to obtain a lease or renew a lease, the corresponding elastic network card is configured with policy routing; In addition, the DHCP client is also responsible for triggering the DHCP hook when receiving the message of releasing the elastic network card lease, and the elastic network card policy routing configuration tool executes the command to clean up the policy routing and routing table added for the elastic network card to prevent residual configuration from affecting subsequent use.
8. The cloud server multi-elastic network card routing automatic configuration device according to claim 7, characterized in that: The DHCP client is responsible for configuring policy routing for the elastic network card. The steps are as follows: Step S1.4.1, create a separate routing table for the elastic network card; Step S1.4.2, add a default route to the newly created routing table and specify the egress as the corresponding elastic network card; Step S1.4.3, add policy routing to direct the exit of all traffic entering from the newly added elastic network card to the elastic network card.
9. A cloud server multi-elastic network card routing automatic configuration device, characterized by: The method comprises a memory and a processor; the memory is used to store a computer program, and the processor is used to implement the method according to any one of claims 1 to 4 when executing the computer program.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Network communication management method and device of cloud platform, equipment and storage medium
CN115664920A
Lease file-based IP setting method and system
WO2014194680A1