Solve the method for IP address conflict in the network service
Technical field
The present invention relates to network communications technology field, relate in particular to the method that solves IP address conflict in a kind of network service.
Background technology
In the Ethernet that uses static IP (Internet protocol) address assignment, IP address conflict is the something that is easy to take place.For solving the IP address conflict problem, usually the method that adopts is the IP address and MAC (medium access control) address of every host name of registration, main frame, so that when IP address conflict takes place, can find the main frame that IP address conflict takes place very soon, and adjust accordingly.Yet in actual applications, the method that the above-mentioned IP of preventing address clashes also not exclusively is suitable for.
For example, as shown in Figure 1, A and C are two main frames in the local area network (LAN), and B is a User Mode Linux (user model operating system) fictitious host computer that runs on the A, and host A, B and C are connected in the same Ethernet.The IP address of fictitious host computer B and MAC Address can be set arbitrarily by the user of operation fictitious host computer, like this, the user for fictitious host computer B IP address set probably with Ethernet in the IP address of other main frames clash, IP address and MAC Address referring to each main frame that provides among Fig. 1, wherein the IP address of host B and C clashes, like this, other main-machine communication may interrupt because of IP address conflict on host C and this local area network (LAN).And in this case, because fictitious host computer B do not register its host name, IP address and MAC Address, so webmaster is difficult to find the main frame that the IP address with host C clashes.The appearance of IP address conflict shown in Figure 1 will make the network administration and maintenance difficulty strengthen, and the reliability of communication also can't be guaranteed.
Lift an example again, as shown in Figure 2, the IP address field 192.168.0.0/16 in the Ethernet wherein is the local area network (LAN) of certain company, is wherein moving some important use, as conferencing over ip phone etc.; Wherein host B is a server, and router C is an experimental equipment, and its Ethernet interface is connected on the internal lan, and another Ethernet interface is missed an address that is made as on the 192.168.4.0 network segment by the staff.Like this, this router just has one to the 192.168.4.0 route table items.When host A was attempted to communicate by letter with server B, according to the setting of main frame, the IP address of server was 192.168.4.4, and host A can be broadcasted the MAC Address of an ARP request inquiry 192.168.4.4.This ARP request is routed device C and server B is received simultaneously, and have a route to 192.168.4.0 owing to router this moment, and therefore, router C can return the arp response message at once.Equally, server B also can be returned the arp response message, but the reaction speed of router is faster than server usually, after so host A is received the arp response message of router C, just packet has been issued router C, and the server B that should receive this packet can't be received the packet from host A.Therefore, host A can't be communicated by letter with server B, cause the service failure of server B, and the service that the main frame of any use server B all can't normally use it to provide is provided.And can't fundamentally prevent the appearance of this type of problem based on the method that prior art provided.
Summary of the invention
The purpose of this invention is to provide in a kind of network service the method that solves IP address conflict, thereby avoid effectively causing network failure because of the conflict of the IP address of the main frame in the network or the network equipment.
The object of the present invention is achieved like this:
The invention provides the method that solves IP address conflict in a kind of network service, comprising:
A, set up the main frame and IP (Internet protocol) address of the network equipment and the corresponding relation of MAC (medium access control) address that move in the network;
B, control the communication of each main frame and the network equipment according to the corresponding relation of setting up.
Described steps A comprises:
In arbitrary the network equipment or any main frame, set up each main frame and the IP address of the network equipment and the corresponding relation of MAC Address that the needs that move in the network prevent that the IP address from clashing.
Among the present invention, the corresponding relation of steps A described IP address and MAC Address is preserved with the form of table.
Described steps A also comprises:
When the needs that increase or reduce operation in the network prevent the main frame that the IP address clashes or the network equipment, then need artificial or automatically the corresponding relation of the IP address of the main frame set up and the network equipment and MAC Address is increased accordingly or reduce processing, and IP address and MAC Address that the IP address that relates to of the corresponding relation that increases newly and MAC Address and the corresponding relation that existed relate to are inequality.
Among the present invention, the described IP address and the corresponding relation of MAC Address to the main frame set up and the network equipment of steps A increases accordingly to handle and comprises:
Each main frame that A1, traversal have been set up and the IP address and the MAC Address of the network equipment;
A2, judge whether to exist IP address or the MAC Address identical with MAC Address with the IP address of the main frame that increases newly or the network equipment, if exist, execution in step A3, otherwise, execution in step A4;
A3, do not increase processing accordingly;
A4, the main frame that increases newly or the IP address of the network equipment and the corresponding relation of MAC Address are increased in the corresponding relation of having set up.
Described steps A 3 further comprises:
Whether the IP address of the list item record that IP address that the IP address with the main frame that increases newly or the network equipment that A31, further judgement exist is identical with MAC Address or MAC Address are corresponding and MAC Address be identical with the IP address and the MAC Address of the main frame that increases newly or the network equipment fully, if, execution in step A32 then, otherwise execution in step A33;
A32, judge whether the IP address of described list item record and the corresponding relation of MAC Address are unavailable, if, then its be set to available, otherwise, execution in step A33;
A33, do not increase processing accordingly, promptly the main frame that increases newly or the IP address of the network equipment and the corresponding relation of MAC Address are not increased in the corresponding relation of having set up.
The described IP address and the corresponding relation of MAC Address to each main frame set up and the network equipment reduces accordingly and is treated to: the corresponding relation deletion of the corresponding main frame that will set up or the IP address of the network equipment and MAC Address or be set to unavailable.
Described step B comprises:
B1, when main frame or the network equipment need send message, send ARP (address resolution protocol) request message to the network equipment or the main frame of IP address that establishes each main frame and the network equipment and MAC Address corresponding relation;
The network equipment or the main frame of B2, the IP address that establishes each main frame and the network equipment and MAC Address corresponding relation obtain the purpose IP address information of carrying in the ARP request message, and determine the corresponding mac address information in this purpose IP address with the corresponding relation of MAC Address, and return to the main frame or the network equipment of the described ARP of transmission request message according to the IP address of setting up;
Target MAC (Media Access Control) address information that B3, the main frame that sends the ARP request message or network equipment basis are returned and destination host or LA Management Room communicate.
Described step B1 comprises:
B11, prevent to preserve in each main frame that the IP address clashes and the network equipment network equipment of corresponding relation of the IP address that establishes the respective host and the network equipment and MAC Address or the mac address information of main frame at needs;
B12, when needs prevent that the main frame that the IP address clashes or the network equipment from need send message, the corresponding network equipment of preserving according to step B11 or the mac address information of main frame send the ARP request message to it.
Described network can be Ethernet or local area network (LAN).
Can learn by such scheme, among the present invention, owing to adopted in arbitrary network equipment in network or the main frame and set up main frame and the IP address of the network equipment and the corresponding relation of MAC Address that moves in the network, the main frame in the network or the network equipment carry out the mutual method of data according to the corresponding relation of setting up then, thereby make the main frame or the network equipment of preserving each main frame and network appliance IP address and MAC Address corresponding relation can respond the ARP request message that each main frame sends specially, and be responsible for finishing the conversion of IP address to MAC address, thereby guaranteed that other main process equipments with identical ip addresses can not send the MAC Address of oneself, avoided the ARP requestor to receive wrong MAC Address effectively and caused communication interruption.
And, method of the present invention can according to the needs of practical application only in network needs prevent to realize on each main frame that the IP address clashes and the network equipment, and do not dispose the main frame or the network equipment of the method for solution IP address conflict of the present invention in same local area network (LAN) other, corresponding normal communication will can not be affected.
Description of drawings
Fig. 1 is a networking structure schematic diagram 1;
Fig. 2 is a networking structure schematic diagram 2;
Fig. 3 is the flow chart of method of the present invention;
Fig. 4 is for increasing the handling process of corresponding relation list item among the present invention.
Embodiment
Core concept of the present invention is main frame and the IP address of the network equipment and the corresponding relation of MAC Address in the centralized management network on arbitrary equipment in networks such as Ethernet or local area network (LAN), and the ARP request message of the inquiry MAC Address sent of unified response main frame or the network equipment, thereby make the corresponding main frame or the network equipment only can obtain unique target MAC (Media Access Control) address, and data to be sent are sent to this target MAC (Media Access Control) address uniquely; And, among the present invention, require the target MAC (Media Access Control) address of the main frame of MAC Address of search purposes IP address correspondence or the ARP request message that the network equipment sends to should be the MAC Address of the equipment of managing described corresponding relation concentratedly.
The concrete execution mode of the method for solution IP address conflict comprises following treatment step as shown in Figure 3 in the network service of the present invention:
Step 31: set up the main frame and the IP address of the network equipment and the corresponding relation of MAC Address that move in the network, so that determine corresponding M AC address information according to corresponding target IP address;
Be generally and in the network equipment or any main frame, set up each main frame and the IP address of the network equipment and the corresponding relation of MAC Address that the needs that move in the network prevent that the IP address from clashing, be both to comprise the IP address of main frame and the corresponding relation of MAC Address in the described corresponding relation, also may comprise the IP address of the network equipment and the corresponding relation of MAC Address;
The IP address of being set up and the corresponding relation of MAC Address can be preserved with the form of table, and each list item is writing down the corresponding relation of the IP address and the corresponding M AC address of a main frame or the network equipment.
Step 32: when main frame or the network equipment need send message, at first send the ARP request message, need to obtain the mac address information of the purpose IP address correspondence of the message that sends with request to the network equipment of IP address that establishes each main frame and the network equipment and MAC Address corresponding relation or main frame;
The specific implementation of step 32 is: preserve the network equipment of corresponding relation of the IP address that establishes the respective host and the network equipment and MAC Address or the mac address information of main frame in needs prevent each main frame that the IP address clashes; When needs prevent that the main frame that the IP address clashes or the network equipment from need send message, mac address information according to corresponding network equipment of being preserved or main frame sends the ARP request message to it, so just, can guarantee only to have in the network IP address of an in store main frame and the network equipment and the network equipment or the main frame of MAC Address corresponding relation can receive described ARP request message, thereby the main frame or the network equipment that clash with purpose IP address having avoided existing in the network are received this ARP request message;
Step 33: establish the IP address of each main frame and the network equipment and the network equipment or the main frame of MAC Address corresponding relation and obtain the purpose IP address information of carrying in the ARP message, and determine the MAC ground information that this purpose IP address is corresponding with the corresponding relation of MAC Address, and described target MAC (Media Access Control) address information is returned to the main frame or the network equipment of the described ARP of transmission request message by the arp response message according to the IP address of setting up;
Step 34: target MAC (Media Access Control) address information that the main frame basis of transmission ARP request message is returned and destination host or LA Management Room communicate, because the MAC Address of returning is unique, therefore can not cause subnetwork equipment or the main frame can't operate as normal, improve the reliability of whole network service because of there being the IP address that clashes with described purpose IP address in the network.
Network of the present invention can be Ethernet or local area network (LAN), and the network of other and Ethernet or the similar networking structure of local area network (LAN).
Above-mentioned steps 31 to step 34 provides a kind of IP address of avoiding effectively to clash the method that causes network failure in network, in said method, also comprise: when the main frame that increases or reduce operation in the network or the network equipment, then also need artificial or automatically each main frame of having set up and the IP address of the network equipment and the corresponding relation of MAC Address are increased or reduce processing accordingly; Wherein the corresponding relation of the IP address of each main frame set up and the network equipment and MAC Address is reduced accordingly and be treated to: the corresponding relation deletion of each main frame that will set up and the IP address of the network equipment and MAC Address or be set to unavailable, and that IP address that IP address that relates to for the corresponding relation that increases newly and MAC Address and the corresponding relation that existed relate to and MAC Address need guarantee is inequality, i.e. the IP address or the MAC Address that can not duplicate in the corresponding relation of Jian Liing.
For this reason, the corresponding relation of the IP address of each main frame set up and the network equipment and MAC Address is increased processing accordingly need adopt as shown in Figure 4 processing procedure, specifically comprise:
Step 41: each main frame that traversal has been set up and the IP address and the MAC Address of the network equipment;
Step 42: judge whether to exist IP address or the MAC Address identical with MAC Address with the IP address of the main frame that increases newly or the network equipment, if exist, execution in step 43, otherwise, execution in step 47 increases to the main frame that increases newly or the IP address of the network equipment and the corresponding relation of MAC Address in the mapping table;
Step 43: whether the IP address of the list item record that IP address that the IP address with the main frame that increases newly or the network equipment that further judgement exists is identical with MAC Address or MAC Address are corresponding and MAC Address be identical with the IP address and the MAC Address of the main frame that increases newly or the network equipment fully, if, then execution in step 44, otherwise execution in step 46;
Step 44: judge whether the IP address of described list item record and the corresponding relation of MAC Address are unavailable, judge promptly whether the list item that needs to add exists, and be that corresponding state is set to unavailable, if, then only it is set to upstate and gets final product execution in step 45, and need not to add new list item, otherwise, execution in step 46;
Step 46: do not increase processing accordingly, promptly the main frame that increases newly or the IP address of the network equipment and the corresponding relation of MAC Address are not increased in the corresponding relation of having set up, at this moment, because the address in the IP address of the main frame that increases newly or the network equipment and MAC Address and the corresponding relation that existed clashes, think the normal operation that guarantees network, must forbid that the corresponding relation of this existence conflict adds in the mapping table.
Be that example is described further in conjunction with method of the present invention with the network organizing example described in the background technology still now: referring to Fig. 1, the IP address of host C and fictitious host computer B is set to identical, and address conflict promptly takes place; Suppose configuration corresponding network equipment and the IP address of main frame and the corresponding relation of MAC Address on network equipment in local area network (LAN) or the main frame, and be provided with the function that responds the ARP request message of the corresponding main frame or the network equipment according to described corresponding relation, be called ARP Server (address resolution protocol service device), ARP Server can be arranged in any main frame or the network equipment; In addition, also disposed the MAC Address of ARP Server among host A and the fictitious host computer B, the MAC Address of described ARP Server is the main frame at ARP Server place or the MAC Address of the network equipment; Like this, when host A was communicated by letter with fictitious host computer B, host A was sent out an ARP request message earlier and is given ARP Server, the MAC Address of the IP address 192.168.1.2 of inquiry host B; Because target MAC (Media Access Control) address is the MAC Address of ARP Server, so have only ARP Server to receive this ARP request message, ARP Server finds the MAC Address of the IP address correspondence of fictitious host computer B subsequently in mapping table, and returns to host A; So far, host A just can carry out proper communication with fictitious host computer B, and can not occur network failures such as communication disruption again.
In addition referring to Fig. 2, suppose on server B, to be provided with ARP Server, when host A is communicated by letter with server B, host A sends an ARP request message earlier, target MAC (Media Access Control) address uses pre-configured ARP Server address, it is the MAC Address of server B, like this, have only server B can receive this ARP request message, subsequently, server B is returned the MAC Address of host B to host A, so far, host A just can communicate with server B, and in the acquisition process of whole M AC address, router C does not produce any harmful effect; Equally, when host A is communicated by letter with the main frame D identical with the IP address of server B, host A sends an ARP request message earlier, target MAC (Media Access Control) address uses ARP Server address, remain and have only server B can receive this ARP request message, afterwards, server B is returned the MAC Address of main frame D to host A, thereby makes host A just can communicate by letter with main frame D.
By above-mentioned in conjunction with explanation that Fig. 1 and Fig. 2 did as can be seen, the present invention can make the network equipment in the local area network (LAN) or main frame still can continue operate as normal when IP address conflict or during router misconfiguration, thereby guarantees the communication of whole network and the influence that service can not be subjected to IP address conflict.
The above; only for the preferable embodiment of the present invention, but protection scope of the present invention is not limited thereto, and anyly is familiar with those skilled in the art in the technical scope that the present invention discloses; the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection range of claims.