CN115550319A - Address allocation method and device - Google Patents

Address allocation method and device Download PDF

Info

Publication number
CN115550319A
CN115550319A CN202211480628.7A CN202211480628A CN115550319A CN 115550319 A CN115550319 A CN 115550319A CN 202211480628 A CN202211480628 A CN 202211480628A CN 115550319 A CN115550319 A CN 115550319A
Authority
CN
China
Prior art keywords
address
server
target client
client
request message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202211480628.7A
Other languages
Chinese (zh)
Other versions
CN115550319B (en
Inventor
蔡林志
陈岩
刘威
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Information Technologies Co Ltd
Original Assignee
New H3C Information Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New H3C Information Technologies Co Ltd filed Critical New H3C Information Technologies Co Ltd
Priority to CN202211480628.7A priority Critical patent/CN115550319B/en
Publication of CN115550319A publication Critical patent/CN115550319A/en
Application granted granted Critical
Publication of CN115550319B publication Critical patent/CN115550319B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application provides an address allocation method and device. In this embodiment, when a server switching event is detected, a reference address is determined from an address pool, and a second address request message carrying the reference address is sent to a first server, so that the first server allocates an address for a client according to the reference address, thereby avoiding a situation that the client fails to be on-line due to allocation from a minimum address when the server is switched; further, the second address request message carrying the reference address is sent to the first server, so that the first server allocates addresses for the clients according to the reference address, transmission of a large number of invalid messages in the network due to allocation of the server from the minimum address is avoided, message data transmitted in the network is reduced, and network load is reduced.

Description

Address allocation method and device
Technical Field
The present application relates to the field of communications technologies, and in particular, to an address allocation method and apparatus.
Background
In a client-relay-server (C-R-S) networking, a relay connects multiple servers, and the address pool configured by each server is the same.
When the client is on line, the address is requested to the server through the relay. After a first server (called as server 1) allocates addresses to N clients in the order of addresses from small to large, when the server 1 is disconnected or the addresses cannot be allocated, the relay is switched to a second server (called as server 2) to allocate the addresses.
Since server 2 has no addresses allocated, it will start with the smallest address in the pool, but in practice the smallest N addresses are already allocated to the first N clients. After receiving the minimum address, the relay finds that the address is already allocated, discards the address, does not send feedback information to the client, and fails to receive the feedback information, and the client goes online. When the next client comes online, the server 2 allocates the second small address to the client, the relay discards the second small address after receiving the second small address, and so on, and the client cannot be normally online until the (N + 1) th client comes online, during which the client fails to be online for N times.
Disclosure of Invention
In view of this, embodiments of the present application provide an address allocation method and apparatus to avoid the situation that the client fails to be online N times when the server switches.
According to a first aspect of the embodiments of the present application, there is provided an address allocation method, where the method is applied to a relay device, the relay device is connected to at least two servers in the same network segment, and each server has configured the same address pool, and the method includes:
receiving a first address request message sent by a target client;
when the first address request message does not carry the client address of the target client, if a server switching event is detected, selecting a reference address to be allocated to the target client from the address pool; the reference address is a free address in the address pool;
sending a second address request message carrying the reference address to a first server to request the first server to allocate an address for the target client based on the reference address;
the server switching event refers to switching the server from a normal working state to an abnormal state.
According to a second aspect of the embodiments of the present application, there is provided an address allocating apparatus, where the apparatus is applied to a relay device, the relay device is connected to at least two servers in the same network segment, and each server has configured the same address pool, and the apparatus includes:
the first address request message receiving module is used for receiving a first address request message sent by a target client;
a reference address determining module, configured to select, when the first address request packet does not carry the client address of the target client, a reference address to be allocated to the target client from the address pool if a server switching event is detected; the reference address is a free address in the address pool;
a first address allocation module, configured to send a second address request packet carrying the reference address to a first server, so as to request the first server to allocate an address to the target client based on the reference address;
the server switching event refers to the switching of the server from a normal working state to an abnormal state.
According to a third aspect of embodiments of the present application, there is provided an electronic apparatus including: a processor and a memory;
wherein the memory is to store machine executable instructions;
the processor is configured to read and execute the machine executable instructions stored by the memory to implement the method of the first aspect.
According to the address allocation method provided by the embodiment of the application, when a server switching event is detected, a reference address is determined from an address pool, and a second address request message carrying the reference address is sent to a first server, so that the first server allocates addresses for clients according to the reference address, and the situation that the clients fail to be online due to allocation from the minimum address when the servers are switched is avoided;
further, the second address request message carrying the reference address is sent to the first server, so that the first server allocates addresses for the clients according to the reference address, transmission of a large number of invalid messages in the network due to allocation of the server from the minimum address is avoided, message data transmitted in the network is reduced, and network load is reduced.
Drawings
FIG. 1 is a schematic diagram of a C-R-S networking provided by an embodiment of the present application;
FIG. 2 is a flow chart of a method provided by an embodiment of the present application;
fig. 3 is an exemplary diagram of online networking of a client according to an embodiment of the present application;
FIG. 4 is a block diagram of an apparatus provided by an embodiment of the present application;
fig. 5 is a hardware structure diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if," as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination," depending on the context.
Next, examples of the present application will be described in detail.
As shown in fig. 1, fig. 1 is a schematic diagram of a C-R-S networking according to an embodiment of the present application. In this embodiment, the relay device is connected to a plurality of servers through a switch, and the plurality of servers are all in the same network segment and configured with the same address pool, that is, the assignable address ranges of the plurality of servers are the same, where the address refers to an IP address. For example, the interface addresses of the relay device and the client are 20.1.1.1, the interface address of the relay device and the switch is 10.1.1.10, the addresses of the three servers are 10.1.1.1, 10.1.1.2 and 10.1.1.3, respectively, and the minimum address in the address pool where each server is configured is 20.1.1.2.
In this embodiment, the server performs IP address allocation based on a Dynamic Host Configuration Protocol (DHCP).
Based on the networking shown in fig. 1, the method provided by the embodiment of the present application is described below by using fig. 2:
referring to fig. 2, fig. 2 is a flowchart of a method provided by an embodiment of the present application. The method is applied to the relay device, and a plurality of servers connected to the relay device are all in an operating state, as shown in fig. 2, the process may include the following steps:
s210: and receiving a first address request message sent by a target client.
For example, in this embodiment, the target client may be a new client that is never on-line in a network segment where each server connected to the relay device is located, or may be a client that is on-line again after being disconnected, and this embodiment of the present application is not particularly limited.
In this embodiment, the first address request packet is a DHCP discover packet, and carries at least a client identifier and the like. Here, the client identifier may be a MAC address, and the like, and the embodiment of the present application is not particularly limited.
In this embodiment, the target client sends the first address request message in a broadcast form through the wireless network.
S220: when the first address request message does not carry the client address of the target client, if a server switching event is detected, selecting a reference address to be allocated to the target client from an address pool; the reference address is a free address in the address pool.
Illustratively, in this embodiment, the client address refers to an IP address of the client.
In this embodiment, the server switching event refers to switching the server from a normal operating state to an abnormal state. The normal working state represents that the server can normally distribute the address for the client, and the abnormal state represents that the server cannot normally distribute the address for the client.
In this embodiment, before executing step S220, whether a server switching event occurs is detected, and there are various ways to detect the server switching event, and this embodiment of the present application is not particularly limited. As an embodiment, when the feedback information of the server is not received within a preset time (for example, 1 minute), the server is considered to be in an abnormal state, and a server switching event occurs.
For example, in this embodiment, there may be multiple implementation manners for determining, from the address pool, a reference address to be allocated to the target client, for example, any free address in the address pool may be used as the reference address, and a minimum free address in the address pool may also be used as the reference address, which is not specifically limited in this embodiment of the application.
S230: and sending a second address request message carrying the reference address to the first server to request the first server to allocate an address for the target client based on the reference address.
Illustratively, in this embodiment, for a plurality of servers connected in a relay manner, it allocates addresses to clients coming online in an order defined in advance to perform address allocation functions, for example, a first server performing an address allocation function is a first server in the order to perform the address allocation function, and when the server fails, the address allocation function is performed by a second server in the order to perform the address allocation function. Here, the order in which the address assignment function is executed may be, for example, a server numbering order, and the embodiment of the present application is not particularly limited.
Based on the above description, in this embodiment, the first server may be a first server located after the server sending the server switching event in the sequence of executing the address assignment function, and in this step S230, a second address request packet carrying a reference address is sent to the first server, specifically, the reference address is encapsulated in an option50 field of the first address request packet to form the second address request packet, and the second address request packet is sent to the first server.
Here, the option50 field is a field of the request IP address, which is defined as follows:
Type 0x32
Length 4
Option string
wherein, the Type field is filled with 0x32 fixed value, and marks the option as option50; the Length field is a fixed value of 4, which represents that the whole option Length is 4; the Option field is the Option50 actually encapsulates the content (i.e., the reference address requested to be allocated), and the type of the encapsulated data is string.
After receiving the second address request message, the first server allocates an address to the target client based on a reference address in the second address request message, and specifically, the first server may directly use the reference address as the address allocated to the target client.
As an optional embodiment, the first server may further compare the client address with a minimum free address in an address pool thereof, allocate the client address to the target client if the client address is consistent with the minimum free address in the address pool, and allocate the minimum free address to the target client if the client address is inconsistent with the minimum free address.
Thus, the flow shown in fig. 2 is completed.
As can be seen from the flow shown in fig. 2, in the embodiment of the present application, when a server switching event is detected, a reference address is determined from an address pool, and a second address request message carrying the reference address is sent to a first server, so that the first server allocates an address for a client according to a target reference, thereby avoiding a situation that the client fails to be online due to allocation starting from a minimum address when the server is switched; further, the second address request message carrying the reference address is sent to the first server, so that the first server allocates addresses for the clients according to the reference address, transmission of a large number of invalid messages in the network due to allocation of the server from the minimum address is avoided, message data transmitted in the network is reduced, and network load is reduced.
As an optional implementation manner of the embodiment of the present application, if a server switching event is not detected, the address allocation method further includes:
and sending a first address request message to a second server to request the second server to distribute an address for the target client based on the first address request message.
For example, in this embodiment, if a server switching event is not detected, the first address request message is directly sent to the second server to request the second server to allocate an address to the target client based on the first address request message, where the second server is a server that allocates an address to a previous online client or a first server in the order of executing the address allocation function, and may be specifically determined according to the target client, for example, when the target client is a first online client, the second server is the first server in the order of executing the address allocation function; when the target client is not the first client to be on-line, the second server is a server for allocating addresses to the last client to be on-line.
In this embodiment, after receiving the first address request packet, the second server allocates an address to the target client based on the first address request packet, specifically, the second server may allocate any free address in its address pool to the target client, and may also allocate the smallest free address in its address pool to the target client, which is not specifically limited in this embodiment of the application.
As an optional implementation manner of the embodiment of the present application, if a server switching event is not detected, the address allocation method further includes:
it is checked whether at least one address in the address pool has been allocated.
Exemplarily, in this embodiment, the checking whether at least one address in the address pool has been allocated may specifically be: it is determined according to the obtained client information record that, for example, if the obtained client information record is empty, none of the addresses in the address pool is considered to be allocated, and if the obtained client information record has record information, at least one address in the address pool is considered to be allocated. For the obtained client information record, reference may be made to the following detailed description of the embodiments, which is not repeated here.
If yes, sending the first address request message to a second server to request the second server to distribute an address for the target client based on the first address request message;
if not, selecting a reference address to be allocated to the target client from the address pool, and sending a second address request message carrying the reference address to the second server to request the second server to allocate the address to the target client based on the reference address.
For example, in this embodiment, the second server is a server that allocates an address to a previous online client or a first server in the above order to perform the address allocation function, for example, when the target client is a first online client, the second server is the first server in the above order to perform the address allocation function; when the target client is not the first client to be on-line, the second server is a server for allocating addresses to the last client to be on-line.
If the addresses in the address pool are not allocated, the target client is determined to be the first online client, and the first address request message is directly sent to the second server to request the second server to allocate the addresses for the target client based on the first address request message.
And if at least one address in the address pool is already allocated, determining that the target client is not the first on-line client, and after determining a reference address to be allocated to the target client from the address pool, sending a second address request message carrying the reference address to a second server to request the second server to allocate the address to the target client based on the reference address. For a method for determining a reference address to be allocated to a target client, reference may be made to the above exemplary description of the embodiments, and details are not described here again.
As an optional implementation manner of this embodiment, the selecting a reference address to be allocated to the target client from the address pool in step S220 includes:
first, the client addresses to which the other clients are assigned are specified from the obtained client information records.
For example, in this embodiment, the client information record may be recorded after each client is online, and the client information record may be stored in a table form. Specifically, the client information record includes at least one piece of client information, and each piece of client information at least includes: client identification, address information, server identification, server operating state, and the like. The address information is IP address information, and the server identifier may be a MAC address of the server, number information of the server, or an IP address of the server.
For example, the client information record may be:
CID IP Server status
CID1 20.1.1.2 10.1.1.1 UP
CID2 20.1.1.3 10.1.1.1 UP
the CID is a client identifier, the IP is IP address information distributed by the client, the Server is a Server identifier, and the status is a working state of the Server corresponding to the Server identifier, wherein up represents that the Server is in a normal working state, and down represents that the Server is in an abnormal state.
Secondly, a free address except the client addresses distributed by other clients is selected from the address pool as a reference address.
For example, there may be many implementations to select a free address from the address pool as the reference address, where the free address is other than the client address allocated to each other client, for example, any free address in the address pool other than the client address allocated to each other client may be used as the reference address, and the smallest address in the address pool other than the client address allocated to each other client may also be used as the reference address, which is not specifically limited in the embodiment of the present application.
As an optional implementation manner of this embodiment, when the first address request packet carries a client address of the target client, the address allocation method further includes:
and inquiring whether target client information corresponding to the target client exists from the obtained client information record.
Illustratively, in this embodiment, the target client information includes at least: target client identification, address information, server identification, server status, and the like, which is not specifically limited in the embodiments of the present application.
In this embodiment, the step of querying whether target client information corresponding to the target client exists in the obtained client information record may specifically be: and inquiring whether target client information matched with the keyword exists in the obtained client information record by taking the target client identifier carried by the first address request message as the keyword.
If not, and a server switching event is detected, sending the first address request message to the first server to request the first server to allocate an address for the target client based on the first address request message.
Illustratively, if the target client information does not exist in the obtained client information record and a server switching event is detected, directly sending a first address request message to the first server to request the first server to allocate an address for the target client based on the first address request message.
After receiving the first address request message, the first server allocates an address to the target client based on the client address in the first address request message, and specifically, the first server may directly use the client address as the address allocated to the target client.
If not, and the server switching event is not detected, directly sending the first address request message to a second server to request the second server to distribute an address for the target client based on the first address request message.
After receiving the first address request message, the second server allocates an address to the target client based on the client address in the first address request message, and specifically, the first server may directly use the client address as the address allocated to the target client. As an optional embodiment, the first server may also compare the client address with a minimum free address in its address pool, and if the client address is consistent with the minimum free address in its address pool, allocate the client address to the target client, and if the client address is inconsistent with the minimum free address in its address pool, allocate the minimum free address to the target client.
If the address of the client in the target client information is different from the address of the client of the target client carried in the first address request message, discarding the first address request message.
If the address of the client in the target client information is the same as the address of the client of the target client carried by the first address request message, if a server switching event is detected, the first address request message is sent to the first server to request the first server to distribute the address for the target client based on the first address request message.
Exemplarily, if the obtained client information record has the target client information, further comparing whether the client address in the target client information is the same as the client address of the target client carried by the first address request message, if not, considering that the first address request message is an attack message, and discarding the first address request message; if the two addresses are the same and a server switching event is detected, sending a first address request message to a first server to request the first server to allocate an address for a target client based on the first address request message, wherein the specific address allocation method refers to the description that the first server allocates an address for the target client based on the first address request message, and is not described herein again; if the two addresses are the same and the server switching event is not detected, the first address request message is sent to the second server to request the second server to allocate the address for the target client based on the first address request message, and for the specific address allocation method, reference is made to the description that the second server allocates the address for the target client based on the first address request message, which is not described herein again.
As an optional implementation manner of the embodiment of the present application, the address allocation method further includes:
firstly, when an address response message returned to a target client by a first server is received, the distributed address of the target client and the lease of the distributed address carried in the address response message are obtained.
For example, in this embodiment, when an address response packet returned to the target client by the first server is received, after the allocated address of the target client and the lease of the allocated address carried in the address response packet are obtained, the address response packet is sent to the target client.
Secondly, when the target client is determined to be on line successfully, the distributed address of the target client, the lease of the distributed address, the identification of the first server and the state of the first server are taken as target client information and recorded.
For example, in this embodiment, there may be many implementation manners for determining that the target client is online, for example, when a feedback message of the target client for the address response message is received, the target client is considered to be online, and this embodiment of the present application is not particularly limited.
In this embodiment, in this step, after it is determined that the target client is online, the address allocated to the target client, the lease of the allocated address, the identifier of the target server, and the state of the first server are taken as target client information and recorded.
As an optional implementation manner of the embodiment of the present application, the address allocation method further includes:
firstly, when an address response message returned to the target client by the second server is received, the address allocated to the target client and the lease of the allocated address carried in the address response message are acquired.
Secondly, when the target client is determined to be on-line successfully, the distributed address of the target client, the lease of the distributed address, the identification of the second server and the state of the second server are taken as target client information and recorded.
The following describes an overall flow of a scheme provided in an embodiment of the present application:
when a first address request message sent by a target client is received, judging whether the first address request message carries a client address of the target client, if the first address request message carries the client address of the target client, further judging whether client information corresponding to a client identifier exists in an obtained client information record, if not, further detecting whether a current server is in a normal working state, and if the current server is in the normal working state, sending the first address request message to the current server; and if the current server is in an abnormal state, sending the first address request message to a target server.
If the address in the client information is inconsistent with the client address, directly discarding the first address request message; if the address in the client information is consistent with the client address, further detecting whether the current server is in a normal working state, and if the current server is in the normal working state, sending a first address request message to the current server; and if the current server is in an abnormal state, sending the first address request message to the target server.
If the first address request message does not carry a client address, further judging whether client information corresponding to a client identifier exists in the obtained client information record, if not, determining that the client is a newly on-line client, and if the current server is in a normal working state, sending a second address request message carrying a reference address to the current server; and if the current server is in an abnormal state, sending a second address request message carrying the reference address to the target server. If the address exists and the current server is in a normal working state, sending a second address request message carrying a reference address to the current server; and if the second address request message exists and the current server is in an abnormal state, sending the second address request message carrying the reference address to the target server.
The following describes, by way of example, a client online provided in an embodiment of the present application:
fig. 3 is an exemplary diagram of online networking of a client, as shown in fig. 3:
1. when a first client CID1 is going to be on-line, a first address request message is sent to the relay equipment, at the moment, the obtained client information record is empty, the relay equipment directly sends the first address request message to the server 1 which is in a normal working state at present, the first address request message does not carry the client address, at the moment, the server 1 normally allocates an address for the CID1, namely, the minimum idle address in an address pool is allocated to the CID1, and after the CID1 is determined to be on-line successfully, the allocated address of the CID1, the lease of the address, the identifier of the server 1 and the state of the server 1 are used as CID1 information and recorded. Taking the address pool in fig. 1 as an example, in this embodiment, the address allocated to CID1 is 20.1.1.2.
The CID1 information recorded is as follows:
CID IP Server status
CID1 20.1.1.2 10.1.1.1 UP
2. when a second client CID2 comes online, sending a first address request message to the relay device, at this time, the relay device does not inquire CID2 information in the obtained client information record, selecting an idle address except the client addresses allocated to other clients in the address pool as a reference address to be allocated to CID2, if the working state of the server 1 is a normal working state, sending a second address request message carrying the reference address to the server 1, and after determining that CID2 comes online successfully, taking the address allocated to CID2, the lease of the address, the identifier of the server 1, and the state of the server 1 as CID2 information and recording, taking the address pool in fig. 1 as an example, in the present embodiment, the reference address is 20.1.1.3. If the working state of the server 1 is the normal working state, the online process of each client to be online later is consistent with the online process of the CID2, and details are not repeated here.
The recorded CID2 information and other client information are as follows:
CID IP Server status
CID1 20.1.1.2 10.1.1.1 UP
CID2 20.1.1.3 10.1.1.1 UP
…… …… …… ……
3. assuming that the server 1 has allocated addresses to 50 clients, the operating status of the server 1 changes to an abnormal status, at this time, if the client CID51 wants to go online, the server sends a first address request message to the relay device, at this time, the relay device does not inquire CID51 information in the obtained client information record, selects an idle address in the destination pool, except the client addresses allocated to other clients, as a reference address to be allocated to the CID51 (for example, 20.1.1.52 in the address pool of fig. 1), encapsulates the reference address into the first address request message, forms a second address request message, and sends the second address request message to the server 2, and when it is determined that the CID51 goes online successfully, the address allocated to the CID51, the lease of the address, the identifier of the server 2, and the status of the server 2 are taken as CID51 information and recorded, and the operating status of the server 1 in the CID1 information — CID50 information is refreshed.
The CID51 information recorded is as follows:
CID IP Server status
CID1 20.1.1.2 10.1.1.1 DOWN
CID2 20.1.1.3 10.1.1.1 DOWN
…… …… …… ……
CID50 20.1.1.51 10.1.1.1 DOWN
CID51 20.1.1.52 10.1.1.2 UP
4. assuming that the server 1 allocates addresses to 50 clients, and then the CID2 is going to be on-line (before disconnection), sending a first address request packet to the relay device, where the first address request packet carries a client address 20.1.1.3, the relay device queries CID2 information from the obtained client information record, but the address information in the CID2 is not the client address, and then considering the first address request packet as an attack packet, and discarding the first address request packet.
5. Assuming that the server 1 has allocated addresses to 50 clients, the operating state of the server 1 changes to an abnormal state, at this time, if the client CID51 wants to go online, the CID51 sends a first address request message to the relay device, where the first address request message carries the client address 20.1.1.100, and at this time, the relay device does not inquire CID51 information in the obtained client information record, the relay device directly sends the first address request message to the server 2, and when it is determined that the CID51 goes online successfully, the address allocated by the CID51, the lease of the address, the identifier of the server 2, and the state of the server 2 are taken as CID51 information and recorded, and the operating state of the server 1 in the CID1 information-CID 50 information is refreshed.
The CID51 information recorded is as follows:
CID IP Server status
CID1 20.1.1.2 10.1.1.1 DOWN
CID2 20.1.1.3 10.1.1.1 DOWN
…… …… …… ……
CID50 20.1.1.51 10.1.1.1 DOWN
CID51 20.1.1.100 10.1.1.2 UP
this completes the description of fig. 3.
Corresponding to the embodiment of the method, the embodiment of the application also provides an embodiment of the device and the terminal applied by the device.
As shown in fig. 4, fig. 4 is a block diagram of an address allocation apparatus provided in an embodiment of the present application, where the address allocation apparatus is applied to a relay device, the relay device is connected to at least two servers in the same network segment, and each server has configured the same address pool, and the address allocation apparatus includes:
the first address request message receiving module is used for receiving a first address request message sent by a target client;
the reference address determining module is used for selecting a reference address to be allocated to the target client from the address pool if a server switching event is detected when the first address request message does not carry the client address of the target client; the reference address is a free address in the address pool;
the first address allocation module is used for sending a second address request message carrying a reference address to the first server so as to request the first server to allocate an address for the target client based on the reference address;
the server switching event refers to the switching of the server from a normal working state to an abnormal state.
As an optional implementation manner of the embodiment of the present application, if a server switching event is not detected, the address allocating apparatus further includes:
and the second address allocation module is used for sending the first address request message to the second server so as to request the second server to allocate the address for the target client based on the first address request message.
As an optional implementation manner of the embodiment of the present application, if a server switching event is not detected, the address allocating apparatus further includes:
a checking module for checking whether at least one address in the address pool has been allocated;
the third address allocation module is used for sending the first address request message to the second server if the first address request message is received, so as to request the second server to allocate an address for the target client based on the first address request message;
and the fourth address allocation module is used for selecting a reference address to be allocated to the target client from the address pool if the address is not allocated to the target client, and sending a second address request message carrying the reference address to the second server so as to request the second server to allocate the address to the target client based on the reference address.
As an optional implementation manner of the embodiment of the present application, the reference address determining module is specifically configured to:
determining client addresses distributed by other clients from the obtained client information records;
and selecting a free address except the client addresses distributed by other clients from the address pool as a reference address.
As an optional implementation manner of the embodiment of the present application, when the first address request packet carries a client address of the target client, the address allocating apparatus further includes:
the query module is used for querying whether target client information corresponding to the target client exists in the obtained client information records;
the fifth address allocation module is used for sending the first address request message to the first server to request the first server to allocate an address for the target client based on the first address request message if the server switching event is not detected;
the sixth address allocation module is used for discarding the first address request message if the client address in the target client information is different from the client address of the target client carried by the first address request message;
and the seventh address allocation module is used for sending the first address request message to the first server if the client address in the target client information is the same as the client address of the target client carried by the first address request message, so as to request the first server to allocate an address for the target client based on the first address request message.
As an optional implementation manner of the embodiment of the present application, the address allocating apparatus further includes:
the acquisition module is used for acquiring the address distributed by the target client and the lease of the distributed address carried in the address response message when receiving the address response message returned to the target client by the first server;
and the recording module is used for taking the allocated address of the target client, the lease of the allocated address, the identifier of the first server and the state of the first server as the target client information and recording the target client information when the target client is determined to be successfully on line.
As an optional implementation manner of the embodiment of the present application, the reference address is in an option50 field of the second address request packet.
The description of the apparatus shown in fig. 4 is thus completed.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the modules described as separate components may or may not be physically separate, and the components displayed as modules may or may not be physical modules, may be located in one place, or may be distributed on a plurality of network modules. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present application. One of ordinary skill in the art can understand and implement it without inventive effort.
Correspondingly, an embodiment of the present application further provides a hardware structure diagram of the apparatus shown in fig. 4, and specifically as shown in fig. 5, the electronic device may be a device for implementing the method. As shown in fig. 5, the hardware structure includes: a processor and a memory.
Wherein the memory is to store machine executable instructions;
the processor is configured to read and execute the machine executable instructions stored in the memory, so as to implement the corresponding address allocation method embodiments as described above.
For one embodiment, the memory may be any electronic, magnetic, optical, or other physical storage device that may contain or store information such as executable instructions, data, and the like. For example, the memory may be: volatile memory, non-volatile memory, or similar storage media. In particular, the Memory may be a RAM (random Access Memory), a flash Memory, a storage drive (e.g., a hard disk drive), a solid state disk, any type of storage disk (e.g., an optical disk, a DVD, etc.), or similar storage medium, or a combination thereof.
Up to this point, the description of the electronic apparatus shown in fig. 5 is completed.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
Other embodiments of the present description will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This specification is intended to cover any variations, uses, or adaptations of the specification following, in general, the principles of the specification and including such departures from the present disclosure as come within known or customary practice within the art to which the specification pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the specification being indicated by the following claims.
It will be understood that the present description is not limited to the precise arrangements described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the description is limited only by the appended claims.
The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalents, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of the present disclosure.

Claims (14)

1. An address allocation method, applied to a relay device, wherein the relay device is connected to at least two servers in the same network segment, and each server has configured the same address pool, the method comprising:
receiving a first address request message sent by a target client;
when the first address request message does not carry the client address of the target client, if a server switching event is detected, selecting a reference address to be allocated to the target client from the address pool; the reference address is a free address in the address pool;
sending a second address request message carrying the reference address to a first server to request the first server to allocate an address for the target client based on the reference address;
the server switching event refers to switching the server from a normal working state to an abnormal state.
2. The method of claim 1, wherein if no server switch event is detected, the method further comprises:
and sending the first address request message to a second server to request the second server to distribute an address for the target client based on the first address request message.
3. The method of claim 1, wherein if no server switch event is detected, the method further comprises:
checking whether at least one address in the pool of addresses has been allocated;
if so, sending the first address request message to a second server to request the second server to allocate an address for the target client based on the first address request message;
if not, selecting a reference address to be allocated to the target client from the address pool, and sending a second address request message carrying the reference address to the second server to request the second server to allocate an address to the target client based on the reference address.
4. The method according to claim 1 or 3, wherein the selecting a reference address to be allocated to the target client from the address pool comprises:
determining client addresses distributed by other clients from the obtained client information records;
and selecting a free address except the client addresses distributed by other clients from the address pool as the reference address.
5. The method according to claim 1, wherein when the first address request packet carries the client address of the target client, the method further comprises:
inquiring whether target client information corresponding to the target client exists from the obtained client information record;
if not, and a server switching event is detected, sending the first address request message to the first server to request the first server to distribute an address for the target client based on the first address request message;
if so, discarding the first address request message when the client address in the target client information is different from the client address of the target client carried by the first address request message;
if the address of the client in the target client information is the same as the address of the client of the target client carried in the first address request message, if a server switching event is detected, sending the first address request message to the first server to request the first server to allocate an address for the target client based on the first address request message.
6. The method of claim 1, further comprising:
when an address response message returned to the target client by the first server is received, acquiring the address allocated to the target client and the lease of the allocated address carried in the address response message;
and when the target client is determined to be on-line successfully, taking the allocated address of the target client, the lease of the allocated address, the identifier of the first server and the state of the first server as the target client information and recording the target client information.
7. The method according to claim 1 or 3, wherein the reference address is encapsulated in an option50 field of the second address request message.
8. An address allocation apparatus, wherein the apparatus is applied to a relay device, the relay device is connected to at least two servers in the same network segment, each server has configured the same address pool, the apparatus comprises:
the first address request message receiving module is used for receiving a first address request message sent by a target client;
a reference address determining module, configured to, when the first address request packet does not carry a client address of the target client, select, if a server switching event has been detected, a reference address to be allocated to the target client from the address pool; the reference address is a free address in the address pool;
a first address allocation module, configured to send a second address request packet carrying the reference address to a first server, so as to request the first server to allocate an address to the target client based on the reference address;
the server switching event refers to the switching of the server from a normal working state to an abnormal state.
9. The apparatus of claim 8, wherein if no server switch event is detected, the apparatus further comprises:
and the second address allocation module is used for sending the first address request message to a second server so as to request the second server to allocate an address for the target client based on the first address request message.
10. The apparatus of claim 8, wherein if no server switch event is detected, the apparatus further comprises:
a checking module for checking whether at least one address in the address pool has been allocated;
a third address allocation module, configured to send the first address request packet to a second server if the first address request packet is received, so as to request the second server to allocate an address to the target client based on the first address request packet;
and the fourth address allocation module is used for selecting a reference address to be allocated to the target client from the address pool if the address pool is not the target client, and sending a second address request message carrying the reference address to the second server so as to request the second server to allocate the address to the target client based on the reference address.
11. The apparatus according to claim 8 or 10, wherein the reference address determining module is specifically configured to:
determining client addresses distributed by other clients from the obtained client information records;
and selecting a free address except the client addresses distributed by other clients from the address pool as the reference address.
12. The apparatus according to claim 8, wherein when the first address request packet carries the client address of the target client, the apparatus further comprises:
the query module is used for querying whether target client information corresponding to the target client exists in the obtained client information records;
a fifth address allocation module, configured to, if no, send the first address request packet to the first server to request the first server to allocate an address to the target client based on the first address request packet, and a server switching event is detected;
a sixth address allocation module, configured to discard the first address request packet if the client address in the target client information is different from the client address of the target client carried in the first address request packet;
and a seventh address allocation module, configured to, if the client address in the target client information is the same as the client address of the target client carried in the first address request packet, send the first address request packet to the first server to request the first server to allocate an address to the target client based on the first address request packet if a server switching event is detected.
13. The apparatus of claim 8, further comprising:
an obtaining module, configured to obtain, when an address response packet returned to the target client by the first server is received, an address allocated to the target client and a lease of the allocated address, where the address response packet is carried by the address response packet;
and the recording module is used for taking the allocated address of the target client, the lease of the allocated address, the identifier of the first server and the state of the first server as the target client information and recording the target client information when the target client is determined to be successfully on line.
14. The apparatus according to claim 8 or 10, wherein the reference address is in an option50 field of the second address request message.
CN202211480628.7A 2022-11-24 2022-11-24 Address allocation method and device Active CN115550319B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211480628.7A CN115550319B (en) 2022-11-24 2022-11-24 Address allocation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211480628.7A CN115550319B (en) 2022-11-24 2022-11-24 Address allocation method and device

Publications (2)

Publication Number Publication Date
CN115550319A true CN115550319A (en) 2022-12-30
CN115550319B CN115550319B (en) 2023-03-28

Family

ID=84720928

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211480628.7A Active CN115550319B (en) 2022-11-24 2022-11-24 Address allocation method and device

Country Status (1)

Country Link
CN (1) CN115550319B (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1738269A (en) * 2004-08-17 2006-02-22 杭州华为三康技术有限公司 Method to allocate protocol relay address table and server address pool for synchronization dynamic host machine
CN101951417A (en) * 2010-09-21 2011-01-19 北京星网锐捷网络技术有限公司 Method, system and trunk equipment for assigning multiple server addresses
WO2011029406A1 (en) * 2009-09-11 2011-03-17 华为技术有限公司 Ip address automatic assignment method, equipment and system
CN102025798A (en) * 2010-12-15 2011-04-20 华为技术有限公司 Address allocation processing method, device and system
CN102685270A (en) * 2012-05-25 2012-09-19 杭州华三通信技术有限公司 Method and equipment for distributing dynamic addresses
US20130080614A1 (en) * 2011-09-27 2013-03-28 Pradeep Iyer Client Aware DHCP Lease Management
CN108259636A (en) * 2017-09-29 2018-07-06 新华三技术有限公司 A kind of message processing method and device
CN108600407A (en) * 2018-03-28 2018-09-28 新华三技术有限公司 A kind of IP address distribution method, device, equipment and machine readable storage medium
CN108632399A (en) * 2017-08-24 2018-10-09 新华三技术有限公司 A kind of address distribution method and device
CN109672758A (en) * 2017-10-13 2019-04-23 中兴通讯股份有限公司 Address distribution method, access server and computer storage medium
CN110730254A (en) * 2019-10-14 2020-01-24 新华三信息安全技术有限公司 Address allocation method, device, relay equipment and medium

Patent Citations (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1738269A (en) * 2004-08-17 2006-02-22 杭州华为三康技术有限公司 Method to allocate protocol relay address table and server address pool for synchronization dynamic host machine
WO2011029406A1 (en) * 2009-09-11 2011-03-17 华为技术有限公司 Ip address automatic assignment method, equipment and system
CN101951417A (en) * 2010-09-21 2011-01-19 北京星网锐捷网络技术有限公司 Method, system and trunk equipment for assigning multiple server addresses
EP2654268A1 (en) * 2010-12-15 2013-10-23 Huawei Technologies Co., Ltd. Address allocation processing method, apparatus, and system
CN102025798A (en) * 2010-12-15 2011-04-20 华为技术有限公司 Address allocation processing method, device and system
US20130080614A1 (en) * 2011-09-27 2013-03-28 Pradeep Iyer Client Aware DHCP Lease Management
CN102685270A (en) * 2012-05-25 2012-09-19 杭州华三通信技术有限公司 Method and equipment for distributing dynamic addresses
CN108632399A (en) * 2017-08-24 2018-10-09 新华三技术有限公司 A kind of address distribution method and device
WO2019037664A1 (en) * 2017-08-24 2019-02-28 新华三技术有限公司 Address allocation
CN108259636A (en) * 2017-09-29 2018-07-06 新华三技术有限公司 A kind of message processing method and device
CN109672758A (en) * 2017-10-13 2019-04-23 中兴通讯股份有限公司 Address distribution method, access server and computer storage medium
CN108600407A (en) * 2018-03-28 2018-09-28 新华三技术有限公司 A kind of IP address distribution method, device, equipment and machine readable storage medium
CN110730254A (en) * 2019-10-14 2020-01-24 新华三信息安全技术有限公司 Address allocation method, device, relay equipment and medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
孙文胜;张园园;张晓晓;: "DHCPv6 Relay报文转发功能实现研究" *

Also Published As

Publication number Publication date
CN115550319B (en) 2023-03-28

Similar Documents

Publication Publication Date Title
CN101951417B (en) Method, system and trunk equipment for assigning multiple server addresses
US8769057B1 (en) Employing a hierarchy of servers to resolve fractional IP addresses
US20210119965A1 (en) Address Management Method and Apparatus
US8161135B2 (en) Device identification number based name service
RU2464722C2 (en) Method, device and system for distribution of messages
CN107087041B (en) Method and device for statically binding IP address to DHCP client
CN108418907B (en) IP address allocation method and device
RU2010130476A (en) INFORMATION PROCESSING APPARATUS, DEVICE, METHOD OF MANAGING INFORMATION PROCESSING APPARATUS AND DATA STORAGE MEDIA
CN111064804A (en) Network access method and device
EP1993238A1 (en) A device and method and system for acquiring ipv6 address
CN107070719B (en) Equipment management method and device
CN111163245B (en) Method and device for adding network camera in network hard disk video recorder
CN111629083B (en) Method and device for acquiring IP address, storage medium and electronic device
CN108089934A (en) Cluster management method and cluster server
CN115550319B (en) Address allocation method and device
CN111245974B (en) Address allocation method, device, equipment and storage medium
US10003572B2 (en) Information processing apparatus and recording medium
CN113132498B (en) Message processing method, relay device, system and storage medium
CN111049948B (en) Domain name detection method and device
CN108712522B (en) IP address allocation method and device
CN109451093B (en) Loopback interface address allocation method and device
CN108965363B (en) Method and equipment for processing message
CN114513455A (en) Route tracking method, device, equipment and storage medium
CN113347285B (en) Automatic allocation method, device and equipment for managing IP address
CN111600832B (en) Message processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant