Summary of the invention
The technical problem to be solved is that the IP address that Dynamic Host Configuration Protocol server distributes to need to access with user for the embodiment of the present invention
The inconsistent problem of network segment.
To solve the above-mentioned problems, technical solution provided in an embodiment of the present invention is as follows:
A kind of IP address management method under more Dynamic Host Configuration Protocol server network environments, provides a receiving Dynamic Host Configuration Protocol server IP
The DHCP client of address distribution, the DHCP client execute the IP address management method, the IP address management method
Include:
Parse the DHCP OFFER data packet that receives, and by the assigned IP address in the DHCP OFFER data packet
It is matched with a default network segment;
When the assigned IP address is fallen into the default network segment, receive in the DHCP OFFER data packet
IP address lease.
Optionally, the IP address management method under above-mentioned more Dynamic Host Configuration Protocol server network environments further includes, according to described
The DHCP OFFER data packet of Dynamic Host Configuration Protocol server feedback, generates a selective listing;The selective listing includes all DHCP services
The IP address that device distributes in DHCP OFFER data packet;
It, will be locating for first IP address according to user to the selection instruction of one first IP address in the selective listing
Network segment is as the default network segment.
Optionally, the IP address management method under above-mentioned more Dynamic Host Configuration Protocol server network environments, in described by described first
After network segment locating for IP address is as the default network segment further include: re-broadcast IP address request.
Optionally, the IP address management method under above-mentioned more Dynamic Host Configuration Protocol server network environments, in described by described first
After network segment locating for IP address is as the default network segment further include: sent to the Dynamic Host Configuration Protocol server for distributing first IP address
IP address request.
Optionally, the IP address management method under above-mentioned more Dynamic Host Configuration Protocol server network environments, Yu Suoshu re-broadcast IP
Before Address requests or described to before distributing the Dynamic Host Configuration Protocol server transmission IP address request of first IP address, release currently makes
IP address resource.
Optionally, the IP address management method under above-mentioned more Dynamic Host Configuration Protocol server network environments, is carrying out IP address for the first time
The setting of the default network segment is received before request in advance.
In order to solve the above technical problems, the embodiment of the invention also discloses a kind of DHCP clients, comprising:
Resolution unit, for parsing the DHCP OFFER data packet received;
A matching unit, for carrying out assigned IP address and the default network segment in the DHCP OFFER data packet
Match;
Processing unit, for receiving the DHCP when the assigned IP address is fallen into the default network segment
IP address lease in OFFER data packet.
Optionally, above-mentioned DHCP client, further includes:
Generation unit, the DHCP OFFER data packet for being fed back according to the Dynamic Host Configuration Protocol server generate a selective listing;
The selective listing includes the IP address that all Dynamic Host Configuration Protocol server distribute in DHCP OFFER data packet;
Setting unit, for the selection instruction according to user to one first IP address in the selective listing, by described
Network segment locating for one IP address is as the default network segment.
Optionally, above-mentioned DHCP client, further includes: the first request unit, being used for will be described in the setting unit
After network segment locating for first IP address is as the default network segment, IP address request is re-broadcast.
Optionally, above-mentioned DHCP client, further includes: the second request unit, being used for will be described in the setting unit
After network segment locating for first IP address is as the default network segment, IP is sent to the Dynamic Host Configuration Protocol server for distributing first IP address
Address requests.
Optionally, above-mentioned DHCP client, further includes: releasing unit, for again wide in first request unit
It broadcasts before IP address is requested or second request unit sends IP address to the Dynamic Host Configuration Protocol server for distributing first IP address and asks
Before asking, currently used IP address resource is discharged.
Optionally, above-mentioned DHCP client, further includes: receiving unit, for being carried out for the first time in the DHCP client
The setting of the default network segment is received before IP address request in advance.
Compared with prior art, technical solution of the present invention has the advantage that
In the present invention, DHCP client is matched by the IP address for distributing Dynamic Host Configuration Protocol server with default network segment, with
It chooses whether to receive the IP address lease, so as to realize Auto-matching and the access of wanting the network segment accessed to user, keep away
The problem of being unable to access demand network segment always and the subsequent cumbersome behaviour for needing manual releasing and re-request IP resource are exempted from
Make.
It further, include the selective listing that IP address is assigned in all DHCP OFFER data packets by generating one,
And then the autonomous selection according to user to IP address, user may be implemented, the needs of desired access network segment are done in use
It is adjusted flexibly and is accessed with Auto-matching.
Further, the default network segment of user setting is received in advance before DHCP client IP address requesting distribution for the first time,
The network segment for wanting access can be quickly accessed after DHCP client accesses network.
Further, before by carrying out new IP address distribution in request Dynamic Host Configuration Protocol server, with discharging currently used IP
Location reduces the IP wasting of resources in Dynamic Host Configuration Protocol server address pool.
Specific embodiment
Currently, in the network of complicated more Dynamic Host Configuration Protocol server, if obtaining undesired IP network section, it usually needs first
The IP address is discharged with order (such as input " ipconfig/release " order), then again with order (as inputted
" ipconfig/renew " order) new IP address request is issued to Dynamic Host Configuration Protocol server again.But this still has certain general
Rate obtains the IP address for being not intended to obtain.If request network administrator finds the DHCP service for being not intended to carry out address distribution
Device, and these servers down are fallen, although available desired IP address, this will be troublesome operation, and
It is irrealizable in many cases, for example does not get in touch with network administrator.Same network may more importantly be also resulted in
Middle other users cannot obtain desired IP address, influence its normal use.
It can be seen that in the prior art, there are no one kind can be adapted under more DHCP network environments, the net that user is needed
The network mechanism that Duan Jinhang is effectively matched.
In the embodiment of the present invention, DHCP client passes through the IP address for distributing Dynamic Host Configuration Protocol server and the progress of default network segment
Match, to choose whether to receive the IP address lease, so as to realize the Auto-matching to the network segment of the desired access of user and connect
Enter, avoid the problem of being unable to access demand network segment always and subsequent need manual releasing and re-request the numerous of IP resource
Trivial operation.
To make the above purposes, features and advantages of the invention more obvious and understandable, with reference to the accompanying drawing to the present invention
Specific embodiment be described in detail.
The embodiment of the invention provides a kind of IP address management methods under more Dynamic Host Configuration Protocol server network environments, can be applicable in
It is any that there is data transmission capabilities and data-handling capacity in IP network environment, and receive Dynamic Host Configuration Protocol server share IP address
Network insertion end equipment.For example, it may be router, can be the computer equipped with wireless network card, it is also possible to have
The smart phone etc. of WiFi module.Hereafter the network insertion end equipment stated will be deserved to be called with DHCP client generation.
IP address management method under a kind of more Dynamic Host Configuration Protocol server environment of the embodiment of the present invention, as shown in Figure 1, can wrap
Include following steps:
Step S101 generates a selective listing according to the DHCP OFFER data packet that the Dynamic Host Configuration Protocol server is fed back.
When DHCP client first time logging in online, it can be broadcasted by udp port and issue a DHCP DISCOVER number
According to packet, requesting Dynamic Host Configuration Protocol server is that oneself distributes corresponding IP address.When Dynamic Host Configuration Protocol server listens to the DHCP DISCOVER
After broadcast, it can select the vacant IP of foremost from the address pool that oneself is managed, and feed back to one DHCP of client computer
OFFER data packet.Which includes the information such as IP address, subnet mask, address lease.
Under the network environment of more Dynamic Host Configuration Protocol server, DHCP client will receive multiple DHCP DISCOVER data packets
Feedback.In the prior art, DHCP client can retain first DHCP OFFER data packet received, after abandoning (DROP)
The DHCP OFFER data packet that continued access receives, and to the broadcast data packet of one DHCP REQUEST of network transmission, it informs all
Its IP address for will receiving which platform server and provide of Dynamic Host Configuration Protocol server, in this way, when other Dynamic Host Configuration Protocol server receive the broadcast,
Their offer can be cancelled so that IP address is supplied to IP address request next time.
Unlike the above-mentioned prior art, the embodiment of the present invention after receiving multiple DHCP DISCOVER data packets, though
It so can also default and receive first DHCP OFFER data packet, and send DHCP REQUEST broadcast data packet, but not abandon
Subsequently received DHCP OFFER data packet, but all DHCP OFFER data packets received are parsed, and read wherein
Information generate the selective listing, the choosing and by an one-dimension array of assigned IP address write-in kernel therein
Selecting list includes the IP address that all Dynamic Host Configuration Protocol server distribute in DHCP OFFER data packet.
It is understood that having received first applied to DHCP client since the embodiment of the present invention can be
In DHCP OFFER data packet after IP lease, processing to subsequently received all DHCP OFFER data packets, therefore it is described
Selective listing can not also include the IP address in first DHCP OFFER data packet received, that is, be being currently used
IP address.
In specific implementation, if the user interface of the DHCP client is graphic interface, the alternative column
Data in table can be shown by way of the page.If the user interface of the DHCP client is Command Line Interface, that
Can by user by input command statement in being shown in the selective listing on the display interface of the DHCP client
IP address information.
Step S102, according to user to the selection instruction of one first IP address in the selective listing, by the first IP
Network segment locating for address is as default network segment.
In specific implementation, according to the difference of the DHCP client user interface, selection of the user to the first IP address
Instruction can be page selection instruction, be also possible to order line command.
Step S103 carries out IP address request.
In specific implementation, the progress IP address request, which can be, re-broadcasts IP address request.With broadcasting IP at this time
Location request with step S101 before DHCP client first log into the DHCP DISCOVER data packet format that sends when network can be with
Be it is identical, i.e., the source address of encapsulated data packet is 0.0.0.0, and destination address 255.255.255.255 adds
Other relevant informations of DHCPDISCOVER.
In specific implementation, the IP address that carries out requests to be also possible to the DHCP service to first IP address is distributed
Device sends IP address request.The format of the Dynamic Host Configuration Protocol server data packet just is sent to no longer using the request method of broadcast at this time
In, destination address is the IP address of the Dynamic Host Configuration Protocol server, and it is the current IP address of DHCP client that source address, which can be, can also
To be 0.0.0.0.
In order to reduce the IP wasting of resources in Dynamic Host Configuration Protocol server address pool, in specific implementation, DHCP client can asked
Before asking Dynamic Host Configuration Protocol server to carry out new IP address distribution, currently used IP address is discharged.
In specific implementation, it in order to avoid all going wrong in Dynamic Host Configuration Protocol server, such as collapses, without can be carried out address distribution
When, program occupies excessive CPU and memory source, preset time can be arranged by components such as similar timers, and carrying out
After Broadcast IP address request, judges whether to receive DHCP OFFER data packet in above-mentioned effective preset time, can reflect
Whether Dynamic Host Configuration Protocol server is in normal operating conditions.
In above-mentioned specific implementation, in view of under Dynamic Host Configuration Protocol server normal condition to the sound of DHCP client IP address requesting
It should be usually in 0.2s or so, so if the waiting time of DHCP client has been more than predetermined time (being such as customized for 5s), also
It is not received by the DHCP OFFER of Dynamic Host Configuration Protocol server reply, then deciding that Dynamic Host Configuration Protocol server will not provide IP address.This
When DHCP client output DHCP request fail and terminates Broadcast IP address request etc. accordingly process to save system resource.
Step S104~step S105, parses the DHCP OFFER data packet received, and by the DHCP OFFER number
It is matched according to the assigned IP address in packet with the default network segment.
Why the present embodiment selects the IP address that same network segment is in first IP address, rather than selects and institute
The identical IP address of the first IP address is stated, is because Dynamic Host Configuration Protocol server can within the period for obtaining first IP and replacement IP
First IP address can be distributed into other dhcp clients, therefore first IP address that can not reallocate.
In specific implementation, Hook Function can be set to intercept the data packet received, if the data that judgement receives
Whether packet is DHCP data packet, then the IP address whether IP address that the DHCP data packet is taken back is intended to, i.e., with described
One IP address is in same network segment.If so, the ACCEPT data packet, receives the IP address in the DHCP OFFER data packet
Otherwise lease abandons the data packet.
For example, currently used IP address is 192.168.1.56/24, user selects in the selective listing
10.6.61.89/24 IP address.At this point, if successively have received respectively include 192.168.1.46/24,
172.16.2.8/24 and the DHCP OFFER data packet of tri- assigned IP address of 10.6.61.96/24, then by comparing IP
Preceding 24 network positions of address binary number, can judge the network position of 192.168.1.46/24,172.16.2.8/24 with
10.6.61.89/24 network position is different, but the network position phase of the network position of 10.6.61.96/24 and 10.6.61.89/24
Together, i.e., the two belongs to same network segment, therefore abandons the first two DHCP OFFER data packet, receives third DHCP OFFER data
IP address lease in packet.
To sum up, the IP address management method under a kind of more Dynamic Host Configuration Protocol server network environments through the embodiment of the present invention, can
To include the selective listing of assigned IP address in all DHCP OFFER data packets by generation one, and then according to user to IP
The autonomous selection of address can be convenient and quickly realize that user does flexible tune to the needs of desired access network segment in use
Whole and Auto-matching access, to improve the usage experience of user.
The embodiment of the invention also discloses the IP address management methods under another more Dynamic Host Configuration Protocol server environment.With previous reality
Apply that example is identical to be, the embodiment of the present invention is equally applicable to receive the DHCP client of the dhcp server ip address distribution,
The IP address management method is executed by the DHCP client.
As shown in Fig. 2, the IP address management method under more Dynamic Host Configuration Protocol server environment may include steps of:
Step S201~step S202, parses the DHCP OFFER data packet received, and by the DHCP OFFER number
It is matched according to the assigned IP address in packet with a default network segment.
Unlike previous embodiment, the default network segment in the present embodiment is before the DHCP networks for the first time
By user setting and it is stored on the DHCP client, rather than as previous embodiment is received in the DHCP client
After DHCP OFEER, selected by user specified.
Step S203 receives the DHCP OFFER when the assigned IP address is fallen into the default network segment
IP address lease in data packet.
In specific implementation, if the assigned IP address in all DHCP OFFER that DHCP client receives not
In the default network segment, then using the method for being similar to the prior art, the DHCP OFFER data packet being initially received is received
The IP address lease of offer.
It, can also be by the corresponding preset time of timer setting, if default beyond this in above-mentioned specific implementation
Time then determines that new DHCP OFFER data packet will not be received again, falls into default network segment if received not yet at this time
IP address, then receive first DHCP OFFER data packet received in IP address lease.
It is understood that the present embodiment is identical as previous embodiment technical problem to be solved, i.e., it is all to avoid
It delays accessing user's the case where wanting the network of access, and subsequent operation cumbersome in the prior art.Meanwhile with regard to technology
For scheme itself, both by by assigned IP and user pre-set network segment in advance, or refer in use
Fixed network segment is matched, therefore the two belongs to same technical idea.
The present embodiment can be applied in combination with previous embodiment, i.e., step S101~step is executed after the step S203
S105。
To sum up, the IP address management method under a kind of more Dynamic Host Configuration Protocol server environment of the embodiment of the present invention, by setting in advance
Set want access network segment, receive Dynamic Host Configuration Protocol server send DHCP OFFER data packet at the beginning, just to IP address progress
Filtering selection, reassigns corresponding network segment without user again in use, further the convenient use of user.
Certainly, if user, which needs to reselect in use, accesses new network segment, the side of such as previous embodiment can also be passed through
Method is easily reselected and is accessed.
The embodiment of the invention also provides the IP under a kind of more Dynamic Host Configuration Protocol server network environments with one embodiment
The corresponding DHCP client of address management method.As shown in figure 3, the DHCP client 30 may include:
Resolution unit 301, for parsing the DHCP OFFER data packet received;
Matching unit 302, for by the DHCP OFFER data packet assigned IP address and a default network segment into
Row matching;
Processing unit 303, for receiving the DHCP when the assigned IP address is fallen into the default network segment
IP address lease in OFFER data packet.
In specific implementation, the DHCP client 30 can also include:
Generation unit 304, the DHCP OFFER data packet for being fed back according to the Dynamic Host Configuration Protocol server generate an alternative column
Table;The selective listing includes the IP address that all Dynamic Host Configuration Protocol server distribute in DHCP OFFER data packet;
Setting unit 305 will be described for the selection instruction according to user to one first IP address in the selective listing
Network segment locating for first IP address is as the default network segment;
Request unit 306, for carrying out IP address request.
In specific implementation, the request unit 306 is for re-broadcasting IP address request.
In specific implementation, the request unit 306 is used to send to the Dynamic Host Configuration Protocol server for distributing first IP address
IP address request.
In specific implementation, the DHCP client 30 can also include: releasing unit 307, for single in the request
Before member 306 re-broadcasts IP address request, or to before distributing the Dynamic Host Configuration Protocol server transmission IP address request of first IP address,
Discharge currently used IP address resource.
The IP address management device 30 under a kind of more Dynamic Host Configuration Protocol server environment through the embodiment of the present invention, can pass through life
Include at one the selective listing of IP address is assigned in all DHCP OFFER data packets, and then according to user to IP address from
Main selection can be convenient and quickly realize that user is in use adjusted flexibly and automatically the needs of desired access network segment
Matching access, to improve the usage experience of user.
About the concrete scheme of the present embodiment, the corresponding contents of first embodiment are referred to, details are not described herein again.
The embodiment of the invention also provides more Dynamic Host Configuration Protocol server rings in another DHCP client, with second embodiment
IP address management method under border is corresponding.As shown in figure 4, the DHCP client 40 may include:
Receiving unit 401, it is described pre- for being received in advance before the DHCP client 40 carries out IP address request for the first time
If the setting of network segment;
Resolution unit 402, for parsing the DHCP OFFER data packet received;
Matching unit 403, for by the DHCP OFFER data packet assigned IP address and a default network segment into
Row matching;
Processing unit 404, for receiving the DHCP when the assigned IP address is fallen into the default network segment
IP address lease in OFFER data packet.
In specific implementation, as shown in figure 4, above-mentioned DHCP client 40, may also include such as above-mentioned DHCP client
30。
A kind of DHCP client 40 of the embodiment of the present invention wants the network segment of access by presetting, and is receiving DHCP
Server send DHCP OFFER data packet at the beginning, selection just is filtered to IP address, is being used without user
Reassign corresponding network segment again in the process, the further convenient use of user.Certainly, if user in use
It needs to reselect the network segment of access, can also easily be reselected by the method for such as previous embodiment.
About the concrete scheme of the present embodiment, the corresponding contents of second embodiment are referred to, details are not described herein again.
Those of ordinary skill in the art will appreciate that all or part of the steps in the various methods of above-described embodiment is can
It is completed with instructing relevant hardware by program, which can be stored in a computer readable storage medium, storage
Medium may include: ROM, RAM, disk or CD etc..
Although present disclosure is as above, present invention is not limited to this.Anyone skilled in the art are not departing from this
It in the spirit and scope of invention, can make various changes or modifications, therefore protection scope of the present invention should be with claim institute
Subject to the range of restriction.