Network configuration automatic recovery method, device, equipment and medium

By persisting network configuration data to an independent storage space in the gateway software, the problem of configuration loss after gateway device restart is solved, achieving automatic recovery and cross-operating system adaptability, and simplifying configuration management.

CN121125473APending Publication Date: 2025-12-12SHANDONG LANGCHAO YUNTOU INFORMATION TECH CO LTD

Patent Information

Application Number
CN202511576553.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2025-12-12

AI Technical Summary

Technical Problem

In cloud computing and data center network environments, the network configuration of gateway devices is lost after system restart or crash. Existing technologies are difficult to automatically recover on different Linux distributions, and there are problems of insufficient flexibility and cumbersome operation.

Method used

By maintaining a structured network configuration object model in the gateway software and persisting the configuration data to a separate storage space, such as a JSON file or an SQLite database, the system can read from this storage space and redistribute the configuration upon restarting, thus achieving automatic recovery.

Benefits of technology

It enables automatic restoration of network configuration after system restart, improves adaptability and manageability to different operating system versions, reduces the cost of new code development and maintenance, and ensures that the restoration behavior is consistent with the real-time configuration behavior.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121125473A_ABST
    Figure CN121125473A_ABST
Patent Text Reader

Abstract

The invention discloses a network configuration automatic recovery method and device, equipment and a medium, and relates to the technical field of computers. Comprising the following steps: acquiring a network configuration request for target network configuration, and calling a system command based on the network configuration request to execute a network configuration operation for the target network configuration; if the network configuration operation is successfully executed, persistently storing the structured data of the current target network configuration into a preset independent storage space; and when an operating system where the gateway software is located is restarted, executing a preset configuration recovery process so as to read the structured data of the stored network configuration from the preset independent storage space, and re-issuing the stored network configuration to the operating system through a preset multiplexing issuing logic so as to complete recovery of the network configuration. Therefore, the network configuration can be automatically recovered after the system is restarted, and the adaptability and manageability for different operating system versions are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a method, apparatus, device, and medium for automatic network configuration recovery. Background Technology

[0002] In cloud computing and data center network environments, gateway devices, as critical control nodes for network traffic, are essential for network connectivity and security due to their network configurations (including network interface card (NIC) addresses, routing rules, firewall policies, tunnel parameters, etc.). Currently, such gateway software typically runs on a Linux operating system, configuring the kernel network stack in real-time via commands using system tools such as iproute2, iptables, and nftables. However, these configurations are only effective in memory by default; if the operating system restarts or crashes, all dynamic configurations are lost and must be redeployed to restore network functionality.

[0003] To address configuration loss issues, the traditional approach relies on the network configuration persistence mechanisms provided by the Linux operating system. This includes editing ` / etc / network / interfaces` (Debian / Ubuntu), configuring netplan (Ubuntu Server), or using the NetworkManager service (RHEL / CentOS) to write network parameters into startup scripts or service configuration files. While this method can automatically load some configurations at system startup, it also has significant limitations:

[0004] Significant differences in system versions: Different Linux distributions have significant differences in the persistence mechanism of network configurations, which means that gateway software needs to adapt to different system versions with different configuration writing logic, increasing the complexity of development and maintenance.

[0005] Insufficient flexibility: Traditional startup scripts often struggle to support or have rigid configuration structures for dynamic and customized network configurations commonly found in gateway devices (such as GRE tunnels, policy routing, and complex firewall rules), failing to meet the flexible and ever-changing business needs.

[0006] Inconvenient to modify: Every time the network configuration changes, the corresponding system configuration file needs to be modified manually or through external tools. It is impossible to achieve automatic synchronization and persistent updates of configuration changes, making the operation cumbersome and prone to errors.

[0007] As can be seen from the above, how to automatically restore network configuration after system restart and improve adaptability and manageability for different operating system versions is an urgent problem to be solved. Summary of the Invention

[0008] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for automatic network configuration recovery, which can automatically restore network configuration after a system restart and improve adaptability and manageability for different operating system versions. The specific solution is as follows:

[0009] Firstly, this application provides a method for automatic network configuration recovery, applied to gateway software, comprising:

[0010] Obtain a network configuration request for the target network configuration, and invoke system commands based on the network configuration request to execute network configuration operations for the target network configuration; the network configuration request includes a creation request, an update request, and a deletion request; the target network configuration includes interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration;

[0011] If the network configuration operation is successfully executed, the structured data of the current target network configuration will be persistently stored in a preset independent storage space.

[0012] When the operating system where the gateway software resides restarts, a preset configuration recovery process is executed to read the structured data of the stored network configuration from the preset independent storage space, and to re-download the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

[0013] Optionally, the step of persistently storing the structured data of the current target network configuration to a preset independent storage space includes:

[0014] If the network configuration request is a creation request, the structured data of the corresponding newly added configuration object will be appended to the preset independent storage space;

[0015] If the network configuration request is an update request, the unique identifier in the network configuration request is used to locate and replace the structured data of the corresponding original network configuration object in the preset independent storage space;

[0016] If the network configuration request is a deletion request, the structured data of the corresponding original network configuration object is located and deleted from the preset independent storage space using the unique identifier in the network configuration request.

[0017] Optionally, the step of executing the preset configuration recovery process to read the structured data of the stored network configuration from the preset independent storage space includes:

[0018] The system accesses the preset independent storage space based on the preset independent storage space path and parses the data in the preset independent storage space into a set of network configuration objects to complete the reading of the structured data of the stored network configuration.

[0019] Optionally, after executing the preset configuration recovery process to read the structured data of the stored network configuration from the preset independent storage space, the process further includes:

[0020] The structured data of the read network configuration is sorted by topology to determine the distribution order based on the dependencies between configuration items.

[0021] Optionally, the step of re-distributing the stored network configuration to the operating system through preset multiplexing and distribution logic to restore the network configuration includes:

[0022] The stored network configuration is re-distributed to the operating system based on the distribution order using a preset reuse distribution logic, thereby restoring the network configuration.

[0023] The preset multiplexing and distribution logic is to parse the stored network configuration into a network configuration request, and then call system commands based on the network configuration request to perform network configuration operations.

[0024] Optionally, the preset independent storage space uses a JSON file, a YAML file, or an SQLite database as its storage format;

[0025] The method further includes:

[0026] When the storage format is JSON or YAML file, the network configuration data is serialized to obtain the corresponding structured object, and the structured object is written into the preset configuration file;

[0027] When the storage format uses an SQLite database, corresponding data tables are created for different types of network configuration objects, and configuration records are stored in the corresponding data tables.

[0028] Optionally, the automatic network configuration recovery method further includes:

[0029] The gateway software is registered as an operating system startup service, and the startup service is used to automatically run the gateway software when the operating system restarts, thereby triggering the network configuration recovery process.

[0030] Secondly, this application provides a network configuration automatic recovery device, comprising:

[0031] The network configuration execution module is used to obtain network configuration requests for a target network configuration and, based on the network configuration requests, call system commands to execute network configuration operations for the target network configuration; the network configuration requests include creation requests, update requests, and deletion requests; the target network configuration includes interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration;

[0032] The network configuration storage module is used to persistently store the structured data of the current target network configuration to a preset independent storage space if the network configuration operation is successfully executed.

[0033] The network configuration recovery module is used to execute a preset configuration recovery process when the operating system where the gateway software is located restarts. This process reads the structured data of the stored network configuration from the preset independent storage space and re-distributes the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

[0034] Thirdly, this application provides an electronic device, comprising:

[0035] Memory, used to store computer programs;

[0036] A processor is used to execute the computer program to implement the aforementioned automatic network configuration recovery method.

[0037] Fourthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned automatic network configuration recovery method.

[0038] This application provides an automatic network configuration recovery method applied to gateway software. First, a network configuration request for a target network configuration is obtained. Based on the network configuration request, system commands are invoked to execute network configuration operations for the target network configuration. The network configuration request includes a creation request, an update request, and a deletion request. The target network configuration includes interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration. If the network configuration operation is successfully executed, the structured data of the current target network configuration is persistently stored in a preset independent storage space. When the operating system on which the gateway software resides restarts, a preset configuration recovery process is executed to read the stored structured data of the network configuration from the preset independent storage space and re-deploy the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

[0039] As can be seen from the above, this application backs up the current network configuration by storing the structured data of the current network configuration in a preset independent storage space. Upon system restart, a preset configuration recovery process is used to retrieve the stored network configuration from the preset independent storage space and complete the network configuration recovery. This enables automatic recovery of the network configuration after a system restart and improves adaptability and manageability for different operating system versions. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0041] Figure 1 This is a flowchart of a network configuration automatic recovery method disclosed in this application;

[0042] Figure 2 This application discloses a flowchart of a specific method for automatic network configuration recovery.

[0043] Figure 3 This is a schematic diagram of an automatic network configuration recovery device disclosed in this application;

[0044] Figure 4 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation

[0045] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0046] In cloud computing and data center network environments, gateway devices, as critical control nodes for network traffic, are essential for network connectivity and security. Currently, such gateway software typically runs on Linux operating systems, configuring the kernel network stack in real-time via commands through system tools such as iproute2, iptables, and nftables. However, this configuration only takes effect in memory by default; once the operating system restarts or crashes, all dynamic configurations are lost and must be redeployed to restore network functionality. Traditionally, this relies on the network configuration persistence mechanisms provided by the Linux operating system, such as editing ` / etc / network / interfaces` (Debian / Ubuntu), configuring netplan (Ubuntu Server), or using the NetworkManager service (RHEL / CentOS) to write network parameters into startup scripts or service configuration files. While these methods can automatically load some configurations at system startup, they also have limitations such as significant system version differences, insufficient flexibility, and inconvenience in modification. Therefore, this application provides an automatic network configuration recovery scheme that can automatically restore network configuration after a system restart and improve adaptability and manageability across different operating system versions.

[0047] See Figure 1 As shown in the figure, this application discloses a method for automatic network configuration recovery, applied to gateway software, including:

[0048] Step S11: Obtain a network configuration request for the target network configuration, and invoke system commands based on the network configuration request to perform network configuration operations for the target network configuration.

[0049] In this embodiment, the gateway software maintains a structured network configuration object model in memory, including but not limited to interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration. For example, in some specific implementations, the gateway software internally defines data structures (e.g., classes, structs, or JSON Schema) to provide fine-grained, object-oriented abstraction of the network configuration. For instance, interface configuration includes network interface card name, status (up / down), IP address (IPv4 / IPv6), subnet mask / prefix, MTU, MAC address, etc. Routing configuration includes target network, gateway, outgoing interface, route type (default, static), metric, etc. Policy routing rule configuration includes policy routing rules (source IP, destination IP, priority, table ID, etc.). GRE tunnel configuration includes tunnel name, local endpoint IP, remote endpoint IP, tunnel key, etc. Firewall rule configuration includes chains, tables, rule conditions, actions, etc.

[0050] Furthermore, whenever a network configuration change operation for a network configuration request is successfully executed, the software not only performs an immediate change, but also immediately writes the changes to a pre-defined independent storage space managed by itself, separate from the operating system's network configuration file. The network configuration requests include, but are not limited to, creation, update, and deletion requests; the sources of these requests include, but are not limited to, the management interface, API calls, or console commands. The storage location of the independent storage space is selected as a directory that still exists after an operating system restart and that the gateway software has access to (e.g., / opt / gateway / config / or / var / lib / gateway / ). The storage format of the independent storage space needs to be selected as an easy-to-parse, durable, and version-controlled format. For example, in one specific implementation, the pre-defined independent storage space uses a JSON file, a YAML file, or an SQLite database as its storage format; correspondingly, the method further includes: when the storage format is JSON or YAML, serializing the network configuration data to obtain a corresponding structured object, and writing the structured object into a pre-defined configuration file; when the storage format is an SQLite database, creating corresponding data tables for different types of network configuration objects, and storing the configuration records in the corresponding data tables. In other words, JSON / YAML is easy to read and version control; SQLite provides ACID transaction support and query capabilities.

[0051] Step S12: If the network configuration operation is successfully executed, the structured data of the current target network configuration is persistently stored in a preset independent storage space.

[0052] In this embodiment, the structured data of the current target network configuration is persistently stored in a preset independent storage space according to the specific type of the network configuration request. Specifically, persistently storing the structured data of the current target network configuration in the preset independent storage space may include: if the network configuration request is a creation request, then appending the structured data of the corresponding newly added configuration object to the preset independent storage space; for example, serializing the corresponding configuration object (converting it to a JSON string) and writing it to persistent storage (appending to a file or inserting it into a database). If the network configuration request is an update request, then using the unique identifier in the network configuration request to locate and replace the structured data of the corresponding original network configuration object in the preset independent storage space; the unique identifier includes, but is not limited to, the interface name and the target network for routing. If the network configuration request is a deletion request, then using the unique identifier in the network configuration request to locate and delete the structured data of the corresponding original network configuration object in the preset independent storage space.

[0053] It is important to note that the process of persistently storing structured data in a pre-defined independent storage space (especially updates and deletions) should be completed within a single transaction whenever possible (such as SQLite transactions or atomic file write operations) to avoid partial writes leading to data corruption. Strictly adhere to the principle of "updating persistent storage only after system commands have executed successfully" to ensure eventual consistency between the memory state, kernel state, and persistent storage. If a system command fails, do not update persistent storage and return an error to the requesting party.

[0054] Step S13: When the operating system where the gateway software is located restarts, a preset configuration recovery process is executed to read the structured data of the stored network configuration from the preset independent storage space, and to re-download the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

[0055] In this embodiment, a preset configuration recovery process is inserted in the main program startup flow of the gateway software, after the initialization phase and before the service operation phase. This preset configuration recovery process is executed when the software starts to read the structured data of the stored network configuration from the preset independent storage space. Specifically, executing the preset configuration recovery process may include: accessing the preset independent storage space based on the stored preset independent storage space path, and parsing the data in the preset independent storage space into a set of network configuration objects to complete the reading of the structured data of the stored network configuration.

[0056] Furthermore, the structured data of the read network configuration is topologically sorted to determine the distribution order based on the dependencies between configuration items. For example, in one implementation, a physical interface must be configured before an IP address can be configured on it or it can be used as an outgoing interface for routing. A GRE tunnel interface must be created before its IP address or routing can be configured. The routing table referenced by policy routing rules must exist first.

[0057] Furthermore, based on the aforementioned distribution order, the stored network configuration is re-distributed to the operating system using a preset reuse distribution logic to complete the network configuration recovery. This preset reuse distribution logic parses the stored network configuration into a network configuration request and invokes system commands based on the request to execute the network configuration operation. In other words, the gateway software converts (or directly constructs) each configuration object in the memory-based configuration object set into a standard internal request format (InternalRequest) used by the gateway software when processing external requests. These InternalRequests are then sequentially sent to the gateway software's original command processing engine, which handles real-time configuration requests. The command processing engine parses each InternalRequest like a user request and invokes the corresponding underlying system command library function to distribute the configuration. The engine's original error handling and logging mechanisms remain in effect during this process. The success or failure status of each configuration item distribution during the recovery process is recorded. For failed items, detailed error information is recorded, and a summary report can be output in the software log. In other words, by reusing existing, validated deployment logic, the development and maintenance costs of new code are greatly reduced, ensuring that recovery behavior is consistent with real-time configuration behavior; changes in business rules (such as deployment logic optimization) are automatically reflected in the recovery process. At the same time, the original engine's error handling mechanism is used to handle exceptions during the recovery process.

[0058] In this embodiment, the core objective is achieved by registering the gateway software as a standard background service within the operating system's service management framework. This ensures that the gateway software is automatically loaded and run after the operating system completes its basic startup process. The core lies in the design and implementation of service integration and automatic triggering mechanisms. To ensure the reliability and manageability of this process, multiple safeguards are required. The primary safeguard is the mandatory guarantee of the startup order, ensuring that the gateway software will not start prematurely before the basic network is ready through service dependency declarations. Simultaneously, integration into the operating system's service framework enables the gateway software to have standardized lifecycle management capabilities, allowing administrators to perform operations such as starting, stopping, and status queries through a unified command interface. To address unexpected failures, an automatic service restart strategy can be configured to attempt recovery when the process exits abnormally. At the security level, restricted user permissions must be specified in the service definition to implement the principle of least privilege. Furthermore, the gateway software's runtime logs should be redirected to the system log system to ensure observability.

[0059] As can be seen from the above, this embodiment of the application backs up the current network configuration by storing the structured data of the current network configuration in a preset independent storage space. This allows the system to restore the network configuration upon restart by retrieving the stored network configuration from the preset independent storage space through a preset configuration recovery process. By reusing existing, verified distribution logic, the development and maintenance costs of new code are greatly reduced, ensuring consistency between the recovery behavior and the real-time configuration behavior. Changes in business rules (such as distribution logic optimization) are automatically reflected in the recovery process. Simultaneously, the error handling mechanism of the original engine is used to handle exceptions during the recovery process. Furthermore, the automatic startup mechanism ensures that the network recovery logic is executed every time the system restarts, eliminating the need for manual intervention and enabling gateway nodes to have full lifecycle configuration autonomy. By using an abstract service management interface to adapt to different systems, decoupling from Linux distributions is achieved, avoiding dependence on the technical details of specific operating systems. This allows for automatic recovery of the network configuration after a system restart and improves adaptability and manageability for different operating system versions.

[0060] See Figure 2 As shown, this application provides a specific method for automatic network configuration recovery, including:

[0061] In this embodiment, the gateway software maintains a structured network configuration object model (including network interface card IP / MAC, routing table entries, firewall rules, GRE tunnel parameters, etc.) in memory. Whenever a network configuration change is successfully applied (regardless of whether it comes from the management interface, API call, or console command), the software not only performs an immediate action, but also immediately writes the change to its own persistent storage area, which is independent of the operating system's network configuration file.

[0062] Gateway software internally defines data structures (e.g., classes, structs, or JSON schemas) to provide fine-grained, object-oriented abstractions of network configuration. For example: `InterfaceConfig`: contains network interface name, status (up / down), IP address (IPv4 / IPv6), subnet mask / prefix, MTU, MAC address, etc. `RouteConfig`: contains target network, gateway, outgoing interface, route type (default, static), metric, etc. `RuleConfig`: contains policy routing rules (source IP, destination IP, priority, table ID, etc.). `GreTunnelConfig`: contains tunnel name, local endpoint IP, remote endpoint IP, tunnel key, etc. `FirewallRuleConfig`: contains chains, tables, rule conditions, actions, etc.

[0063] Furthermore, select a directory that persists after an operating system reboot and that the gateway software has access to (such as / opt / gateway / config / or / var / lib / gateway / ). Use an easily parsable, robust, and version-controlled format, such as a JSON file (network_config.json), a YAML file, or an SQLite database file (config.db). JSON / YAML is easy to read and version-manage; SQLite provides ACID transaction support and query capabilities. Alternatively, use a lightweight key-value database (such as LevelDB, RocksDB) or utilize etcd / Consul (if shared in a cluster environment). The key can be a unique identifier for the configuration item (such as interface:eth0, route:default).

[0064] When a new network configuration request is received (e.g., adding a new IP address), the software first invokes system commands for real-time configuration. Upon success, the corresponding InterfaceConfig object is immediately serialized (e.g., converted to a JSON string) and written to persistent storage (appended to a file or inserted into a database). When the software needs to query the current persistent state or restore it, it reads the entire storage content and deserializes it into a collection of configuration objects in memory. When a request to modify existing configuration is received (e.g., changing the IP address of an interface): a system command is invoked for real-time modification. Upon success, the corresponding old configuration object is located in persistent storage based on the unique identifier in the request (e.g., interface name, target network of the route). The relevant fields in the old object are replaced with the new data. The updated object is written back to persistent storage (overwriting the original record or updating the database row). When a request to delete configuration is received (e.g., deleting a static route): a system command is invoked to delete the real-time configuration. Upon success, the corresponding configuration object record is deleted from persistent storage based on the identifier. It is important to note that persistent operations (especially updates and deletions) should be completed within a single transaction whenever possible (e.g., SQLite transactions or atomic file write operations) to avoid partial writes leading to data corruption. Strictly adhere to the principle of "updating persistent storage only after successful execution of system commands" to ensure eventual consistency between memory state, kernel state, and persistent storage. If a system command fails, persistent storage is not updated, and an error is returned to the requesting party.

[0065] In this embodiment, a dedicated initialization module is built into the gateway software startup process (not the operating system startup process). After the core software logic is loaded and before the network service starts, this module actively reads all network configuration data in the custom persistent storage area. Then, the gateway software completely reuses its regular network configuration distribution logic (i.e., calling the same system command libraries, such as iproute2, iptables / nftables, ip link / set, etc.) to redistribute these persistent configurations to the operating system kernel one by one.

[0066] In the main program startup process of the gateway software, after the initialization phase and before the service running phase, a configuration recovery sub-process is inserted. The specific recovery process steps include:

[0067] Load persistent data: The recovery module accesses the preset persistent storage path and reads all stored network configuration data. It then deserializes or parses this data into a collection of configuration objects (ConfigCollection) in memory.

[0068] Configuration sorting and dependency handling: The loaded configuration objects are sorted topologically, and dependencies are handled. For example: a physical interface (eth0 up) must be configured first before an IP address can be configured on it or it can be used as an outgoing interface for routing. A GRE tunnel interface (gre-tun0) must be created first before its IP address or route can be configured. The routing table (RouteConfig) referenced by policy routing rules (RuleConfig) must exist first.

[0069] Reusing the distribution logic: The gateway software does not write special configuration code for this recovery process. Instead, it converts (or directly constructs) each configuration object in the ConfigCollection into a standard internal request format (InternalRequest) used by the gateway software when processing external requests. Then, these InternalRequests are sequentially sent to the gateway software's original command processing engine (Command Processor) for handling real-time configuration requests.

[0070] Command engine execution: The command processing engine parses each InternalRequest just like it would a user request, and calls the corresponding underlying system command library functions (such as ip addr add ..., ip route add ..., iptables -A ...) to distribute the configuration. The engine's original error handling and logging mechanisms remain in effect during this process.

[0071] Results Processing and Logging: Record the success or failure status of each configuration item issued during the recovery process. For failed items, record detailed error information (such as the reason for command failure, missing dependencies, etc.). A summary report can be output to the software log.

[0072] In this embodiment, to ensure that the gateway software itself can run automatically after the operating system starts, thereby triggering the above-mentioned configuration recovery process, the gateway software needs to be configured as an auto-start service of the Linux system. This is achieved through standard service management tools (such as systemd) or system startup scripts (such as / etc / rc.local).

[0073] Specifically, the gateway software must first be fully registered with the operating system's service management framework. This process requires explicitly defining the service's unique identifier and configuring the gateway software's executable path, startup parameters, and required resource environment. It's crucial to declare strong startup dependencies for the gateway service, mandating that it only start after the operating system's basic network services are fully ready, ensuring network stack availability. After service registration, the service's startup flag must be activated to automatically include it in the operating system's startup sequence. When the system startup meets preset dependency conditions, the operating system's service manager will automatically invoke the gateway software's startup command, initializing it as a background daemon. Conversely, when the system shuts down or restarts, the service manager will automatically trigger preset stop commands, ensuring the gateway software's safe exit.

[0074] Furthermore, to ensure the reliability and manageability of this process, multiple safeguards are required. The primary safeguard is the mandatory guarantee of the startup order, ensuring that the gateway software will not start prematurely before the underlying network is ready through service dependency declarations. Simultaneously, integration into the operating system service framework enables the gateway software to have standardized lifecycle management capabilities, allowing administrators to perform operations such as starting, stopping, and querying status through a unified command interface. To cope with unexpected failures, an automatic service restart policy can be configured to attempt recovery when a process exits abnormally. At the security level, restricted user permissions must be specified in the service definition to implement the principle of least privilege. In addition, the gateway software's runtime logs should be redirected to the system log system to ensure observability. The ultimate value of this feature lies in achieving the integrity of the network autonomous recovery chain. As the sole trigger point from persistent storage to the startup recovery process, the automatic startup mechanism ensures that the network recovery logic is executed every time the system restarts. This eliminates the need for manual intervention, enabling gateway nodes to have autonomous configuration capabilities throughout their entire lifecycle. By adapting to different system implementations through an abstract service management interface, it maintains decoupling from Linux distributions and avoids dependence on the technical details specific to any operating system.

[0075] As can be seen from the above, this application's embodiments abandon traditional persistence methods that directly rely on Linux distribution-specific / etc / network / interfaces, netplan, or NetworkManager configuration files. Instead, the gateway software itself assumes the responsibility of configuration management. By storing the structured data of the current network configuration in a preset independent storage space, the current network configuration is backed up. Upon system restart, a preset configuration recovery process is used to retrieve the stored network configuration from the preset independent storage space, completing the network configuration recovery. By reusing existing, verified distribution logic, the development and maintenance costs of new code are greatly reduced, ensuring consistency between recovery behavior and real-time configuration behavior; changes in business rules (such as distribution logic optimization) are automatically reflected in the recovery process. Simultaneously, the original engine's error handling mechanism is used to handle exceptions during the recovery process. Furthermore, the automatic startup mechanism ensures that the network recovery logic is executed every time the system restarts, eliminating the need for manual intervention and enabling the gateway node to have full lifecycle configuration autonomy. Through an abstract service management interface adapted to different systems, decoupling from Linux distributions is achieved, avoiding dependence on the technical details of specific operating systems. This allows the network configuration to be automatically restored after a system restart, and improves adaptability and manageability for different operating system versions.

[0076] See Figure 3 As shown in the figure, this application discloses a network configuration automatic recovery device, including:

[0077] The network configuration execution module 11 is used to obtain a network configuration request for a target network configuration and to call system commands based on the network configuration request to execute a network configuration operation for the target network configuration; the network configuration request includes a creation request, an update request, and a deletion request; the target network configuration includes interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration.

[0078] The network configuration storage module 12 is used to persistently store the structured data of the current target network configuration to a preset independent storage space if the network configuration operation is successfully executed.

[0079] The network configuration recovery module 13 is used to execute a preset configuration recovery process when the operating system where the gateway software is located restarts, so as to read the structured data of the stored network configuration from the preset independent storage space, and re-send the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

[0080] In some specific embodiments, the network configuration storage module 12 may specifically include:

[0081] The first configuration storage unit is used to append the structured data of the corresponding newly added configuration object to the preset independent storage space if the network configuration request is a creation request.

[0082] The second configuration storage unit is used to locate and replace the structured data of the corresponding original network configuration object from the preset independent storage space using the unique identifier in the network configuration request if the network configuration request is an update request.

[0083] The third configuration storage unit is used to locate and delete the structured data of the corresponding original network configuration object from the preset independent storage space if the network configuration request is a deletion request.

[0084] In some specific embodiments, the network configuration recovery module 13 may specifically include:

[0085] The network configuration data reading unit is used to access the preset independent storage space based on the preset independent storage space path, and parse the data in the preset independent storage space into a set of network configuration objects to complete the reading of the structured data of the stored network configuration.

[0086] The configuration distribution order determination unit is used to sort the structured data of the read network configuration in the topology so as to determine the distribution order based on the dependencies between configuration items;

[0087] The configuration distribution unit is used to re-distribute the stored network configuration to the operating system based on the distribution order through a preset multiplexing distribution logic to complete the network configuration recovery; the preset multiplexing distribution logic is to parse the stored network configuration into a network configuration request and call system commands based on the network configuration request to perform network configuration operations.

[0088] In some specific implementations, the preset independent storage space uses a storage format of JSON file, YAML file, or SQLite database;

[0089] Accordingly, the network configuration automatic recovery device may further include:

[0090] The first configuration data processing unit is used to serialize network configuration data to obtain a corresponding structured object when the storage format is JSON or YAML file, and write the structured object into a preset configuration file.

[0091] The second configuration data processing unit is used to create corresponding data tables for different types of network configuration objects when the storage format adopts an SQLite database, and to store the configuration records into the corresponding data tables.

[0092] The self-starting unit is used to register the gateway software as a self-starting service of the operating system, and use the self-starting service to automatically run the gateway software when the operating system restarts, so as to trigger the network configuration recovery process.

[0093] Furthermore, embodiments of this application also disclose an electronic device, Figure 4 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the network configuration automatic recovery method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be a computer.

[0094] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.

[0095] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.

[0096] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the automatic network configuration recovery method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include a computer program capable of performing other specific tasks.

[0097] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned network configuration automatic recovery method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.

[0098] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.

[0099] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software 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.

[0100] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0101] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0102] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A method for automatic network configuration recovery, characterized in that, Applied to gateway software, including: Obtain a network configuration request for the target network configuration, and invoke system commands based on the network configuration request to execute network configuration operations for the target network configuration; the network configuration request includes a creation request, an update request, and a deletion request; the target network configuration includes interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration; If the network configuration operation is successfully executed, the structured data of the current target network configuration will be persistently stored in a preset independent storage space. When the operating system where the gateway software resides restarts, a preset configuration recovery process is executed to read the structured data of the stored network configuration from the preset independent storage space, and to re-download the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

2. The automatic network configuration recovery method according to claim 1, characterized in that, The step of persistently storing the structured data of the current target network configuration to a preset independent storage space includes: If the network configuration request is a creation request, the structured data of the corresponding newly added configuration object will be appended to the preset independent storage space; If the network configuration request is an update request, the unique identifier in the network configuration request is used to locate and replace the structured data of the corresponding original network configuration object in the preset independent storage space; If the network configuration request is a deletion request, the structured data of the corresponding original network configuration object is located and deleted from the preset independent storage space using the unique identifier in the network configuration request.

3. The automatic network configuration recovery method according to claim 1, characterized in that, The execution of the preset configuration recovery process, to read the structured data of the stored network configuration from the preset independent storage space, includes: The system accesses the preset independent storage space based on the preset independent storage space path and parses the data in the preset independent storage space into a set of network configuration objects to complete the reading of the structured data of the stored network configuration.

4. The automatic network configuration recovery method according to claim 1, characterized in that, After executing the preset configuration recovery process to read the structured data of the stored network configuration from the preset independent storage space, the process further includes: The structured data of the read network configuration is sorted by topology to determine the distribution order based on the dependencies between configuration items.

5. The automatic network configuration recovery method according to claim 4, characterized in that, The step of re-deploying the stored network configuration to the operating system through a preset multiplexing and distribution logic to restore the network configuration includes: The stored network configuration is re-distributed to the operating system based on the distribution order using a preset reuse distribution logic, thereby restoring the network configuration. The preset multiplexing and distribution logic is to parse the stored network configuration into a network configuration request, and then call system commands based on the network configuration request to perform network configuration operations.

6. The automatic network configuration recovery method according to claim 1, characterized in that, The preset independent storage space uses JSON files, YAML files, or SQLite databases as storage formats. The method further includes: When the storage format is JSON or YAML file, the network configuration data is serialized to obtain the corresponding structured object, and the structured object is written into the preset configuration file; When the storage format uses an SQLite database, corresponding data tables are created for different types of network configuration objects, and configuration records are stored in the corresponding data tables.

7. The automatic network configuration recovery method according to any one of claims 1 to 6, characterized in that, Also includes: The gateway software is registered as an operating system startup service, and the startup service is used to automatically run the gateway software when the operating system restarts, thereby triggering the network configuration recovery process.

8. A network configuration automatic recovery device, characterized in that, include: The network configuration execution module is used to obtain network configuration requests for a target network configuration and, based on the network configuration requests, call system commands to execute network configuration operations for the target network configuration; the network configuration requests include creation requests, update requests, and deletion requests; the target network configuration includes interface configuration, routing configuration, policy routing rule configuration, GRE tunnel configuration, and firewall rule configuration; The network configuration storage module is used to persistently store the structured data of the current target network configuration to a preset independent storage space if the network configuration operation is successfully executed. The network configuration recovery module is used to execute a preset configuration recovery process when the operating system where the gateway software is located restarts. This process reads the structured data of the stored network configuration from the preset independent storage space and re-distributes the stored network configuration to the operating system through a preset reuse and distribution logic to complete the network configuration recovery.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the automatic network configuration recovery method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the automatic network configuration recovery method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Redundant system boot code in a secondary non-volatile memory

    CN105122262A

  • Method for automatic configuration or restoring of computer system network configuration

    CN1512379A

  • Method and system for duplicating and recovering network element configuration data

    CN1815974A

  • Resuming testing after a destructive event

    US9983988B1

  • Automated SSD recovery

    WO2024177778A2

Cited By

  • Method for enhancing reliability of IPv6 gateway in dual-stack mode of cloud data center

    CN121690979A

  • A service recovery method and apparatus

    CN122349042A