Summary of the invention
This application provides a kind of IP address conversion method and device of network equipment, can be used for solving in the prior artPartial network devices lead to not realize the technical issues of converting between IPv4 and IPv6 due to not supporting tunneling technique.
In a first aspect, the embodiment of the present application provides a kind of IP address conversion method of network equipment, which comprises
Obtain the original ip address of the network equipment;
According to the corresponding IP agreement version of the original ip address and the corresponding IP agreement version of target ip address, two are determinedTransfer algorithm between a IP agreement version;
The original ip address is converted according to the transfer algorithm, obtains the target ip address corresponding firstField groups;
According to the position letter of the network type and the network equipment of the network equipment belonging network in the networkBreath, determines corresponding second field groups of the target ip address;
First field groups and second field groups are combined, the target ip address is obtained.
In one possible implementation, the corresponding IP agreement version of the original ip address is IPv4, the targetThe corresponding IP agreement version of IP address is IPv6;Or, the corresponding IP agreement version of the original ip address is IPv6, the targetThe corresponding IP agreement version of IP address is IPv4.
In one possible implementation, according to the corresponding IP agreement version of the original ip address and target ip addressCorresponding IP agreement version, determines the transfer algorithm between two IP agreement versions, comprising:
If the corresponding IP agreement version of the original ip address is IPv4, the corresponding IP agreement version of the target ip addressThis is IPv6, it is determined that the transfer algorithm between two IP agreement versions is that the decimal system turns hexadecimal algorithm;
If the corresponding IP agreement version of the original ip address is IPv6, the corresponding IP agreement version of the target ip addressThis is IPv4, it is determined that the transfer algorithm between two IP agreement versions is that hexadecimal turns metric algorithm.
In one possible implementation, the network type of the network equipment belonging network include Types of Local Area Networks andWan type;
According to the position letter of the network type and the network equipment of the network equipment belonging network in the networkBreath, determines corresponding second field groups of the target ip address, comprising:
If the network type of the network equipment belonging network is Types of Local Area Networks, according to the network equipment in instituteThe location information in local area network is stated, determines corresponding second field groups of the target ip address;
If the network type of the network equipment belonging network is wan type, according to belonging to the wide area networkThe mark and location information of the network equipment in the wide area network of operator determine the target ip address corresponding theTwo field groups.
In one possible implementation, first field groups and second field groups are combined, are obtainedThe target ip address, comprising:
Using first field groups as the suffix of the target ip address, using second field groups as the targetThe prefix of IP address, combination obtain the target ip address.
Second aspect, the embodiment of the present application provide a kind of IP address conversion device of network equipment, and described device includes:
Acquiring unit, for obtaining the original ip address of the network equipment;
Processing unit, for being assisted according to the corresponding IP agreement version of the original ip address and the corresponding IP of target ip addressVersion is discussed, determines the transfer algorithm between two IP agreement versions;And according to the transfer algorithm to the original ip addressIt is converted, obtains corresponding first field groups of the target ip address;And the net according to the network equipment belonging networkThe location information of network type and the network equipment in the network determines corresponding second field of the target ip addressGroup;
Assembled unit obtains the Target IP for being combined first field groups and second field groupsAddress.
In one possible implementation, the corresponding IP agreement version of the original ip address is IPv4, the targetThe corresponding IP agreement version of IP address is IPv6;Or, the corresponding IP agreement version of the original ip address is IPv6, the targetThe corresponding IP agreement version of IP address is IPv4.
In one possible implementation, the processing unit is specifically used for:
If the corresponding IP agreement version of the original ip address is IPv4, the corresponding IP agreement version of the target ip addressThis is IPv6, it is determined that the transfer algorithm between two IP agreement versions is that the decimal system turns hexadecimal algorithm;
If the corresponding IP agreement version of the original ip address is IPv6, the corresponding IP agreement version of the target ip addressThis is IPv4, it is determined that the transfer algorithm between two IP agreement versions is that hexadecimal turns metric algorithm.
In one possible implementation, the network type of the network equipment belonging network include Types of Local Area Networks andWan type;
The processing unit is specifically used for:
If the network type of the network equipment belonging network is Types of Local Area Networks, according to the network equipment in instituteThe location information in local area network is stated, determines corresponding second field groups of the target ip address;
If the network type of the network equipment belonging network is wan type, according to belonging to the wide area networkThe mark and location information of the network equipment in the wide area network of operator determine the target ip address corresponding theTwo field groups.
In one possible implementation, the assembled unit is specifically used for:
Using first field groups as the suffix of the target ip address, using second field groups as the targetThe prefix of IP address, combination obtain the target ip address.
It can be according to the corresponding IP of original ip address after the original ip address for obtaining the network equipment using the above methodProtocol version and the corresponding IP agreement version of target ip address, determine the transfer algorithm between two IP agreement versions, Jin ErkeTo be converted according to transfer algorithm to original ip address, obtaining corresponding first field groups of target ip address further canWith the location information according to the network type of network equipment belonging network and the network equipment in a network, target ip address pair is determinedFirst field groups and the second field groups can be finally combined, to obtain target ip address by the second field groups answered.Such asThis, in terms of existing technologies, the embodiment of the present application supports two different protocol stacks without the network equipment simultaneously, also just notIt needs to carry out HardwareUpgring to the network equipment, so that it may realize and convert between the IP address between different IP agreement versions.
Specific embodiment
To keep the purposes, technical schemes and advantages of the application clearer, below in conjunction with attached drawing to the application embodiment partyFormula is described in further detail.
Fig. 1 is illustrated corresponding to a kind of IP address conversion method of network equipment provided by the embodiments of the present applicationFlow diagram.As shown in Figure 1, specifically comprising the following steps:
Step 101, the original ip address of the network equipment is obtained.
Step 102, according to the corresponding IP agreement version of original ip address and the corresponding IP agreement version of target ip address, reallyTransfer algorithm between fixed two IP agreement versions.
Step 103, original ip address is converted according to transfer algorithm, obtains corresponding first field of target ip addressGroup.
Step 104, the position letter according to the network type of network equipment belonging network and the network equipment in the networkBreath, determines corresponding second field groups of target ip address.
Step 105, the first field groups and the second field groups are combined, obtain target ip address.
It should be noted that method provided by the embodiments of the present application, on the one hand, can be corresponded to not changing original ip addressIP agreement version under conditions of, using the setting method of original ip address, target ip address is set;On the other hand, Ke YiIt supports that target is arranged using the setting method of original ip address in the network equipment of the corresponding IP agreement version of target ip addressIP address.
It can be according to the corresponding IP of original ip address after the original ip address for obtaining the network equipment using the above methodProtocol version and the corresponding IP agreement version of target ip address, determine the transfer algorithm between two IP agreement versions, Jin ErkeTo be converted according to transfer algorithm to original ip address, obtaining corresponding first field groups of target ip address further canWith the location information according to the network type of network equipment belonging network and the network equipment in a network, target ip address pair is determinedFirst field groups and the second field groups can be finally combined, to obtain target ip address by the second field groups answered.Such asThis, in terms of existing technologies, the embodiment of the present application supports two different protocol stacks without the network equipment simultaneously, also just notIt needs to carry out HardwareUpgring to the network equipment, so that it may realize and convert between the IP address between different IP agreement versions.
Specifically, in step 101, the network equipment can refer to the physical entity being connected in network.Embedded deviceIt is a kind of network equipment, in today that IPv6 is continued to develop, the embedded device of many low costs is not the case where changing hardwareUnder, equally there are the needs that the corresponding protocol version of the IP address of itself is upgraded to IPv6.
According to the difference of network device itself structure, there are many modes for obtaining the original ip address of the network equipment.It is a kind ofPossible implementation is, for the network equipment with display device, can directly be shown by the display deviceOriginal ip address, so as to obtain the original ip address by way of reading.
For example, the Embedded Network Device of some low costs can only generally be repaired by simple LED display screenChange IP address, then, for these network equipments, so that it may read original ip address on LED display.
Alternatively possible implementation is, for it cannot directly read the network equipment of IP address, can useThe mode of external interface obtains the original ip address of the network equipment.Specifically, the network equipment can be connected by external interfaceComputer is connect, in this way, computer passes through the original ip address of the available network equipment of the external interface.Wherein, to diplomacyInterface may include any one of telnet interface or web page interface etc., specifically without limitation.
Further, in specific implementation process, computer can be used the original ip address that protocol stack will acquire and carry outStorage.Wherein, protocol stack can be lwip2.0.3 protocol stack, the lwip2.0.3 protocol stack can support simultaneously IPv4 andIPv6。
In step 102 and step 103, original IP address and the corresponding IP agreement version of target ip address can haveDifferent forms.In one example, the corresponding IP agreement version of original ip address can be IPv4, the corresponding IP of target ip addressProtocol version can be IPv6.
Further, if the corresponding IP agreement version of original ip address is IPv4, the corresponding IP agreement of target ip addressWhen version is IPv6, it can determine that the transfer algorithm between two IP agreement versions is that the decimal system turns hexadecimal algorithm.
For example, it is assumed that original ip address is " 192.168.0.155 ", turns hexadecimal algorithm through the decimal system and convertsAfterwards, " C0A8:009B " is obtained, i.e., " C0A8:009B " can be used as corresponding first field groups of target ip address.
In another example, the corresponding IP agreement version of original ip address can be IPv6, the corresponding IP of target ip addressProtocol version can be IPv4.
Further, if the corresponding IP agreement version of original ip address is IPv6, the corresponding IP agreement of target ip addressWhen version is IPv4, it can determine that the transfer algorithm between two IP agreement versions is that hexadecimal turns metric algorithm.
For example, it is assumed that original ip address is " C0A8:009B ", after hexadecimal turns metric algorithm conversion," 192.168.0.155 " is obtained, i.e., " 192.168.0.155 " can be used as corresponding first field groups of target ip address.
In step 104, the network type of network equipment belonging network may include Types of Local Area Networks and wan type.
Wherein, local area network can refer to the calculating unit being mutually unified into a certain region by multiple stage computers, for example, beIn the geographic range of one part (such as in school, factory and an organ), usually have an area of within several kms, by various calculatingMachine, external equipment and database etc. link up mutually the computer communication network of composition.Local area network may be implemented file management, answerWith functions such as software is shared, sharing printer, schedule, Email and facsimile services in working group.Local area networkBe it is case type, can be made of indoor two computers of handling official business, can also be by thousands of calculating units in a companyAt.
Wide area network is also known as wide area network, outer net, public network.Be connect different regions local area network or Metropolitan Area Network (MAN) computer communication it is remoteJourney net.The usually very big physical extent of bridging, from tens kilometers to thousands of kilometers, it can be connected multiplely the range coveredArea, city and country, or across several continents, and telecommunication can be provided, form international telecommunication network.
According to the difference of the network type of network equipment belonging network, the determination of corresponding second field groups of target ip addressMode is also different.
If the network type of network equipment belonging network is Types of Local Area Networks, can be according to the network equipment in local area networkIn location information, determine corresponding second field groups of target ip address.
If the network type of network equipment belonging network is wan type, the operator according to belonging to wide area networkMark and the location information of the network equipment in the wide area network, determine corresponding second field groups of target ip address.
It should be noted that during actual implementation, the second field groups can be to be obtained automatically by software.For example,The second field groups can be obtained using following procedure code.
For example, using code as above " g_unIPV6head [0]=ABCDEF01;G_unIPV6head [1]=23456789;G_unIPV6head [2]=ABCDEF01 " obtain the second field groups can for " ABCD:EF01:2345:6789:ABCD:EF01”。
In step 105, there are many modes that the first field groups and the second field groups are combined, a kind of possible realizationMode is, can be using the first field groups as the suffix of target ip address, using the second field groups as the target ip addressPrefix, combination obtain target ip address.
For example, it is assumed that the first field groups be " C0A8:009B ", the second field groups be " ABCD:EF01:2345:6789:ABCD:EF01 ", then, the target ip address obtained after combination can for " ABCD:EF01:2345:6789:ABCD:EF01:C0A8:009B”。
It, can also be using the first field groups as the prefix of target ip address, by second in other possible implementationsSuffix of the field groups as the target ip address, combination obtain target ip address;Alternatively, the first field groups can also be inserted intoTo any position in the second field groups, combination obtains target ip address, specifically without limitation.
During actual implementation, the combination of the first field groups and the second field groups is also possible to obtain automatically by software's.For example, can be realized using following procedure code.
It should be noted that " ... " in above-mentioned code is the logical code of software itself, the application no longer retouches in detailIt states.
After executing above-mentioned steps 105, target ip address can also be set to the IP address of the network equipment, in this way,The network equipment can be communicated using target ip address.
Following is the application Installation practice, can be used for executing the application embodiment of the method.It is real for the application deviceUndisclosed details in example is applied, the application embodiment of the method is please referred to.
The structure that Fig. 2 illustrates a kind of IP address conversion device of network equipment provided by the embodiments of the present application is shownIt is intended to.As shown in Fig. 2, the device has the function of realizing the IP address conversion method of the above-mentioned network equipment, the function can be withBy hardware realization, corresponding software realization can also be executed by hardware.The apparatus may include: acquiring unit 201, processing unit202 and assembled unit 203.
Acquiring unit 201, for obtaining the original ip address of the network equipment;
Processing unit 202, for corresponding according to the corresponding IP agreement version of the original ip address and target ip addressIP agreement version determines the transfer algorithm between two IP agreement versions;And according to the transfer algorithm to the initial IPAddress is converted, and corresponding first field groups of the target ip address are obtained;And according to the network equipment belonging networkLocation information in the network of network type and the network equipment, determine corresponding second word of the target ip addressSection group;
Assembled unit 203 obtains the target for being combined first field groups and second field groupsIP address.
In one possible implementation, the corresponding IP agreement version of the original ip address is IPv4, the targetThe corresponding IP agreement version of IP address is IPv6;Or, the corresponding IP agreement version of the original ip address is IPv6, the targetThe corresponding IP agreement version of IP address is IPv4.
In one possible implementation, the processing unit 202 is specifically used for:
If the corresponding IP agreement version of the original ip address is IPv4, the corresponding IP agreement version of the target ip addressThis is IPv6, it is determined that the transfer algorithm between two IP agreement versions is that the decimal system turns hexadecimal algorithm;
If the corresponding IP agreement version of the original ip address is IPv6, the corresponding IP agreement version of the target ip addressThis is IPv4, it is determined that the transfer algorithm between two IP agreement versions is that hexadecimal turns metric algorithm.
In one possible implementation, the network type of the network equipment belonging network include Types of Local Area Networks andWan type;
The processing unit 202 is specifically used for:
If the network type of the network equipment belonging network is Types of Local Area Networks, according to the network equipment in instituteThe location information in local area network is stated, determines corresponding second field groups of the target ip address;
If the network type of the network equipment belonging network is wan type, according to belonging to the wide area networkThe mark and location information of the network equipment in the wide area network of operator determine the target ip address corresponding theTwo field groups.
In one possible implementation, the assembled unit 203 is specifically used for:
Using first field groups as the suffix of the target ip address, using second field groups as the targetThe prefix of IP address, combination obtain the target ip address.
Using above-mentioned apparatus, which, can be according to original ip address pair after the original ip address for obtaining the network equipmentThe corresponding IP agreement version of the IP agreement version and target ip address answered, determines the transfer algorithm between two IP agreement versions,And then original ip address can be converted according to transfer algorithm, corresponding first field groups of target ip address are obtained, into oneStep ground can determine target according to the location information of the network type and the network equipment of network equipment belonging network in a networkFirst field groups and the second field groups, can finally be combined, to obtain target by corresponding second field groups of IP addressIP address.In this way, in terms of existing technologies, the embodiment of the present application supports two different agreements without the network equipment simultaneouslyStack, also there is no need to carry out HardwareUpgring to the network equipment, so that it may realize between the IP address between different IP agreement versionsConversion.
In the exemplary embodiment, a kind of computer readable storage medium is additionally provided, is stored in the storage mediumComputer program or intelligent contract, the computer program or intelligent contract are loaded and executed by nodes to realize above-described embodimentThe transaction methods of offer.Optionally, above-mentioned computer readable storage medium can be read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), CD-ROM, tape, floppy disk andOptical data storage devices etc..
It is required that those skilled in the art can be understood that the technology in the embodiment of the present application can add by softwareThe mode of general hardware platform realize.Based on this understanding, the technical solution in the embodiment of the present application substantially orSay that the part that contributes to existing technology can be embodied in the form of software products, which can depositStorage is in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are used so that computer equipment (can be withIt is personal computer, server or the network equipment etc.) execute certain part institutes of each embodiment of the application or embodimentThe method stated.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the disclosureIts embodiment.This application is intended to cover any variations, uses, or adaptations of the disclosure, these modifications, purposes orPerson's adaptive change follows the general principles of this disclosure and including the undocumented common knowledge in the art of the disclosureOr conventional techniques.The description and examples are only to be considered as illustrative, and the true scope and spirit of the disclosure are by followingClaim is pointed out.
It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, andAnd various modifications and changes may be made without departing from the scope thereof.The scope of the present disclosure is only limited by the accompanying claims.