Background technology
DHCP adopts the client/server communication pattern, to Dynamic Host Configuration Protocol server the configuration application is proposed by dhcp client, Dynamic Host Configuration Protocol server is returned as the corresponding configuration informations such as Internet Protocol (IP) address that dhcp client distributes, to realize the dynamic-configuration of information such as IP address, specifically can be referring to the workflow diagram that dynamically obtains the IP address approach shown in Figure 1.As shown in Figure 1, this flow process comprises:
Step 101:DHCP client finds that with DHCP (DISCOVER) message sends to Dynamic Host Configuration Protocol server with broadcast mode.
After step 102:DHCP server receives DHCP DISCOVER message, select an IP address according to the order of priority of IP address assignment, and provide (OFFER) message to send to client by DHCP the IP address of selecting.
Step 103:DHCP client is asked (REQUEST) message in the mode of broadcasting to Dynamic Host Configuration Protocol server transmission DHCP after receiving DHCP OFFER message, comprising Dynamic Host Configuration Protocol server in this DHCP REQUEST message is the IP address that dhcp client is selected.
Need to prove, in this step, send DHCP OFFER message, be dhcp client when receiving a plurality of DHCP OFFER message to dhcp client as many Dynamic Host Configuration Protocol server, the DHCP OFFER message that dhcp client selects one of them server to send.
Step 104: after having been selected the Dynamic Host Configuration Protocol server of DHCP OFFER message to receive DHCP REQUEST message by dhcp client, give this dhcp client if confirm the IP address assignment that to select in the step 102, then return DHCP affirmative acknowledgement (ACK) message to dhcp client; Otherwise, return DHCP negative response (NACK) message to dhcp client.
Need to prove, when dhcp client is received DHCP ACK message, the IP address that will use Dynamic Host Configuration Protocol server to select for this dhcp client; Otherwise this dhcp client need return execution in step 101, to obtain the IP address again.
Also it should be noted that, after dhcp client gets access to the IP address, IP address lease writing time that Dynamic Host Configuration Protocol server need be applied for for each dhcp client, after lease time expires, renew a contract to Dynamic Host Configuration Protocol server by sending DHCP renewed treaty message by dhcp client, if renew a contract successfully, dhcp client can continue to use this IP address; Dhcp client was not renewed a contract when the failure or lease expired if renew a contract, the corresponding lease of Dynamic Host Configuration Protocol server deletion, and allow to give other dhcp clients with this IP address assignment.
Step 105:DHCP client is used the IP address after the end, sends DHCP with mode of unicast to Dynamic Host Configuration Protocol server and discharges (RELEASE) message, uses for other dhcp clients so that Dynamic Host Configuration Protocol server reclaims this resource.
So far, promptly finished the existing whole workflow of dynamically obtaining the IP address approach, this flow process is mainly used in networking schematic diagram as shown in Figure 2, promptly comprises in the networking of a DFCP server and the dhcp client more than two.
Yet when this Dynamic Host Configuration Protocol server fault in the network, whole network all will bear the risk that hinders for some reason and cause Network to be interrupted, and for this reason, has mainly adopted two-node cluster hot backup structure as shown in Figure 3 at present.As shown in Figure 3, between Dynamic Host Configuration Protocol server A and Dynamic Host Configuration Protocol server B, set up backup link, by the business on the backup link backup opposite end Dynamic Host Configuration Protocol server of setting up, thus, when a Dynamic Host Configuration Protocol server fault, business datum also can be passed through from the opposite end Dynamic Host Configuration Protocol server, thereby has avoided the interruption of Network to a great extent.
By above-mentioned analysis as can be seen, adopt two-node cluster hot backup can avoid because the interruption of the Network that the Dynamic Host Configuration Protocol server fault is brought, yet, on the one hand, need set up backup link when adopting two-node cluster hot backup, and backup link depends on the system hot standby technology, is inapplicable for not possessing the hot network that is equipped with technology; On the other hand, two-node cluster hot backup can only be backed up between two Dynamic Host Configuration Protocol server, also is inapplicable for the network more than two Dynamic Host Configuration Protocol server.
Summary of the invention
In view of this, the invention provides a kind of Dynamic Host Configuration Protocol server backup method, can realize the backup of two above Dynamic Host Configuration Protocol server, and need not to set up backup link.
The present invention also provides a kind of Dynamic Host Configuration Protocol server, can realize the backup of two above Dynamic Host Configuration Protocol server, and need not to set up backup link.
In order to achieve the above object, the technical scheme of the present invention's proposition is:
A kind of dynamic host configuration protocol DHCP server backup method, this method comprises:
The Internet Protocol IP address of more than one other Dynamic Host Configuration Protocol server of record, and other Dynamic Host Configuration Protocol server that will write down is as trust server;
When the DHCP that receives the dhcp client transmission finds the DISCOVER message, be this dhcp client distributing IP address, and described IP address allocated is recorded as preliminary rental agreement;
When receiving the DHCP request REQUEST message of dhcp client transmission, judge that whether self or trust server be the server identity sign Server ID corresponding server in the DHCP REQUEST message, if self, preliminary rental agreement is recorded as effective lease, if trust server, delete preliminary rental agreement, and this trust server is recorded as effective lease for the dhcp client IP address allocated; Otherwise, the preliminary rental agreement that deletion is corresponding.
This method further comprises:
When the DHCP that receives the dhcp client transmission detects the DECLINE message, judge self whether to be Server ID corresponding server in the DHCP DECLINE message, if, effective lease that deletion is corresponding, and the IP address in the effective lease that will delete is recorded as conflict IP address; Otherwise, effective lease that deletion is corresponding;
This method further comprises:
When receiving DHCP that dhcp client sends when discharging the RELEASE message, judge self whether to be Server ID corresponding server in the DHCP RELEASE message, if effective lease that deletion is corresponding sends to trust server with this message; Otherwise, effective lease that deletion is corresponding.
This method further comprises:
When receiving the DHCP renewed treaty message that dhcp client sends, judge self whether to be Server ID corresponding server in the DHCP renewed treaty message, if, upgrade corresponding effective lease, simultaneously this message is sent to trust server; Otherwise, upgrade corresponding effective lease.
Add fashionablely as new trust server, this method further comprises:
Receive the lease batch synchronization request that this trust server sends, give this trust server in batches synchronously described lease.
Described lease batch synchronization request and described lease all pass through the DHCP message in batches synchronously and send.
A kind of dynamic host configuration protocol DHCP server, this Dynamic Host Configuration Protocol server comprises: duplicated record unit, preliminary rental agreement record cell and preliminary rental agreement processing unit, wherein,
Described duplicated record unit is used to write down the Internet Protocol IP address of more than one other Dynamic Host Configuration Protocol server, and other Dynamic Host Configuration Protocol server that will write down is as trust server;
Described preliminary rental agreement record cell is used for being this dhcp client distributing IP address, and described IP address allocated being recorded as preliminary rental agreement when the DHCP that receives the dhcp client transmission finds the DISCOVER message;
Described preliminary rental agreement processing unit, be used for when receiving the DHCP request REQUEST message of dhcp client transmission, judge that whether self or trust server in the duplicated record unit be the server identity sign Server ID corresponding server in the DHCPREQUEST message, if self, the preliminary rental agreement of described preliminary rental agreement recording unit records is recorded as effective lease, if trust server, delete the preliminary rental agreement of described preliminary rental agreement recording unit records, and this trust server is recorded as effective lease for the dhcp client IP address allocated; Otherwise, delete the preliminary rental agreement of described preliminary rental agreement recording unit records.
This Dynamic Host Configuration Protocol server also comprises first effective lease delete cells, be used for when the DHCP that receives the dhcp client transmission detects the DECLINE message, judge self whether to be Server ID corresponding server in the DHCP DECLINE message in the described duplicated record unit, if, delete effective lease of described preliminary rental agreement processing unit correspondence, and the IP address in the effective lease that will delete is recorded as conflict IP address; Otherwise, delete effective lease of described preliminary rental agreement processing unit correspondence.
This Dynamic Host Configuration Protocol server also comprises second effective lease delete cells, be used for when the DHCP that receives the dhcp client transmission discharges the RELEASE message, judge self whether to be Server ID corresponding server in the DHCP RELEASE message in the described duplicated record unit, if, delete effective lease of described preliminary rental agreement processing unit correspondence, this message is sent to backup server; Otherwise, delete effective lease of described preliminary rental agreement processing unit correspondence.
This Dynamic Host Configuration Protocol server also comprises effective lease updating block, be used for when receiving the DHCP renewed treaty message of dhcp client transmission, judge self whether to be Server ID corresponding server in the DHCP renewed treaty message in the described duplicated record unit, if, upgrade effective lease of described preliminary rental agreement processing unit correspondence, simultaneously this message is sent to backup server; Otherwise, upgrade effective lease of described preliminary rental agreement processing unit correspondence.
This Dynamic Host Configuration Protocol server also comprises in batches lock unit of lease, is used for adding as new trust server fashionable, receives lease that this trust server sends synchronization request in batches, gives this trust server in batches synchronously with described lease.
In sum, Dynamic Host Configuration Protocol server backup method of the present invention and Dynamic Host Configuration Protocol server, be that more than one other Dynamic Host Configuration Protocol server by having write down in advance the IP address in a server is a trust server, when server receives DHCP DISCOVER message, be this dhcp client distributing IP address, and described IP address allocated is recorded as preliminary rental agreement, and when receiving the DHCPREQUEST message, can determine according to the ID of Server ID in this message and prior specified server preliminary rental agreement is recorded as effective lease or this preliminary rental agreement of deletion.Because the present invention has specified more than one trust server in a server, and can carry out correct processing to lease according to the ID of server and the relation of the Server ID in the DHCP message, therefore, when one of them server takes place when unusual, other trust server is because the lease of this unusual server-assignment of record, also just can continue as client service, and can not give the IP address of client distribution conflict, thereby not only realized the backup of two above Dynamic Host Configuration Protocol server, and need not between server, to set up backup link.
Embodiment
In order to solve the technical problem that the present invention proposes, the specific implementation of scheme of the present invention comprises:
The IP address of more than one other Dynamic Host Configuration Protocol server of record, and other Dynamic Host Configuration Protocol server that will write down is as trust server; When receiving the DHCP DISCOVER message of dhcp client transmission, be this dhcp client distributing IP address, and described IP address allocated is recorded as preliminary rental agreement; When receiving the DHCP REQUEST message of dhcp client transmission, judge that whether self or trust server be the Server ID corresponding server in the DHCP REQUEST message, if self, preliminary rental agreement is recorded as effective lease, if trust server, delete preliminary rental agreement, and this trust server is recorded as effective lease for the dhcp client IP address allocated; Otherwise, the preliminary rental agreement that deletion is corresponding.
For making the purpose, technical solutions and advantages of the present invention clearer, the present invention is described in further detail below in conjunction with the accompanying drawings and the specific embodiments.
Fig. 4 is the workflow diagram of Dynamic Host Configuration Protocol server backup method of the present invention.As shown in Figure 4, this flow process comprises:
Step 401: the Internet Protocol IP address of more than one other Dynamic Host Configuration Protocol server of record, and other Dynamic Host Configuration Protocol server that will write down is as trust server.
Need to prove, in the present embodiment, need a Dynamic Host Configuration Protocol server in the network that more than one other Dynamic Host Configuration Protocol server is appointed as trust server, and this operating between server is mutual, suppose that it is trust server that Dynamic Host Configuration Protocol server A has specified Dynamic Host Configuration Protocol server B, C, D, then also to have specified Dynamic Host Configuration Protocol server A, C, D be trust server to Dynamic Host Configuration Protocol server B, it is trust server that Dynamic Host Configuration Protocol server C has also specified Dynamic Host Configuration Protocol server A, B, D, and it is trust server that Dynamic Host Configuration Protocol server D has also specified Dynamic Host Configuration Protocol server A, B, C.
Step 402:DHCP client sends the DHCPDISCOVER message with broadcast mode to Dynamic Host Configuration Protocol server, to seek Dynamic Host Configuration Protocol server.
After step 403:DHCP server is received DHCP DISCOVER message, will will be recorded as preliminary rental agreement for this client IP address allocated for after the client IP address allocated sends to client by the DHCPOFFER message.
In this step, described preliminary rental agreement comprises the MAC Address of client and is this client IP address allocated.
Be client records behind the preliminary rental agreement, when follow-up when receiving the DHCP message that dhcp client sends, can be according to the Dynamic Host Configuration Protocol server of the ID correspondence in the DHCP message, determine preliminary rental agreement is recorded as effective lease or deletion preliminary rental agreement, specifically can be referring to step 404-413, below introduce respectively:
After step 404:DHCP client is received DHCP OFFER message, send DHCP REQUEST message to Dynamic Host Configuration Protocol server in the mode of broadcasting.
Step 405: the Dynamic Host Configuration Protocol server that receives DHCP REQUEST message has three kinds of processing modes: when from as the Server ID corresponding server in the DHCP REQUEST message time, preliminary rental agreement is recorded as effective lease; When certain trust server in self is Server ID corresponding server in the DHCP REQUEST message, the deletion preliminary rental agreement, and be that client IP address allocated (also being the Request IP in the corresponding DHCP REQUEST message) is recorded as effective lease with this trust server; Otherwise, the preliminary rental agreement of deletion message correspondence.
Owing in a server, write down the lease of trust server, therefore, when one of them server generation was unusual, other trust server can be according to the lease of the unusual server that writes down, continue as client service, and IP address that can distribution conflict.
The Dynamic Host Configuration Protocol server of the ID correspondence in the step 406:DHCP REQUEST message sends DHCP ACK message to dhcp client.
Step 407: after receiving DHCP ACK message, whether dhcp client sends the ARP(Address Resolution Protocol) message to other dhcp client, available with the IP address of resolving in effective lease.
Step 408: after the feedback of receiving the ARP message, send DHCP to Dynamic Host Configuration Protocol server and detect (DECLINE) message.
Need to prove,, illustrate that the IP address in this effective lease is used by other dhcp client if dhcp client is received the feedback of ARP message.
Step 409: when receiving DHCP DECLINE message: when from the time as the Server ID corresponding server in the DHCP DECLINE message, effective lease of deletion message correspondence, and the IP address in the effective lease that will delete is recorded as conflict IP address; When certain trust server in self is Server ID corresponding server in the DHCP DECLINE message, effective lease of deletion message correspondence; Otherwise Dynamic Host Configuration Protocol server is left intact.
Need to prove, when Dynamic Host Configuration Protocol server is received DHCP DECLINE message, be illustrated as dhcp client IP address allocated occupied (conflicting with having for other dhcp client IP address allocated), therefore, needing be dhcp client distributing IP address again.
Step 410: when dhcp client does not re-use IP address in effective lease, send DHCP to Dynamic Host Configuration Protocol server and discharge (RELEASE) message.
Step 411: when receiving DHCP RELEASE message: when from as the Server ID corresponding server in the DHCP RELEASE message time, effective lease of deletion message correspondence sends to backup server with this message simultaneously; When certain trust server in self is Server ID corresponding server in the DHCP RELEASE message, effective lease of deletion message correspondence.
Because DHCP RELEASE message is a unicast message, therefore, when Dynamic Host Configuration Protocol server from as the Server ID corresponding server in the DHCP RELEASE message time, in the time of the effective lease of deletion message correspondence, also need this message is transmitted to the trust server of self.
Step 412: when dhcp client also continues to use IP address in effective lease, send DHCP renewed treaty message to Dynamic Host Configuration Protocol server.
Step 413: when receiving DHCP renewed treaty message: when from the time, upgrade effective lease of message correspondence, simultaneously this message is sent to backup server as the Server ID corresponding server in the DHCP renewed treaty message; When certain trust server in self is Server ID corresponding server in the DHCP renewed treaty message, upgrade effective lease of message correspondence.
The same with the DHCP RELEASE message in the step 411, DHCP renewed treaty message also is a unicast message, therefore, when Dynamic Host Configuration Protocol server from as the Server ID corresponding server in the DHCP RELEASE message time, also need this message is transmitted to backup server.
So far, promptly finished the whole workflow of Dynamic Host Configuration Protocol server backup method of the present invention.
Need to prove, in the present embodiment, when Dynamic Host Configuration Protocol server is restarted or have new Dynamic Host Configuration Protocol server to add trust server, also need the lease of all trust server is carried out synchronously, promptly, be specifically as follows by restarting server or initiate server to one of them server requests lease:
1) by increasing new DHCP message, asking lease (BINDREQUEST) message in batches as DHCP, to the server requests lease; 2) in existing message, increase new option, to be used for to Dynamic Host Configuration Protocol server request lease.In the reality, in the server or initiate trust server that also can adopt other modes that lease is synchronized to restart, specifically realize being as the criterion with reality.
Also it should be noted that, when reality realizes, real lease is synchronous by TFTP or FTP synchronously, be specially: Dynamic Host Configuration Protocol server is recorded in lease in the local file, when receiving the lease synchronization request, its own IP address and file name (comprising the path, place) are passed through the DHCP response feedback to the request server in the Dynamic Host Configuration Protocol server; Request server is initiated TFTP or FTP acquisition request lease file according to these information, obtains the lease that writes down in the successfully back resolution file and is recorded in this locality.
Based on said method, Fig. 5 has provided the structure of Dynamic Host Configuration Protocol server of the present invention.As shown in Figure 5, this Dynamic Host Configuration Protocol server comprises duplicated record unit 51, preliminary rental agreement record cell 52 and preliminary rental agreement processing unit 53, wherein,
Described duplicated record unit 51 is used to write down the IP address of more than one other Dynamic Host Configuration Protocol server, and other Dynamic Host Configuration Protocol server that will write down is as trust server.
Described preliminary rental agreement record cell 52 is used for being this dhcp client distributing IP address, and described IP address allocated being recorded as preliminary rental agreement when the DHCP that receives the dhcp client transmission finds the DISCOVER message.
Described preliminary rental agreement processing unit 53, be used for when receiving the DHCP request REQUEST message of dhcp client transmission, judge that whether self or trust server in the duplicated record unit 51 be the Server ID corresponding server in the DHCP REQUEST message, if self, the preliminary rental agreement of described preliminary rental agreement record cell 52 records is recorded as effective lease, if trust server, delete the preliminary rental agreement of described preliminary rental agreement record cell 52 records, and this trust server is recorded as effective lease for the dhcp client IP address allocated; Otherwise, delete the preliminary rental agreement that described preliminary rental agreement record cell 52 writes down.
Further, this backup server also comprises first effective lease delete cells 54, be used for when receiving the DHCP DECLINE message of dhcp client transmission, judge self whether to be Server ID corresponding server in the DHCP DECLINE message in the described duplicated record unit 51, if, delete effective lease of described preliminary rental agreement processing unit 53 correspondences, and the IP address in the effective lease that will delete is recorded as conflict IP address; Otherwise, delete effective lease of described preliminary rental agreement processing unit 53 correspondences.
This backup server also comprises second effective lease delete cells 55, be used for when receiving the DHCP RELEASE message of dhcp client transmission, judge self whether to be Server ID corresponding server in the DHCP RELEASE message in the described duplicated record unit 51, if, delete effective lease of described preliminary rental agreement processing unit 53 correspondences, this message is sent to backup server; Otherwise, delete effective lease of described preliminary rental agreement processing unit 53 correspondences.
This backup server also comprises effective lease updating block 56, be used for when receiving the DHCP renewed treaty message of dhcp client transmission, judge self whether to be Server ID corresponding server in the DHCP renewed treaty message in the described duplicated record unit 51, if, upgrade effective lease of described preliminary rental agreement processing unit 53 correspondences, simultaneously this message is sent to backup server; Otherwise, upgrade effective lease of described preliminary rental agreement processing unit 53 correspondences.
This backup server also comprises in batches lock unit 57 of lease, is used for adding as new trust server fashionable, receives lease that this trust server sends synchronization request in batches, gives this trust server in batches synchronously with described lease.
Wherein, described lease batch synchronization request and described lease all pass through the transmission of DHCP message in batches synchronously.
So far, promptly obtained Dynamic Host Configuration Protocol server of the present invention.The concrete workflow of the described Dynamic Host Configuration Protocol server of Fig. 5 can repeat no more here referring to Fig. 4.
Below illustrate the process that Dynamic Host Configuration Protocol server backup when unusual takes place Dynamic Host Configuration Protocol server of the present invention: suppose to have in the network server a and server b, can distribute address 1~10:
When not having back mechanism, server a has distributed address 1~3,4~10 are recorded as unappropriated address, server b has distributed address 7~10, and address 1~6 is recorded as unallocated address, at this moment, if server a is unusual, have only server b to work, may occur two kinds of mistakes so: can fail when 1, the client of address 1~3 is renewed a contract, client needs applied address again; 2, server b may attempt address 1~3 to distribute, and distributing can failure.
When adopting multi-computer back-up of the present invention, server a and b can recording addresses 1~3 and 7~10th, distributed lease, thereby, also just avoided the appearance of above-mentioned two problems, successfully realized backup.
In a word, Dynamic Host Configuration Protocol server backup method of the present invention and Dynamic Host Configuration Protocol server, be that more than one other Dynamic Host Configuration Protocol server by having write down in advance the IP address in a server is a trust server, when server receives DHCP DISCOVER message, be this dhcp client distributing IP address, and described IP address allocated is recorded as preliminary rental agreement, and when receiving the DHCPREQUEST message, can determine according to the ID of Server ID in this message and prior specified server preliminary rental agreement is recorded as effective lease or this preliminary rental agreement of deletion.Because the present invention has specified more than one trust server in a server, and can carry out correct processing to lease according to the ID of server and the relation of the Server ID in the DHCP message, therefore, when one of them server takes place when unusual, other trust server is because the lease of this unusual server-assignment of record, also just can continue as client service, and can not give the IP address of client distribution conflict, thereby not only realized the backup of two above Dynamic Host Configuration Protocol server, and need not between server, to set up backup link.
The above only is preferred embodiment of the present invention, and is in order to restriction the present invention, within the spirit and principles in the present invention not all, any modification of being made, is equal to replacement, improvement etc., all should be included within the scope of protection of the invention.