The content of the invention
For the above problem existing for existing router, a kind of WAN mouths acquisition aimed at when router is now provided
When the IP address arrived conflicts with the IP address presence of LAN, the IP for preventing the network equipment of LAN mouthfuls of IP address can be changed
The system and method for location conflict.
Specific technical solution is as follows:
A kind of system for the IP address conflict for preventing the network equipment, applied in router, including:
Wide Area Network interface, to provide one first address for the router;
Lan interfaces connect at least one client, and the second address for being associated with a LAN according to one, in described
It works in LAN;
Allocation unit connects the lan interfaces, to distribute IP according to second address for the client
Location;
It further includes:
Judging unit connects the Wide Area Network interface and the lan interfaces respectively, to judge first address
It whether there is with second address and conflict, and provide a mark in there are the conflict is represented during the conflict;
Processing unit connects the judging unit and the allocation unit, when first address and second address
During conflict, the processing unit changes second address to discharge first address with pre-defined rule, described in control
Allocation unit distributes IP address according to client of second address after change again to be connected with the lan interfaces,
And conflicting information and router reboot event prompting are generated according to the mark.
Preferably, further include:
Display unit connects the processing unit, to show that the conflicting information and the router restart prompting thing
Part.
Preferably, the judging unit includes:
First judgment module, to judge whether first address and second address are identical;
Second judgment module connects first judgment module, to judge first address and second address
Whether the same network segment is in;
3rd judgment module connects second judgment module, judging in first address of different segment and
Whether second address is in consolidated network.
Preferably, the detailed process of the second judgment module judgement is:
When first address and second address differ, obtain subnet corresponding with first address and cover
First address conversion is the value of integer type, and the value of acquisition is assigned to the first variable by code, and the subnet mask is turned
The value of integer type is changed, and the value of acquisition is assigned to the second variable;
Subnet mask corresponding with second address is obtained, by the value that second address conversion is integer type, and will
The value of acquisition is assigned to ternary, and the subnet mask is converted to the value of integer type, and the value of acquisition is assigned to the 4th
Variable;
Judge the first variable and the second variable carried out with the value that computing obtains with ternary and the 4th variable and fortune
Whether equal calculate the value obtained.
Preferably, the detailed process of the 3rd judgment module judgement is:
By the second variable and the 4th variable carries out and computing, and the value for making acquisition is the 5th variable;
Judge the first variable and the 5th variable carried out with the value that computing obtains with ternary and the 5th variable and fortune
Whether equal calculate the value obtained.
Preferably, the pre-defined rule includes, when first address and second address conflict, and the IP to conflict
Location be the c classes net IP address when, by second address be revised as a class nets IP address and/or
When first address and second address conflict, and during IP address that the IP address to conflict is a classes net,
By second address be revised as b class nets IP address and/or
When first address and second address conflict, and during IP address that the IP address to conflict is the b classes net,
Second address is revised as to the IP address of c class nets.
Preferably, the pre-defined rule is further included when first address and second address conflict, and the IP to conflict
When address is not admitted to a classes net, the b classes net and the c classes net, second address is revised as to the IP of c class nets
Location.
A kind of method for the IP address conflict for preventing the network equipment, using the IP address for preventing the network equipment as described above
The system of conflict, comprises the following steps:
S1. first address and second address are judged with the presence or absence of conflict, are identified if so, providing one in depositing
The conflict is represented in the conflict, performs step S2;If it is not, then terminate;
S2. when first address and second address conflict, first address is discharged, and is changed with pre-defined rule
Become second address, distributed according to client of second address after change again to be connected with the lan interfaces
It IP address and conflicting information and the router reboot event is generated according to the mark prompts;
S3. restart prompting event to the conflicting information and the router to show.
Preferably, the step S1 includes:
S11. judge whether first address and second address are identical, if so, providing a mark to represent
Conflict is stated, performs the step S2;If it is not, perform step S12;
S12. judge whether first address is in the same network segment with second address, if it is not, performing step S13;
If so, providing a mark to represent the conflict, the step S2 is performed;
S13. whether judge in first address of different segment and second address in consolidated network, if so,
A mark is then provided to represent the conflict, the step S2 is performed, if it is not, then terminating.
Preferably, the specific deterministic process of the step S12 is:
Subnet mask corresponding with first address is obtained, by the value that first address conversion is integer type, and will
The value of acquisition is assigned to the first variable, and the second change is assigned to by the value of the subnet mask convert integer type, and by the value of acquisition
Amount;
Subnet mask corresponding with second address is obtained, by the value that second address conversion is integer type, and will
The value of acquisition is assigned to ternary, and the subnet mask is converted to the value of integer type, and the value of acquisition is assigned to the 4th
Variable;
Judge the first variable and the second variable carried out with the value that computing obtains with ternary and the 4th variable and fortune
Whether equal the value obtained is calculated, if it is not, performing the step S13;If so, providing a mark to represent the conflict, perform
The step S2.
Preferably, the specific deterministic process of the step S13 is:
By the second variable and the 4th variable carries out and computing, and the value for making acquisition is the 5th variable;
Judge the first variable and the 5th variable carried out with the value that computing obtains with ternary and the 5th variable and fortune
It whether equal calculates the value obtained, if so, providing a mark to represent the conflict, the step S2 is performed, if it is not, then tying
Beam.
Preferably, the pre-defined rule includes, when first address and second address conflict, and the IP to conflict
Location be the c classes net IP address when, by second address be revised as a class nets IP address and/or
When first address and second address conflict, and during IP address that the IP address to conflict is a classes net,
By second address be revised as b class nets IP address and/or
When first address and second address conflict, and during IP address that the IP address to conflict is the b classes net,
Second address is revised as to the IP address of c class nets.
Preferably, the pre-defined rule is further included when first address and second address conflict, and the IP to conflict
When address is not admitted to a classes net, the b classes net and the c classes net, second address is revised as to the IP of c class nets
Location.
The advantageous effect of above-mentioned technical proposal:
In the technical program, WAN/ can determine whether by judging unit in the system for preventing the IP address conflict of the network equipment
LAN when a conflict exists, can change the IP address of LAN mouthfuls of clients to be solved with the presence or absence of conflict by allocation unit.
It, can be by discharging the first ground with WAN mouthfuls in the method for preventing the IP address conflict of the network equipment when WAN/LAN conflicts
Location, to avoid cannot be introduced into the problem of WEB page just changes IP address.
Specific embodiment
Below in conjunction with the attached drawing in the embodiment of the present invention, the technical solution in the embodiment of the present invention is carried out clear, complete
Site preparation describes, it is clear that described embodiment is only part of the embodiment of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, those of ordinary skill in the art obtained on the premise of creative work is not made it is all its
His embodiment, belongs to the scope of protection of the invention.
It should be noted that in the case where there is no conflict, the feature in embodiment and embodiment in the present invention can phase
Mutually combination.
The invention will be further described in the following with reference to the drawings and specific embodiments, but not as limiting to the invention.
As shown in Figure 1, a kind of system for the IP address conflict for preventing the network equipment, applied in router, including:
Wide Area Network interface 1, to provide one first address for router;
Lan interfaces 3 connect at least one client, and the second address for being associated with a LAN according to one, in office
It works in the net of domain;
Allocation unit 4 connects lan interfaces 3, to distribute IP address according to the second address for client;
It further includes:
Judging unit 2, difference connecting wan interface 1 and lan interfaces 3, to judge the first address and the second address
With the presence or absence of conflict, and a mark is provided in there are conflict is represented during the conflict;
Processing unit 5, connection judgment unit 2 and allocation unit 4, when the first address and the second address conflict, processing is single
Member 5 changes second address to discharge the first address with pre-defined rule, and control allocation unit 4 is according to the institute after change
The client that the second address is stated again to be connected with lan interfaces 3 distributes IP address and according to the mark generation conflict
Information and the prompting of router reboot event.
In the present embodiment, router supports DHCP (Dynamic Host Configuration Protocol, dynamic
Host configuration) function.It can determine whether that WAN/LAN with the presence or absence of conflict, when a conflict exists, can lead to by judging unit 2
The release of processing unit 5 and the first address of WAN mouths are crossed, avoids the problem that cannot be introduced into WEB page just changes IP address, can lead to
It crosses allocation unit 4 and changes the IP address of LAN mouthfuls of clients to be solved.
In a preferred embodiment, may also include:
Display unit 6, connection processing unit 5, to show that conflicting information and router restart prompting event.
In the present embodiment, when a conflict exists, the conflict page can be shown by display unit 6, and promotes user's routing
Think highly of the new IP address that in opening and LAN mouthfuls are not replaced, user is facilitated to understand the current operating status of router.
In a preferred embodiment, judging unit 2 may include:
First judgment module 21, to judge whether the first address is identical with the second address;
Second judgment module 22 connects the first judgment module 21, to judge whether the first address is in the second address
The same network segment;
3rd judgment module 23 connects the second judgment module 22, to judge in the first address of different segment and second
Whether address is in consolidated network.
In the present embodiment, WAN/LAN mouthfuls of conflict may include that three classes are respectively:The production identical with the second address of first address
Raw conflict, the first address and the second address be in the generation of the same network segment conflict and the first address with the second address in same
The conflict that network generates.
In a preferred embodiment, the detailed process of the second judgment module 22 judgement is:
When the first address and the second address differ, subnet mask corresponding with the first address is obtained, by the first address
The value of integer type is converted to, and the value of acquisition is assigned to the first variable, by the value of subnet mask convert integer type, and will be obtained
Value be assigned to the second variable;
Corresponding with the second address subnet mask is obtained, by the value that the second address conversion is integer type, and by the value of acquisition
Ternary is assigned to, subnet mask is converted to the value of integer type, and the value of acquisition is assigned to the 4th variable;
Judge the first variable and the second variable carried out with the value that computing obtains with ternary and the 4th variable and fortune
Whether equal calculate the value obtained.
In the present embodiment, during the normal electrifying startup of router, WAN mouthfuls of access cables, client enters the WEB of router
The page configures the mode of WAN mouthfuls of acquisition IP address in WEB page and obtains (i.e. DHCP) mode to be automatic, and normally gets
IP address.
After router gets WAN mouthfuls of IP address, judge whether the IP address got and LAN mouthfuls of IP address deposit
Conflicting.The value that WAN mouthfuls of the first address (IP address) is converted into integer type by the second judgment module 22 is assigned to first
Variable WANIP, the value that WAN mouthfuls of subnet mask is converted into integer type are assigned to the second variable WANMASK;By LAN mouthfuls of IP
The value of address conversion into integer type is assigned to ternary LANIP, and LAN mouthfuls of subnet mask is converted into the value assignment of integer type
To the 4th variables L ANMASK, judge that WANIP and WANMASK carries out the progress with the value that computing obtains and LANIP and LANMASK
It is whether equal with the computing value obtained, if equal, then it represents that WAN/LAN is in the same network segment, there is conflict, and provides a mark
To represent conflict.
In a preferred embodiment, the detailed process of the 3rd judgment module 23 judgement is:
By the second variable and the 4th variable carries out and computing, and the value for making acquisition is the 5th variable;
Judge the first variable and the 5th variable carried out with the value that computing obtains with ternary and the 5th variable and fortune
Whether equal calculate the value obtained.
In the present embodiment, when WANIP and WANMASK carries out the progress with the value that computing obtains and LANIP and LANMASK
When the value obtained with computing is unequal, WANMASK and LANMASK are carried out with computing and will obtained using the 3rd judgment module 23
The value that takes assigns the 5th variable ENMASK, judge WANIP and ENMASK carry out with the value that computing obtains and LANIP and ENMASK into
Whether row and the computing value obtained are equal, if equal, then it represents that WAN/LAN is in consolidated network, there is conflict, and provides a mark
Know to represent to conflict.
In a preferred embodiment, the pre-defined rule includes, when first address and second address conflict, and
When the IP address of conflict is the IP address of the c classes net, second address is revised as to the IP address of a class nets.
Wherein, a classes net IP address is:10.0.0.0 the address of~10.255.255.255, c class net IP address are:
192.168.0.0~192.168.255.255.
In the present embodiment, after conflict is detected, current WAN/ can be represented by setting variable conflict_flag
LAN exist conflict, when WAN mouthful obtain IP address it is identical with the IP address that LAN mouthfuls of clients obtain, since router default is straight
Connect away WAN mouthfuls, so as to cause client can not access router WEB page, therefore after detecting conflict, pass through processing unit 5
The IP address of WAN mouthfuls of release.When client user asks WEB page, judge to be by this variable of conflict_flag
It is no to there is conflict, if it is present directly showing the conflict page to user, and customer router is prompted to restart and match again
LAN mouth IP address afterwards.The rule change of wherein LAN mouthfuls of IP address is, if detecting LAN mouthfuls of IP address 192.168.2.1
When conflicting with WAN mouthfuls, LAN mouthfuls of IP address are changed to 10.10.10.1.
In a preferred embodiment, the pre-defined rule includes, when first address and second address conflict, and
When the IP address of conflict is the IP address of a classes net, second address is revised as to the IP address of b class nets.
Wherein, b classes net IP address is:172.16.0.0~172.31.255.255.
In the present embodiment, if detect that LAN mouthfuls of IP address 10.10.10.1 conflict with WAN mouthfuls, by LAN mouthfuls of IP
Location is changed to 172.16.10.1.
In a preferred embodiment, the pre-defined rule includes, when first address and second address conflict, and
When the IP address of conflict is the IP address of the b classes net, second address is revised as to the IP address of c class nets.
In the present embodiment, if detect that LAN mouthfuls of IP address 172.16.10.1 conflict with WAN mouthfuls, by LAN mouthfuls of IP
Address is changed to 192.168.2.1.
In a preferred embodiment, the pre-defined rule is further included when first address and second address conflict,
And c is revised as when being not admitted to a classes net, the b classes net and the c classes net in second address by the IP address of conflict
The IP address of class net.
As shown in Fig. 2, a kind of method for the IP address conflict for preventing the network equipment, applied to the IP for preventing the network equipment
The system of location conflict, comprises the following steps:
S1. judge that the first address, with the presence or absence of conflicting, is identified if so, providing one in there are the punchings with the second address
The conflict is represented when prominent, performs step S2;If it is not, then terminate;
S2. when first address and second address conflict, first address is discharged, and is changed with pre-defined rule
Become second address, distributed according to client of second address after change again to be connected with the lan interfaces
It IP address and conflicting information and the router reboot event is generated according to the mark prompts;
S3. restart prompting event to conflicting information and router to show.
In the present embodiment, by judging that WAN/LAN with the presence or absence of conflict, when a conflict exists, can pass through release and WAN
Mouthful the first address, avoids the problem that cannot be introduced into WEB page just changes IP address, can be by changing LAN mouthfuls of clients
IP address is solved, while the conflict page can be shown by a display unit, and promoted during customer router is restarted and
The LAN mouthfuls of new IP address do not replaced facilitate user to understand the current operating status of router.
As shown in figure 3, in a preferred embodiment, step S1 includes:
S11. judge whether the first address is identical with the second address, if so, providing a mark in there are the conflicts
When represent the conflict, perform step S2;If it is not, perform step S12;
S12. judge whether the first address is in the same network segment with the second address, if it is not, performing step S13;If so, it carries
For a mark in there are the conflict, execution step S2 are represented during the conflict;
S13. whether judge in the first address of different segment and the second address in consolidated network, if so, providing one
Mark is in there are the conflict, execution step S2, if it is not, then terminating are represented during the conflict.
In the present embodiment, WAN/LAN mouthfuls of conflict may include that three classes are respectively:The production identical with the second address of first address
Raw conflict, the first address and the second address be in the generation of the same network segment conflict and the first address with the second address in same
The conflict that network generates.
In a preferred embodiment, the specific deterministic process of step S12 is:
Corresponding with the first address subnet mask is obtained, by the value that the first address conversion is integer type, and by the value of acquisition
The first variable is assigned to, the second variable is assigned to by the value of subnet mask convert integer type, and by the value of acquisition;
Corresponding with the second address subnet mask is obtained, by the value that the second address conversion is integer type, and by the value of acquisition
Ternary is assigned to, subnet mask is converted to the value of integer type, and the value of acquisition is assigned to the 4th variable;
Judge the first variable and the second variable carried out with the value that computing obtains with ternary and the 4th variable and fortune
Whether equal the value obtained is calculated, if it is not, performing step S13;If so, a mark is provided in there are institute is represented during the conflict
Conflict is stated, performs step S2.
In the present embodiment, during the normal electrifying startup of router, WAN mouthfuls of access cables, client enters the WEB of router
The page configures the mode of WAN mouthfuls of acquisition IP address in WEB page and obtains (i.e. DHCP) mode to be automatic, and normally gets
IP address.
After router gets WAN mouthfuls of IP address, judge whether the IP address got and LAN mouthfuls of IP address deposit
Conflicting.First variable WANIP is assigned to by the value that WAN mouthfuls of the first address (IP address) is converted into integer type, by WAN
The value that the subnet mask of mouth is converted into integer type is assigned to the second variable WANMASK;By LAN mouthfuls of IP address conversion into integer type
Value be assigned to ternary LANIP, the value that LAN mouthfuls of subnet mask is converted into integer type is assigned to the 4th variable
LANMASK judges that WANIP and WANMASK obtained with the value that computing obtains and the progress of LANIP and LANMASK with computing
Value it is whether equal, if equal, then it represents that WAN/LAN is in the same network segment, there is conflict, and provides a mark to represent to rush
It is prominent, step S2 is performed, if unequal, performs step S13.
In a preferred embodiment, the specific deterministic process of step S13 is:
By the second variable and the 4th variable carries out and computing, and the value for making acquisition is the 5th variable;
Judge the first variable and the 5th variable carried out with the value that computing obtains with ternary and the 5th variable and fortune
Whether equal the value obtained is calculated, if so, providing a mark in there are the conflict is represented during the conflict, to perform step
S2, if it is not, then terminating.
In the present embodiment, when WANIP and WANMASK carries out the progress with the value that computing obtains and LANIP and LANMASK
When the value obtained with computing is unequal, WANMASK and LANMASK are carried out to assign the 5th variable with computing and by acquired value
ENMASK judges that WANIP and ENMASK carry out with LANIP and ENMASK with the value that computing obtains being with the value that computing obtains
It is no equal, if equal, then it represents that WAN/LAN is in consolidated network, there is conflict, and provides a mark to represent to conflict, and performs
Step S2.
In a preferred embodiment, the pre-defined rule includes, when first address and second address conflict, and
When the IP address of conflict is the IP address of the c classes net, second address is revised as to the IP address of a class nets.
Wherein, a classes net IP address is:10.0.0.0 the address of~10.255.255.255, c class net IP address are:
192.168.0.0~192.168.255.255.
In the present embodiment, after conflict is detected, current WAN/ can be represented by setting variable conflict_flag
LAN exist conflict, when WAN mouthful obtain IP address it is identical with the IP address that LAN mouthfuls of clients obtain, since router default is straight
Connect away WAN mouthfuls, so as to cause client can not access router WEB page, therefore after detecting conflict, by discharging WAN mouthfuls
IP address.When client user asks WEB page, by this variable of conflict_flag to determine whether there is punching
It is prominent, if it is present directly show the conflict page to user, and the LAN after customer router is prompted to restart and match again
Mouth IP address.The rule change of wherein LAN mouthfuls of IP address is, if detecting LAN mouthfuls of IP address 192.168.2.1 and WAN mouthfuls
During conflict, LAN mouthfuls of IP address are changed to 10.10.10.1.
In a preferred embodiment, the pre-defined rule includes, when first address and second address conflict, and
When the IP address of conflict is the IP address of a classes net, second address is revised as to the IP address of b class nets.
Wherein, b classes net IP address is:172.16.0.0~172.31.255.255.
In the present embodiment, if detect that LAN mouthfuls of IP address 10.10.10.1 conflict with WAN mouthfuls, by LAN mouthfuls of IP
Location is changed to 172.16.10.1.
In a preferred embodiment, the pre-defined rule includes, when first address and second address conflict, and
When the IP address of conflict is the IP address of the b classes net, second address is revised as to the IP address of c class nets.
In the present embodiment, if detect that LAN mouthfuls of IP address 172.16.10.1 conflict with WAN mouthfuls, by LAN mouthfuls of IP
Address is changed to 192.168.2.1.
In a preferred embodiment, the pre-defined rule is further included when first address and second address conflict,
And c is revised as when being not admitted to a classes net, the b classes net and the c classes net in second address by the IP address of conflict
The IP address of class net.
The present invention can not only judge whether, in the same network segment, to can determine whether simultaneously in WAN/LAN collision detection is carried out
In consolidated network.After conflict is detected, can WAN mouthfuls be discharged and be passed through variable is set to determine whether in conflict shape
State.User can directly pop up the page of WAN/LAN conflicts, and prompt customer router weight by the WEB page of access router
In opening and the LAN mouth IP address redistributed.
The foregoing is merely preferred embodiments of the present invention, not thereby limit embodiments of the present invention and protection model
It encloses, to those skilled in the art, should can appreciate that all with made by description of the invention and diagramatic content
Equivalent substitution and obviously change obtained scheme, should all include within the scope of the present invention.