CN-122027599-A - Network address conversion method, device, computer equipment and storage medium
Abstract
The application provides a network address translation method, a device, computer equipment and a storage medium, which are characterized in that domain name-address mapping information is obtained from a server, first network address information containing a domain name and corresponding IPv4 address and IPv6 address is extracted, and then the first network address information is compared with locally stored second network address information, and the difference between the first network address information and the second network address information is automatically identified, so that NAT64 rules to be added and deleted are determined, the problems of relying on manual comparison and manually maintaining NAT64 rules in the prior art are avoided, the configuration efficiency of the network address translation rules is obviously improved, and the adaptability to network environment changes is enhanced.
Inventors
- WU XIANQI
Assignees
- 杭州迪普科技股份有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260204
Claims (10)
- 1. A method of network address translation, the method comprising: Acquiring domain name-address mapping information from a server, and extracting first network address information from the domain name-address mapping information, wherein the first network address information comprises a plurality of domain names, and IPv4 addresses and IPv6 addresses corresponding to the domain names; Comparing the locally stored second network address information with the first network address information to obtain difference information between the second network address information and the first network address information; based on the difference information, determining network address translation NAT64 rules to be added and deleted; generating an NAT64 rule modification request based on the NAT64 rules to be added and deleted; and sending the NAT64 rule modification request to the server so that the server modifies the stored NAT64 rule of the current terminal, wherein the NAT64 rule is used for converting the access request of the current terminal for the IPv4 address into the access request of the corresponding IPv6 address.
- 2. The method of claim 1, wherein the extracting the first network address information from the domain name-address mapping information comprises: extracting a plurality of domain names from the domain name-address mapping information based on a regular expression, and IPv4 addresses and IPv6 addresses corresponding to the domain names; performing data cleaning on the extracted multiple domain names, and the IPv4 addresses and the IPv6 addresses corresponding to the domain names, and filtering invalid addresses; and converting the filtered multiple domain names, and the IPv4 addresses and the IPv6 addresses corresponding to the domain names into structured data to obtain the first network address information.
- 3. The method of claim 1, wherein said comparing the locally stored second network address information with the first network address information to obtain difference information between the second network address information and the first network address information comprises: Comparing the locally stored second network address information with the first network address information, and screening out a newly added domain name and a domain name with changed IPv4 address or IPv6 address from the first network address information; and determining the difference information based on the screened domain name and the IPv4 address and the IPv6 address corresponding to the domain name.
- 4. The method of claim 3, wherein the determining network address translation NAT64 rules to be added and to be deleted based on the difference information comprises: aiming at the newly added domain name and the domain name with the IPv4 address or the IPv6 address changed, generating a corresponding NAT64 rule to be newly added based on the corresponding IPv4 address and IPv6 address; for the domain name with the changed IPv4 address or IPv6 address, the NAT64 rule stored on the server is determined to be the rule to be deleted.
- 5. The method of claim 4, wherein the generating the NAT64 rule for the new domain name and the domain name with the changed IPv4 address or IPv6 address based on the corresponding IPv4 address and IPv6 address comprises: Under the condition that the domain name corresponds to a plurality of IPv6 addresses, randomly extracting an IPv6 address from the corresponding plurality of IPv6 addresses aiming at any IPv4 address of the domain name, and associating the IPv4 address with the extracted IPv6 address to obtain the NAT64 rule to be newly added corresponding to the IPv4 address.
- 6. The method of claim 1, wherein the obtaining domain name-address mapping information from the server comprises: establishing a communication connection with the server based on a secure shell protocol SSH; And acquiring the domain name-address mapping information based on the communication connection.
- 7. The method of claim 6, wherein the method further comprises: And under the condition that the server responds to the overtime of the communication connection and/or acquires the overtime of the domain name-address mapping information, interrupting the communication and reporting errors.
- 8. A network address translation device, comprising: the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring domain name-address mapping information from a server and extracting first network address information from the domain name-address mapping information, wherein the first network address information comprises a plurality of domain names, and IPv4 addresses and IPv6 addresses corresponding to the domain names; the comparison module is used for comparing the locally stored second network address information with the first network address information to obtain difference information between the second network address information and the first network address information; The determining module is used for determining network address translation NAT64 rules to be added and deleted based on the difference information; The generating module is used for generating an NAT64 rule modification request based on the NAT64 rules to be added and deleted; And the sending module is used for sending the NAT64 rule modification request to the server so as to enable the server to modify the stored NAT64 rule of the current terminal, wherein the NAT64 rule is used for converting the access request of the current terminal for the IPv4 address into the corresponding access request for the IPv6 address.
- 9. A computer device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any of claims 1 to 7 when the program is executed.
- 10. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
Description
Network address conversion method, device, computer equipment and storage medium Technical Field The present application relates to the field of computer technologies, and in particular, to a network address translation method, a device, a computer device, and a storage medium. Background With the continuous exhaustion of IPv4 address resources and the gradual deployment of IPv6 networks, the existing network environment is generally in a transition stage where IPv4 and IPv6 coexist. In this transition phase, a large number of terminals are still mainly based on the IPv4 protocol, and more servers and network resources are already deployed in the IPv6 network, thereby creating an interworking requirement for the IPv4 terminals to access the IPv6 resources. Network address translation technology, particularly NAT64 technology, is an important means to achieve interworking between IPv4 and IPv6 networks. In the prior art, the NAT64 rule is usually maintained by manual configuration or static policy, i.e. by pre-configuring the mapping relationship between the IPv4 address and the IPv6 address, the terminal can complete protocol conversion through the NAT64 gateway. However, this approach has significant drawbacks in practical applications. On the one hand, as domain name based access methods are becoming more common, the same domain name may correspond to multiple IPv4 addresses or IPv6 addresses, and the addresses may change frequently due to load balancing, content distribution network or operation and maintenance adjustment, so that the static configuration NAT64 rule cannot reflect the real address mapping relationship in time. On the other hand, when the domain name resolution result is changed, the prior art needs to manually compare the new configuration with the old configuration and manually update the NAT64 rule, which has low configuration efficiency and is easy to generate omission or error. Disclosure of Invention In view of the above, the present application provides a network address translation method, apparatus, computer device and storage medium, so as to solve the problems of low NAT64 configuration efficiency and insufficient dynamic adaptation capability in the prior art. Specifically, the application is realized by the following technical scheme: in a first aspect, an embodiment of the present application provides a network address translation method, including: Acquiring domain name-address mapping information from a server, and extracting first network address information from the domain name-address mapping information, wherein the first network address information comprises a plurality of domain names, and IPv4 addresses and IPv6 addresses corresponding to the domain names; Comparing the locally stored second network address information with the first network address information to obtain difference information between the second network address information and the first network address information; based on the difference information, determining network address translation NAT64 rules to be added and deleted; generating an NAT64 rule modification request based on the NAT64 rules to be added and deleted; and sending the NAT64 rule modification request to the server so that the server modifies the stored NAT64 rule of the current terminal, wherein the NAT64 rule is used for converting the access request of the current terminal for the IPv4 address into the access request of the corresponding IPv6 address. In some embodiments, the extracting the first network address information from the domain name-address mapping information includes: extracting a plurality of domain names from the domain name-address mapping information based on a regular expression, and IPv4 addresses and IPv6 addresses corresponding to the domain names; performing data cleaning on the extracted multiple domain names, and the IPv4 addresses and the IPv6 addresses corresponding to the domain names, and filtering invalid addresses; and converting the filtered multiple domain names, and the IPv4 addresses and the IPv6 addresses corresponding to the domain names into structured data to obtain the first network address information. In some embodiments, the comparing the locally stored second network address information with the first network address information to obtain difference information between the second network address information and the first network address information includes: Comparing the locally stored second network address information with the first network address information, and screening out a newly added domain name and a domain name with changed IPv4 address or IPv6 address from the first network address information; and determining the difference information based on the screened domain name and the IPv4 address and the IPv6 address corresponding to the domain name. In some embodiments, the determining the NAT64 rule for network address translation to be added and deleted based on the differen