Summary of the invention
The embodiment of the present invention is to be solved technical problem is that the IP address and user that Dynamic Host Configuration Protocol server distributes
Need the problem that the network segment of access is inconsistent.
In order to solve the problems referred to above, the technical scheme that the embodiment of the present invention provides is as follows:
A kind of IP address management method under many Dynamic Host Configuration Protocol server network environment a, it is provided that acceptance is described
The DHCP client of dhcp server ip address distribution, described DHCP client performs described IP
Address management method, described IP address management method includes:
Resolve the DHCP OFFER packet received, and by described DHCP OFFER packet
Allocated IP address preset the network segment with one and mate;
When described allocated IP address falls in the described default network segment, accept described DHCP OFFER
IP address lease in packet.
Optionally, the above-mentioned IP address management method under many Dynamic Host Configuration Protocol server network environment also includes,
The DHCP OFFER packet fed back according to described Dynamic Host Configuration Protocol server, generates a selective listing;Described
Selective listing includes the IP address that all Dynamic Host Configuration Protocol server distribute in DHCP OFFER packet;
According to user to the selection instruction of one the oneth IP address in described selective listing, by a described IP ground
The network segment residing for location is as the described default network segment.
Optionally, the above-mentioned IP address management method under many Dynamic Host Configuration Protocol server network environment, in described
The network segment residing for a described IP address is also included after the described default network segment: re-broadcast IP address
Request.
Optionally, the above-mentioned IP address management method under many Dynamic Host Configuration Protocol server network environment, in described
The network segment residing for a described IP address is also included after the described default network segment: to distribution described first
The Dynamic Host Configuration Protocol server of IP address sends IP Address requests.
Optionally, the above-mentioned IP address management method under many Dynamic Host Configuration Protocol server network environment, in described
Before re-broadcasting IP Address requests, or the described Dynamic Host Configuration Protocol server to the described IP address of distribution is sent out
Before sending IP Address requests, discharge currently used IP address resource.
Optionally, the above-mentioned IP address management method under many Dynamic Host Configuration Protocol server network environment, first
The setting of the described default network segment is received in advance before carrying out IP Address requests.
In order to solve above-mentioned technical problem, the embodiment of the invention also discloses a kind of DHCP client,
Including:
Resolution unit, for resolving the DHCP OFFER packet received;
Matching unit, for presetting the allocated IP address in described DHCP OFFER packet with one
The network segment mates;
Processing unit, for when described allocated IP address falls in the described default network segment, accepts institute
State the IP address lease in DHCP OFFER packet.
Optionally, above-mentioned DHCP client, also include:
Signal generating unit, for the DHCP OFFER packet fed back according to described Dynamic Host Configuration Protocol server, raw
Become a selective listing;Described selective listing includes that all Dynamic Host Configuration Protocol server are in DHCP OFFER packet
The IP address of middle distribution;
Unit is set, for the selection of one the oneth IP address in described selective listing being instructed according to user,
Using the network segment residing for a described IP address as the described default network segment.
Optionally, above-mentioned DHCP client, also include: the first request unit, for setting in described
Put unit using the network segment residing for a described IP address as after the described default network segment, re-broadcast IP address
Request.
Optionally, above-mentioned DHCP client, also include: the second request unit, for setting in described
Put unit using the network segment residing for a described IP address as after the described default network segment, to distribution described first
The Dynamic Host Configuration Protocol server of IP address sends IP Address requests.
Optionally, above-mentioned DHCP client, also include: releasing unit, for asking in described first
Before asking unit to re-broadcast IP Address requests, or described second request unit is to distributing a described IP address
Dynamic Host Configuration Protocol server send before IP Address requests, discharge currently used IP address resource.
Optionally, above-mentioned DHCP client, also include: receive unit, at described DHCP
Client computer receives the setting of the described default network segment in advance before carrying out IP Address requests first.
Compared with prior art, technical scheme has the advantage that
In the present invention, DHCP client is by the IP address distributed by Dynamic Host Configuration Protocol server and the default network segment
Mate, to choose whether to accept this IP address lease, such that it is able to realize user is wanted access
The Auto-matching of the network segment and access, it is to avoid all the time can not the problem of the access demand network segment, and follow-up need
Want manual release the troublesome operation of re-request IP resource.
Further, allocated IP address in all DHCP OFFER packets is included by generation one
Selective listing, and then according to user to IP address from main separation, it is possible to achieve user use process
In to want access the network segment needs be adjusted flexibly and Auto-matching access.
Further, before DHCP client IP address requesting first distributes, user setup is received in advance
Preset the network segment, the network segment wanting to access can be quickly accessed after DHCP client access network.
Further, by before request Dynamic Host Configuration Protocol server carries out new IP address distribution, release is current
The IP address used, decreases the IP wasting of resources in Dynamic Host Configuration Protocol server address pool.
Detailed description of the invention
At present, in the network of complicated many Dynamic Host Configuration Protocol server, if obtaining undesired IP network section,
Typically require and first discharge this IP address, then with order (such as input " ipconfig/release " order)
Again new IP ground is sent to Dynamic Host Configuration Protocol server again with order (such as input " ipconfig/renew " order)
Location is asked.But this still has certain probability and obtains the IP address being not intended to obtain.If request network
Manager finds the Dynamic Host Configuration Protocol server being not intended to carry out address distribution, and these servers all down
Fall, although the IP address wanted can be obtained, but this will be troublesome operation, and in a lot of situations
Under be irrealizable, such as do not get in touch with network manager.The more important thing is and may also result in same net
In network, other users can not obtain the IP address wanted, and affects it and normally uses.
Visible also do not have one to go under many DHCP network environment in the prior art, to
The network segment that family needs carries out the network mechanism being effectively matched.
In the embodiment of the present invention, DHCP client by IP address that Dynamic Host Configuration Protocol server is distributed with pre-
If the network segment mates, to choose whether to accept this IP address lease, such that it is able to realize user is wanted
The Auto-matching of the network segment accessed and access, it is to avoid all the time can not the problem of the access demand network segment, and
The follow-up troublesome operation needing manual release re-request IP resource.
Understandable, below in conjunction with the accompanying drawings for enabling the above-mentioned purpose of the present invention, feature and advantage to become apparent from
The specific embodiment of the present invention is described in detail.
Embodiments provide the IP address management side under a kind of many Dynamic Host Configuration Protocol server network environment
Method, goes in IP network environment, and any have data transmission capabilities and a data-handling capacity, and
Accept the network insertion end equipment of Dynamic Host Configuration Protocol server share IP address.For example, it may be router, can
To be equipped with the computer of wireless network card, it is also possible to be the smart mobile phone etc. with WiFi module.Hereafter will
The network insertion end equipment stated is deserved to be called with DHCP client generation.
IP address management method under a kind of many Dynamic Host Configuration Protocol server environment of the embodiment of the present invention, such as Fig. 1
Shown in, may include steps of:
Step S101, the DHCP OFFER packet fed back according to described Dynamic Host Configuration Protocol server, generate
One selective listing.
When DHCP client logging in online for the first time, one can be sent by udp port broadcast
DHCP DISCOVER packet, request Dynamic Host Configuration Protocol server is that oneself distributes corresponding IP address.When
After Dynamic Host Configuration Protocol server listens to described DHCP DISCOVER broadcast, it can be from the ground managed itself
Pond, location selects the vacant IP of foremost, feeds back to one DHCP OFFER packet of client computer.Wherein
Include the information such as IP address, subnet mask, address lease.
Under the network environment of many Dynamic Host Configuration Protocol server, DHCP client can receive multiple DHCP
The feedback of DISCOVER packet.In the prior art, DHCP client can retain first reception
The DHCP OFFER packet arrived, abandons the DHCP OFFER data that (DROP) is subsequently received
Bag, and the broadcast data packet of a DHCP REQUEST is sent to network, inform that all DHCP take
Business device it by accepting the IP address which station server provides, so, when other Dynamic Host Configuration Protocol server receive
During this broadcast, their offer can be cancelled so that IP address is supplied to IP Address requests next time.
Unlike above-mentioned prior art, the embodiment of the present invention is receiving multiple DHCP DISCOVER
After packet, although also can give tacit consent to first DHCP OFFER packet of acceptance, and send DHCP
REQUEST broadcast data packet, but subsequently received DHCP OFFER packet will not be abandoned, and
It is to resolve all DHCP OFFER packets received, and reads information therein, and by therein
In one one-dimension array of allocated IP address write kernel, generate described selective listing, described alternative column
Table includes the IP address that all Dynamic Host Configuration Protocol server distribute in DHCP OFFER packet.
It is understood that owing to the embodiment of the present invention can be to be applied to DHCP client accepted
In first DHCP OFFER packet after IP lease, to subsequently received all DHCP
The process of OFFER packet, the most described selective listing can not also include that first receives
IP address in DHCP OFFER packet, the IP address being i.e. being currently used.
In being embodied as, if the user interface of described DHCP client is graphic interface, then
Data in described selective listing can be shown by the form of the page.If described DHCP client
User interface is Command Line Interface, then can be objective in described DHCP by input command statement by user
The IP address information in described selective listing is shown on the display interface of family machine.
Step S102, according to user to the selection instruction of one the oneth IP address in described selective listing, by institute
State the network segment residing for an IP address as the default network segment.
In being embodied as, according to the difference of described DHCP client user interface, user is to an IP
The selection instruction of address can be that the page selects instruction, it is also possible to is order line order.
Step S103, carries out IP Address requests.
In being embodied as, described in carry out IP Address requests can be to re-broadcast IP Address requests.Now
The DHCP that before Broadcast IP address request and step S101, DHCP client sends when first logging into network
DISCOVER data packet format can be identical, i.e. the source address of encapsulated data packet is 0.0.0.0, mesh
Mark address is 255.255.255.255, adds other relevant informations of DHCPDISCOVER.
In being embodied as, described in carry out IP Address requests can also to distribute a described IP address
Dynamic Host Configuration Protocol server sends IP Address requests.The most no longer use the request method of broadcast, be sent to this
In the form of Dynamic Host Configuration Protocol server packet, destination address is the IP address of this Dynamic Host Configuration Protocol server, and source
Address can be the IP address that DHCP client is current, it is also possible to be 0.0.0.0.
In order to reduce the IP wasting of resources in Dynamic Host Configuration Protocol server address pool, in being embodied as, DHCP visitor
Family machine can discharge currently used IP before request Dynamic Host Configuration Protocol server carries out new IP address distribution
Address.
In being embodied as, in order to avoid all going wrong at Dynamic Host Configuration Protocol server, as collapsed, and can not
When carrying out address distribution, program takies too much CPU and memory source, can be by similar intervalometer etc.
Parts arrange Preset Time, and after carrying out Broadcast IP address request, it may be judged whether above-mentioned the most pre-
If receiving DHCP OFFER packet in the time, can reflect whether Dynamic Host Configuration Protocol server is in normal work
Make state.
In above-mentioned being embodied as, in view of please to DHCP client under Dynamic Host Configuration Protocol server normal condition
Ask the response of IP address generally at about 0.2s, if therefore the waiting time of DHCP client exceedes
The scheduled time (is such as customized for 5s), is also not received by the DHCP OFFER that Dynamic Host Configuration Protocol server is replied,
So decide that Dynamic Host Configuration Protocol server will not provide IP address.At this moment DHCP client output DHCP
Request failure also terminates the corresponding processes such as described Broadcast IP address request to save system resource.
Step S104~step S105, resolve the DHCP OFFER packet received, and by described
Allocated IP address in DHCP OFFER packet is mated with the described default network segment.
The present embodiment why select with a described IP address be in the same network segment IP address rather than
Select the IP address identical with a described IP address, be because obtaining first IP and changing IP's
In time period, other dhcp client may be distributed in an IP address by Dynamic Host Configuration Protocol server
, an IP address of therefore cannot reallocating.
In being embodied as, the packet that Hook Function receives with intercepting can be set, it is judged that if received
To packet be DHCP packet, then whether the IP address that this DHCP packet takes back is intended to
IP address, the most whether be in the same network segment with a described IP address.If it is, ACCEPT should count
According to bag, accept the IP address lease in described DHCP OFFER packet, otherwise abandon this packet.
Such as, currently used IP address is 192.168.1.56/24, and user selects in described selective listing
Select the IP address of 10.6.61.89/24.Now, if successively have received and including respectively
192.168.1.46/24, the DHCP of the allocated IP address of 172.16.2.8/24 and 10.6.61.96/24 tri-
OFFER packet, then by comparing front 24 network positions of IP address binary number, can judge
192.168.1.46/24, the network position of 172.16.2.8/24 the most different from the network position of 10.6.61.89/24, but
10.6.61.96/24 network position is identical with the network position of 10.6.61.89/24, and i.e. both belong to the same network segment,
Therefore abandon the first two DHCP OFFER packet, accept in the 3rd DHCP OFFER packet
IP address lease.
To sum up, managed by the IP address under a kind of many Dynamic Host Configuration Protocol server network environment of the embodiment of the present invention
Reason method, can include the choosing of allocated IP address in all DHCP OFFER packets by generating one
Select list, so according to user to IP address from main separation, user can be realized conveniently and efficiently and make
To wanting the needs accessing the network segment to be adjusted flexibly and Auto-matching access during with, thus improve use
The experience at family.
The embodiment of the invention also discloses the IP address management side under another kind of many Dynamic Host Configuration Protocol server environment
Method.Identical with previous embodiment, the embodiment of the present invention is equally applicable to accept described DHCP service
The DHCP client of device IP address distribution, is performed described IP address management by described DHCP client
Method.
As in figure 2 it is shown, the IP address management method under described many Dynamic Host Configuration Protocol server environment can include as
Lower step:
Step S201~step S202, resolve the DHCP OFFER packet received, and by described
Allocated IP address in DHCP OFFER packet is preset the network segment with one and is mated.
Unlike previous embodiment, the described default network segment in the present embodiment is first at described DHCP
By user setup and be stored on described DHCP client rather than such as previous embodiment before secondary networking
After described DHCP client receives DHCP OFEER, user select to specify.
Step S203, when described allocated IP address falls in the described default network segment, accepts described
IP address lease in DHCP OFFER packet.
In being embodied as, if being divided in all DHCP OFFER of receiving of DHCP client
Join IP address the most not in the described default network segment, then use the method being similar to prior art, receive at first
The IP address lease that the DHCP OFFER packet received provides.
In above-mentioned being embodied as, it is also possible to by intervalometer, corresponding Preset Time is set, if super
Go out this Preset Time, then judge will not receive new DHCP OFFER packet again, if now also
Do not receive the IP address fallen in the default network segment, then accept first DHCP OFFER received
IP address lease in packet.
It is understood that the present embodiment technical problem to be solved with previous embodiment is identical, the most all
It is intended to avoid delaying to access user and wants the situation of the network accessed, and loaded down with trivial details in prior art
Subsequent operation.Meanwhile, for technical scheme itself, both by by allocated IP and user's thing
Before the network segment that pre-sets, or the network segment in use specified mates, therefore both belong to
One technological thought.
The present embodiment can be applied in combination with previous embodiment, i.e. performs step after described step S203
S101~step S105.
To sum up, the IP address management method under a kind of many Dynamic Host Configuration Protocol server environment of the embodiment of the present invention,
By pre-setting the network segment wanting to access, receiving the DHCP OFFER number that Dynamic Host Configuration Protocol server sends
According to bag at the beginning, IP address just carries out filtering selection, thus without user the most again
Specify the corresponding network segment, the most convenient use of user.Certainly, if the user while during Shi Yonging
Need to reselect and access the new network segment, it is also possible to carried out weight by the method such as previous embodiment easily
The newly selected and access.
The embodiment of the present invention additionally provides a kind of and in first embodiment many Dynamic Host Configuration Protocol server network rings
The DHCP client that IP address management method under border is corresponding.As it is shown on figure 3, described DHCP is objective
Family machine 30 may include that
Resolution unit 301, for resolving the DHCP OFFER packet received;
Matching unit 302, for by the allocated IP address and in described DHCP OFFER packet
The default network segment mates;
Processing unit 303, for when described allocated IP address falls in the described default network segment, connects
By the IP address lease in described DHCP OFFER packet.
In being embodied as, described DHCP client 30 can also include:
Signal generating unit 304, for the DHCP OFFER packet fed back according to described Dynamic Host Configuration Protocol server,
Generate a selective listing;Described selective listing includes that all Dynamic Host Configuration Protocol server are in DHCP OFFER data
The IP address of distribution in bag;
Unit 305 is set, for referring to the selection of one the oneth IP address in described selective listing according to user
Order, using the network segment residing for a described IP address as the described default network segment;
Request unit 306, is used for carrying out IP Address requests.
In being embodied as, described request unit 306 is used for re-broadcasting IP Address requests.
In being embodied as, described request unit 306 is for the DHCP distributing a described IP address
Server sends IP Address requests.
In being embodied as, described DHCP client 30 can also include: releasing unit 307, is used for
Before described request unit 306 re-broadcasts IP Address requests, or to distributing a described IP address
Before Dynamic Host Configuration Protocol server sends IP Address requests, discharge currently used IP address resource.
By the IP address management device 30 under a kind of many Dynamic Host Configuration Protocol server environment of the embodiment of the present invention,
The selective listing of allocated IP address in all DHCP OFFER packets can be included by generating one,
And then according to user to IP address from main separation, user can be realized conveniently and efficiently in use
To wanting the needs accessing the network segment to be adjusted flexibly and Auto-matching access, thus improve the use of user
Experience.
About the concrete scheme of the present embodiment, it is referred to the corresponding contents of first embodiment, the most no longer
Repeat.
The embodiment of the present invention additionally provides in another kind of DHCP client, with second embodiment many
IP address management method under Dynamic Host Configuration Protocol server environment is corresponding.As shown in Figure 4, described DHCP visitor
Family machine 40 may include that
Receive unit 401, for before described DHCP client 40 carries out IP Address requests first in advance
Receive the setting of the described default network segment;
Resolution unit 402, for resolving the DHCP OFFER packet received;
Matching unit 403, for by the allocated IP address and in described DHCP OFFER packet
The default network segment mates;
Processing unit 404, for when described allocated IP address falls in the described default network segment, connects
By the IP address lease in described DHCP OFFER packet.
In being embodied as, as shown in Figure 4, above-mentioned DHCP client 40, may also include as above-mentioned
DHCP client 30.
A kind of DHCP client 40 of the embodiment of the present invention, by pre-setting the network segment wanting to access,
Receive Dynamic Host Configuration Protocol server send DHCP OFFER packet at the beginning, just IP address is carried out
Filter and select, thus reassign the corresponding network segment the most again without user, the most just
The prompt use of user.Certainly, if the user while need to reselect the network segment of access during Shi Yonging,
Can also be reselected easily by the method such as previous embodiment.
About the concrete scheme of the present embodiment, it is referred to the corresponding contents of the second embodiment, the most no longer
Repeat.
One of ordinary skill in the art will appreciate that all or part of step in the various methods of above-described embodiment
Suddenly the program that can be by completes to instruct relevant hardware, and this program can be stored in a computer can
Reading in storage medium, storage medium may include that ROM, RAM, disk or CD etc..
Although present disclosure is as above, but the present invention is not limited to this.Any those skilled in the art,
Without departing from the spirit and scope of the present invention, all can make various changes or modifications, therefore the guarantor of the present invention
The scope of protecting should be as the criterion with claim limited range.