WO2017206572A1 - 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机 - Google Patents

一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机 Download PDF

Info

Publication number
WO2017206572A1
WO2017206572A1 PCT/CN2017/077420 CN2017077420W WO2017206572A1 WO 2017206572 A1 WO2017206572 A1 WO 2017206572A1 CN 2017077420 W CN2017077420 W CN 2017077420W WO 2017206572 A1 WO2017206572 A1 WO 2017206572A1
Authority
WO
WIPO (PCT)
Prior art keywords
address
dhcp
data packet
network segment
request
Prior art date
Application number
PCT/CN2017/077420
Other languages
English (en)
French (fr)
Inventor
黄江伟
Original Assignee
上海斐讯数据通信技术有限公司
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 上海斐讯数据通信技术有限公司 filed Critical 上海斐讯数据通信技术有限公司
Publication of WO2017206572A1 publication Critical patent/WO2017206572A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming
    • H04L61/50Address allocation
    • H04L61/5007Internet protocol [IP] addresses
    • H04L61/5014Internet protocol [IP] addresses using dynamic host configuration protocol [DHCP] or bootstrap protocol [BOOTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L61/00Network arrangements, protocols or services for addressing or naming

Definitions

  • the present invention relates to computer network technology, and in particular to an IP address management method and a DHCP client in a multi-DHCP server network environment.
  • the network environment has become more and more complex, and more and more cases include multiple DHCP servers in a network environment.
  • the IP address pool managed by each DHCP server in a network environment usually belongs to different network segments.
  • a user's network access terminal such as a router, mobile phone, computer, etc.
  • a DHCP request to obtain an IP address from the DHCP server.
  • the terminal uses the IP address that was first replied.
  • this assigned IP address is sometimes not necessarily what we need, and sometimes it is not possible to connect to the external network through this IP address.
  • the technical problem to be solved by the embodiment of the present invention is that the IP address assigned by the DHCP server is inconsistent with the network segment that the user needs to access.
  • a method for managing an IP address in a multi-DHCP server network environment, providing a DHCP client that accepts the IP address allocation of the DHCP server, the DHCP client performing the IP address management method, and the IP address management method includes:
  • the method for managing an IP address in the network environment of the multiple DHCP server further includes: generating, according to the DHCP OFFER data packet fed back by the DHCP server, a selection list; the selection list includes all DHCP servers in the DHCP OFFER data packet. The assigned IP address;
  • the network segment where the first IP address is located is used as the preset network segment according to a user's selection instruction of a first IP address in the selection list.
  • the method for managing an IP address in the network environment of the multiple DHCP server includes: rebroadcasting an IP address request after the network segment where the first IP address is located as the preset network segment.
  • the method for managing an IP address in the network environment of the multiple DHCP server, after the network segment where the first IP address is located as the preset network segment, further includes: allocating the first The DHCP server of the IP address sends an IP address request.
  • the foregoing method for managing an IP address in a multi-DHCP server network environment releases the current before the rebroadcast IP address request or before sending the IP address request to the DHCP server that allocates the first IP address.
  • the foregoing method for managing an IP address in a multi-DHCP server network environment pre-receives the setting of the preset network segment before performing the IP address request for the first time.
  • an embodiment of the present invention further discloses a DHCP client, including:
  • a parsing unit configured to parse the received DHCP OFFER data packet
  • a matching unit configured to match the allocated IP address in the DHCP OFFER data packet with a preset network segment
  • a processing unit configured to accept an IP address lease in the DHCP OFFER data packet when the allocated IP address falls into the preset network segment.
  • the foregoing DHCP client further includes:
  • a generating unit configured to generate a selection list according to the DHCP OFFER data packet fed back by the DHCP server; the selection list includes an IP address allocated by all DHCP servers in the DHCP OFFER data packet;
  • a setting unit configured to use, according to a user's selection instruction of a first IP address in the selection list, a network segment where the first IP address is located as the preset network segment.
  • the foregoing DHCP client further includes: a first requesting unit, configured to re-broadcast the IP address after the setting unit uses the network segment where the first IP address is located as the preset network segment request.
  • the foregoing DHCP client further includes: a second requesting unit, configured to: after the setting unit uses the network segment where the first IP address is located as the preset network segment, The DHCP server of the first IP address sends an IP address request.
  • the foregoing DHCP client further includes: a releasing unit, configured to: before the first requesting unit rebroadcasts the IP address request, or the second requesting unit sends a DHCP server that allocates the first IP address Release the currently used IP address resource before sending an IP address request.
  • a releasing unit configured to: before the first requesting unit rebroadcasts the IP address request, or the second requesting unit sends a DHCP server that allocates the first IP address Release the currently used IP address resource before sending an IP address request.
  • the foregoing DHCP client further includes: a receiving unit, configured to pre-receive the setting of the preset network segment before the DHCP client first performs an IP address request.
  • the DHCP client matches the IP address assigned by the DHCP server with the preset network segment to select whether to accept the IP address lease, thereby realizing automatic matching and access to the network segment that the user wants to access. This avoids the problem of always being unable to access the required network segment, and the cumbersome operation of manually releasing and re-requesting IP resources.
  • the user can flexibly adjust the need to access the network segment during use. And automatic matching access.
  • the preset network segment set by the user is received in advance, and the network segment that the user wants to access can be quickly accessed after the DHCP client accesses the network.
  • FIG. 1 is a flowchart of an IP address management method in a multi-DHCP server environment according to an embodiment of the present invention
  • FIG. 2 is a flowchart of another IP address management method in a multi-DHCP server environment according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of an IP address management apparatus in a multi-DHCP server environment according to an embodiment of the present invention
  • FIG. 4 is a schematic structural diagram of an IP address management apparatus in another multi-DHCP server environment according to an embodiment of the present invention.
  • the DHCP client matches the IP address assigned by the DHCP server with the preset network segment to select whether to accept the IP address lease, thereby realizing automatic matching of the network segment that the user wants to access. Access avoids the problem of always being unable to access the required network segment, and the cumbersome operation of manually releasing and re-requesting IP resources.
  • the embodiment of the invention provides a method for managing an IP address in a multi-DHCP server network environment, which can be applied to an IP access environment, any network access end having a data transmission capability and a data processing capability, and accepting a DHCP server share IP address.
  • device may be a router, a computer equipped with a wireless network card, or a smart phone with a WiFi module.
  • the above mentioned network access device will be referred to as a DHCP client.
  • the method for managing an IP address in a multi-DHCP server environment may include the following steps:
  • Step S101 Generate a selection list according to the DHCP OFFER data packet fed back by the DHCP server.
  • the DHCP client When the DHCP client logs in to the network for the first time, it will broadcast a DHCP DISCOVER packet through the UDP port to request the DHCP server to assign the corresponding IP address to itself.
  • the DHCP server listens to the DHCP DISCOVER broadcast, it selects the first vacant IP from the address pool it manages and feeds the client a DHCP OFFER packet. It includes information such as IP address, subnet mask, and address lease.
  • DHCP clients receive feedback from multiple DHCP DISCOVER packets.
  • the DHCP client reserves the first received DHCP OFFER data packet, discards (DROP) the subsequently received DHCP OFFER data packet, and sends a DHCP REQUEST broadcast data packet to the network to inform all DHCP servers. Which IP address the server will accept, so that when other DHCP servers receive the broadcast, they will revoke their offer to provide the IP address for the next IP address request.
  • the embodiment of the present invention will accept the first DHCP OFFER data packet by default and send a DHCP REQUEST broadcast data packet, but will not discard the subsequent packets.
  • the selection list includes IP addresses assigned by all DHCP servers in a DHCP OFFER packet.
  • the selection list is It is also possible not to include the IP address in the first received DHCP OFFER packet, ie the IP address currently being used.
  • the data in the selection list may be displayed in the form of a page. If the user interface of the DHCP client is a command line interface, the IP address information in the selection list may be displayed by the user on the display interface of the DHCP client by inputting a command statement.
  • Step S102 The network segment where the first IP address is located is used as a preset network segment according to a user's selection instruction of a first IP address in the selection list.
  • the user's selection instruction for the first IP address may be a page selection instruction or a command line command.
  • step S103 an IP address request is made.
  • the performing an IP address request may be a rebroadcast IP address request.
  • the broadcast IP address request may be the same as the DHCP DISCOVER packet format sent by the DHCP client when logging in to the network for the first time before step S101, that is, the source address of the encapsulated data packet is 0.0.0.0, and the target address is 255.255.255.255, plus Other related information on DHCP DISCOVER.
  • the performing an IP address request may also be to send an IP address request to a DHCP server that allocates the first IP address.
  • the broadcast request method is no longer used, and the format sent to the DHCP server data packet is the IP address of the DHCP server, and the source address may be the current IP address of the DHCP client, or may be 0.0. .0.0.
  • the DHCP client may release the currently used IP address before requesting the DHCP server to perform new IP address allocation.
  • the program occupies excessive CPU and memory resources, and the preset time can be set by a similar timer and the like, and broadcasted. After the IP address is requested, it is determined whether the DHCP OFFER data packet is received within the above-mentioned valid preset time, which can reflect whether the DHCP server is in a normal working state.
  • the DHCP server in view of the DHCP server's response to the DHCP client requesting the IP address in the normal state is usually about 0.2s, if the DHCP client's waiting time exceeds the predetermined time (such as custom 5s), there is no Upon receiving the DHCP OFFER replied by the DHCP server, it is determined that the DHCP server will not provide an IP address. At this time, the DHCP client outputs a DHCP request failure and ends the corresponding process such as the broadcast IP address request to save system resources.
  • the predetermined time such as custom 5s
  • Steps S104 to S105 parsing the received DHCP OFFER data packet, and matching the assigned IP address in the DHCP OFFER data packet with the preset network segment.
  • the reason why the IP address of the same network segment as the first IP address is selected in this embodiment instead of selecting the same IP address as the first IP address is because the time period of obtaining the first IP and replacing the IP is obtained.
  • the DHCP server may have already assigned the first IP address to other DHCP clients, so the first IP address cannot be allocated any more.
  • a hook function may be set to intercept the received data packet, and if the received data packet is a DHCP data packet, whether the IP address brought back by the DHCP data packet is a desired IP address, that is, whether The first IP address is in the same network segment. If yes, ACCEPT the packet, accepting the IP address lease in the DHCP OFFER packet, otherwise discarding the packet.
  • the currently used IP address is 192.168.1.56/24, and the user selects in the selection list.
  • the IP address of 10.6.61.89/24.
  • the DHCP OFFER packets including the assigned IP addresses of 192.168.1.46/24, 172.16.2.8/24, and 10.6.61.96/24 are received successively, the first 24 networks of the binary numbers of the IP addresses are compared.
  • the network bits of 192.168.1.46/24 and 172.16.2.8/24 are different from the network bits of 10.6.61.89/24, but the network bits of 10.6.61.96/24 and the network bits of 10.6.61.89/24 The same, that is, the two belong to the same network segment, so the first two DHCP OFFER packets are discarded, and the IP address lease in the third DHCP OFFER packet is accepted.
  • an IP address management method in a multi-DHCP server network environment can generate a selection list including all the IP addresses of the DHCP OFFER data packets, and then according to the user's autonomy to the IP address.
  • the selection can conveniently and quickly realize the flexible adjustment and automatic matching access of the user in the process of using the network segment, thereby improving the user experience.
  • the embodiment of the invention also discloses another IP address management method in a multi-DHCP server environment.
  • the embodiment of the present invention is equally applicable to a DHCP client that accepts the IP address assignment of the DHCP server, and the DHCP client performs the IP address management method.
  • the IP address management method in the multiple DHCP server environment may include the following steps:
  • Steps S201 to S202 parsing the received DHCP OFFER data packet, and matching the assigned IP address in the DHCP OFFER data packet with a preset network segment.
  • the preset network segment in this embodiment is set by the user and stored on the DHCP client before the DHCP is first connected to the network, instead of being described in the previous embodiment. After the DHCP client receives the DHCP OFEER, it is selected by the user.
  • Step S203 When the allocated IP address falls into the preset network segment, accept an IP address lease in the DHCP OFFER data packet.
  • the DHCP antenna data received first is received in a manner similar to the prior art.
  • the preset preset time may also be set by using a timer. If the preset time is exceeded, it is determined that the new DHCP OFFER data packet will not be received again. If the IP address in the network segment is set, the IP address lease in the first received DHCP OFFER packet is accepted.
  • the present embodiment is the same as the technical problem to be solved in the previous embodiment, that is, to avoid the delay in accessing the network that the user wants to access, and the cumbersome subsequent operations in the prior art.
  • both of them belong to the same technical idea by matching the assigned IP with the network segment preset by the user in advance or the network segment specified in the use process.
  • This embodiment can be used in combination with the previous embodiment, that is, steps S101 to S105 are performed after the step S203.
  • the IP address management method in the multi-DHCP server environment of the embodiment of the present invention performs the IP address to be accessed when the DHCP OFFER data packet sent by the DHCP server is received by setting the network segment to be accessed in advance. Filtering the selection, so that users do not need to re-designate the corresponding network segment during use, which further facilitates the user's use. Of course, if the user needs to re-select to access the new network segment during use, the reselection and access can be conveniently performed by the method as in the previous embodiment.
  • the embodiment of the present invention further provides a DHCP client corresponding to the IP address management method in the multi-DHCP server network environment in the first embodiment.
  • the DHCP client 30 can include:
  • the parsing unit 301 is configured to parse the received DHCP OFFER data packet
  • the matching unit 302 is configured to match the allocated IP address in the DHCP OFFER data packet with a preset network segment.
  • the processing unit 303 is configured to accept an IP address lease in the DHCP OFFER data packet when the allocated IP address falls into the preset network segment.
  • the DHCP client 30 may further include:
  • the generating unit 304 is configured to generate, according to the DHCP OFFER data packet fed back by the DHCP server, a selection list, where the selection list includes an IP address allocated by all DHCP servers in the DHCP OFFER data packet;
  • the setting unit 305 is configured to use, according to a user's selection instruction of a first IP address in the selection list, a network segment where the first IP address is located as the preset network segment;
  • the requesting unit 306 is configured to perform an IP address request.
  • the request unit 306 is configured to rebroadcast an IP address request.
  • the requesting unit 306 is configured to allocate a DHCP service to the first IP address.
  • the server sends an IP address request.
  • the DHCP client 30 may further include: a releasing unit 307, configured to send an IP address request to the DHCP server that allocates the first IP address before the requesting unit 306 rebroadcasts the IP address request. Before releasing the currently used IP address resource.
  • a releasing unit 307 configured to send an IP address request to the DHCP server that allocates the first IP address before the requesting unit 306 rebroadcasts the IP address request. Before releasing the currently used IP address resource.
  • the IP address management device 30 in the multi-DHCP server environment of the embodiment of the present invention may generate a selection list including all the IP addresses of the DHCP OFFER data packets, and then according to the user's independent selection of the IP address, It is convenient and quick to implement flexible adjustment and automatic matching access for users who want to access the network segment during use, thereby improving the user experience.
  • the embodiment of the present invention further provides another DHCP client, which corresponds to the IP address management method in the multi-DHCP server environment in the second embodiment.
  • the DHCP client 40 can include:
  • the receiving unit 401 is configured to pre-receive the setting of the preset network segment before the DHCP client 40 first performs an IP address request;
  • the parsing unit 402 is configured to parse the received DHCP OFFER data packet
  • the matching unit 403 is configured to match the allocated IP address in the DHCP OFFER data packet with a preset network segment
  • the processing unit 404 is configured to accept an IP address lease in the DHCP OFFER data packet when the allocated IP address falls into the preset network segment.
  • the above DHCP client 40 may further include a DHCP client 30 as described above.
  • the DHCP client 40 of the embodiment of the present invention filters the IP address by selecting the network segment to be accessed in advance, and receives the DHCP OFFER data packet sent by the DHCP server, so that the user does not need to use the network. Re-designate the corresponding network segment in the middle, which further facilitates the user's use. Of course, if the user needs to reselect the accessed network segment during use, the reselection can be conveniently performed by the method as in the previous embodiment.
  • the program can be executed by instructing related hardware, and the program can be stored in a computer readable storage medium, and the storage medium can include: ROM, RAM, magnetic disk or optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)
  • Small-Scale Networks (AREA)

Abstract

一种多DHCP服务器网络环境下的IP地址管理方法和DHCP客户机,其中,IP地址管理方法包括:提供一接受所述DHCP服务器IP地址分配的DHCP客户机,所述DHCP客户机执行所述IP地址管理方法,所述IP地址管理方法包括:解析接收到的DHCP OFFER数据包,并将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配;当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。通过所述多DHCP服务器网络环境下的IP地址管理方法和DHCP客户机,可以解决DHCP服务器分配的IP地址与用户需要接入的网段不一致的问题。

Description

一种多DHCP服务器网络环境下的IP地址管理方法和DHCP客户机 技术领域
本发明涉及计算机网络技术,特别是涉及一种多DHCP服务器网络环境下的IP地址管理方法和DHCP客户机。
背景技术
随着互联网和网络设备的迅速发展,网络环境变的越来越复杂,一个网络环境中包括多个DHCP服务器的情况也越来越多。为了避免地址冲突,一个网络环境下每个DHCP服务器管理的IP地址池通常都是属于不同网段。
当用户的网络接入终端(如路由器、手机和电脑等)需要连接网络的时候,会发出DHCP请求向DHCP服务器获取IP地址。在存在多个DHCP服务器的复杂环境中,终端会用最先回复的IP地址。然而,由于不同网段提供的服务在多数情况下是不一样的,所以这个被分配的IP地址有时并不一定是我们需要的,甚至有的时候都不能通过这个IP地址连接外网。
如果获取到了不希望获取的IP地址,需要用户手动地将通过命令该IP release掉,然后重新随机获取新的IP地址。必然的,这种概率性的服务将会严重影响用户的使用体验和使用效率。
发明内容
本发明实施例所要解决的技术问题是DHCP服务器分配的IP地址与用户需要接入的网段不一致的问题。
为了解决上述问题,本发明实施例提供的技术方案如下:
一种多DHCP服务器网络环境下的IP地址管理方法,提供一接受所述DHCP服务器IP地址分配的DHCP客户机,所述DHCP客户机执行所述IP地址管理方法,所述IP地址管理方法包括:
解析接收到的DHCP OFFER数据包,并将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配;
当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
可选的,上述的多DHCP服务器网络环境下的IP地址管理方法还包括,根据所述DHCP服务器反馈的DHCP OFFER数据包,生成一选择列表;所述选择列表包括所有DHCP服务器在DHCP OFFER数据包中分配的IP地址;
根据用户对所述选择列表中一第一IP地址的选择指令,将所述第一IP地址所处的网段作为所述预设网段。
可选的,上述的多DHCP服务器网络环境下的IP地址管理方法,于所述将所述第一IP地址所处的网段作为所述预设网段后还包括:重新广播IP地址请求。
可选的,上述的多DHCP服务器网络环境下的IP地址管理方法,于所述将所述第一IP地址所处的网段作为所述预设网段后还包括:向分配所述第一IP地址的DHCP服务器发送IP地址请求。
可选的,上述的多DHCP服务器网络环境下的IP地址管理方法,于所述重新广播IP地址请求前,或所述向分配所述第一IP地址的DHCP服务器发送IP地址请求前,释放当前使用的IP地址资源。
可选的,上述的多DHCP服务器网络环境下的IP地址管理方法,在首次进行IP地址请求前预先接收所述预设网段的设置。
为了解决上述的技术问题,本发明实施例还公开了一种DHCP客户机,包括:
解析单元,用于解析接收到的DHCP OFFER数据包;
匹配单元,用于将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配;
处理单元,用于当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
可选的,上述的DHCP客户机,还包括:
生成单元,用于根据所述DHCP服务器反馈的DHCP OFFER数据包,生成一选择列表;所述选择列表包括所有DHCP服务器于DHCP OFFER数据包中分配的IP地址;
设置单元,用于根据用户对所述选择列表中一第一IP地址的选择指令,将所述第一IP地址所处的网段作为所述预设网段。
可选的,上述的DHCP客户机,还包括:第一请求单元,用于于所述设置单元将所述第一IP地址所处的网段作为所述预设网段后,重新广播IP地址请求。
可选的,上述的DHCP客户机,还包括:第二请求单元,用于于所述设置单元将所述第一IP地址所处的网段作为所述预设网段后,向分配所述第一IP地址的DHCP服务器发送IP地址请求。
可选的,上述的DHCP客户机,还包括:释放单元,用于于所述第一请求单元重新广播IP地址请求前,或所述第二请求单元向分配所述第一IP地址的DHCP服务器发送IP地址请求前,释放当前使用的IP地址资源。
可选的,上述的DHCP客户机,还包括:接收单元,用于在所述DHCP客户机首次进行IP地址请求前预先接收所述预设网段的设置。
与现有技术相比,本发明的技术方案具有以下优点:
本发明中,DHCP客户机通过将DHCP服务器分配的IP地址与预设网段进行匹配,以选择是否接受该IP地址租约,从而可以实现对用户想要接入的网段的自动匹配和接入,避免了始终不能接入需求网段的问题,以及后续需要手动释放并重新请求IP资源的繁琐操作。
进一步地,通过生成一包括所有DHCP OFFER数据包中被分配IP地址的选择列表,进而根据用户对IP地址的自主选择,可以实现用户在使用过程中对想要接入网段的需要做灵活调整和自动匹配接入。
进一步地,在DHCP客户机首次请求IP地址分配前预先接收用户设置的预设网段,可以在DHCP客户机接入网络之后快速接入想要接入的网段。
进一步地,通过在请求DHCP服务器进行新的IP地址分配前,释放当前使用的IP地址,减少了DHCP服务器地址池中IP资源浪费。
附图说明
图1是本发明实施例中一种多DHCP服务器环境下的IP地址管理方法的流程图;
图2是本发明实施例中另一种多DHCP服务器环境下的IP地址管理方法的流程图;
图3是本发明实施例中一种多DHCP服务器环境下的IP地址管理装置的结构示意图;
图4是本发明实施例中另一种多DHCP服务器环境下的IP地址管理装置的结构示意图。
具体实施方式
目前,在复杂的多DHCP服务器的网络中,如果获取了不想要的IP网段,通常需要先用命令(如输入“ipconfig/release”命令)释放该IP地址,然后再用命令(如输入“ipconfig/renew”命令)重新向DHCP服务器发出新的IP地址请求。但这依然会有一定的概率获得不希望获得的IP地址。如果请求网络管理员找到不希望进行地址分配的DHCP服务器,并把这些服务器都down掉,虽然可以获取想要的IP地址,但这将是很繁琐的操作,而且在很多情况下是不能实现的,比如联系不到网络管理员。更重要的是可能还会导致同网络中其他用户不能获取想要的IP地址,影响其正常使用。
可见在现有技术中,还没有一种可以适用于多DHCP网络环境下,对用户需要的网段进行有效匹配的网络机制。
本发明实施例中,DHCP客户机通过将DHCP服务器分配的IP地址与预设网段进行匹配,以选择是否接受该IP地址租约,从而可以实现对用户想要接入的网段的自动匹配和接入,避免了始终不能接入需求网段的问题,以及后续需要手动释放并重新请求IP资源的繁琐操作。
为使本发明的上述目的、特征和优点能够更为明显易懂,下面结合附图对本发明的具体实施例做详细的说明。
本发明实施例提供了一种多DHCP服务器网络环境下的IP地址管理方法,可以适用于IP网络环境中,任何具有数据传输能力和数据处理能力,并接受DHCP服务器份额IP地址的网络接入端设备。例如,可以是路由器,可以是装有无线网卡的计算机,也可以是具有WiFi模块的智能手机等。下文将以DHCP客户机代称上述的网络接入端设备。
本发明实施例的一种多DHCP服务器环境下的IP地址管理方法,如图1所示,可以包括如下步骤:
步骤S101,根据所述DHCP服务器反馈的DHCP OFFER数据包,生成一选择列表。
当DHCP客户机第一次登陆网络时,会通过UDP端口广播发出一个DHCP DISCOVER数据包,请求DHCP服务器为自己分配相应的IP地址。当DHCP服务器监听到所述DHCP DISCOVER广播后,它会从自己所管理的地址池中选择最前面的空置IP,反馈给客户机一个DHCP OFFER数据包。其中包括了IP地址、子网掩码、地址租期等信息。
在多DHCP服务器的网络环境下,DHCP客户机会收到多个DHCP DISCOVER数据包的反馈。在现有技术中,DHCP客户机会保留第一个接收到的DHCP OFFER数据包,丢弃(DROP)后续接收到的DHCP OFFER数据包,并向网络发送一个DHCP REQUEST的广播数据包,告知所有DHCP服务器它将接受哪一台服务器提供的IP地址,这样,当其他DHCP服务器收到该广播时,会撤销它们的提供以便将IP地址提供给下一次IP地址请求。
与上述现有技术不同的是,本发明实施例在收到多个DHCP DISCOVER数据包后,虽然也会默认接受第一个DHCP OFFER数据包,并发送DHCP REQUEST广播数据包,但不会丢弃后续接收到的DHCP OFFER数据包,而是解析所有接收到的DHCP OFFER数据包,并读取其中的信息,并将其中的被分配IP地址写入内核的一张一维数组内,生成所述选择列表,所述选择列表包括所有DHCP服务器在DHCP OFFER数据包中分配的IP地址。
可以理解的是,由于本发明实施例可以是应用于DHCP客户机已经接受了第一个DHCP OFFER数据包中IP租约后,对后续接收到的所有DHCP OFFER数据包的处理,因此所述选择列表也可以不包括第一个接收到的DHCP OFFER数据包中的IP地址,即当前正在使用的IP地址。
在具体实施中,如果所述DHCP客户机的用户接口是图形化界面,那么所述选择列表中的数据可以通过页面的形式显示。如果所述DHCP客户机的用户接口是命令行界面,那么可以由用户通过输入命令语句于所述DHCP客户机的显示界面上显示所述选择列表中的IP地址信息。
步骤S102,根据用户对所述选择列表中一第一IP地址的选择指令,将所述第一IP地址所处的网段作为预设网段。
在具体实施中,根据所述DHCP客户机用户接口的不同,用户对第一IP地址的选择指令可以是页面选择指令,也可以是命令行命令。
步骤S103,进行IP地址请求。
在具体实施中,所述进行IP地址请求可以是重新广播IP地址请求。此时广播IP地址请求与步骤S101之前DHCP客户机首次登录网络时发送的DHCP DISCOVER数据包格式可以是相同的,即封装数据包的源地址为0.0.0.0,目标地址为255.255.255.255,再加上DHCP DISCOVER的其他相关信息。
在具体实施中,所述进行IP地址请求也可以是向分配所述第一IP地址的DHCP服务器发送IP地址请求。此时就不再采用广播的请求方式,发送给该DHCP服务器数据包的格式中,目标地址为该DHCP服务器的IP地址,而源地址可以是是DHCP客户机当前的IP地址,也可以是0.0.0.0。
为了减少DHCP服务器地址池中IP资源浪费,在具体实施中,DHCP客户机可以在请求DHCP服务器进行新的IP地址分配前,释放当前使用的IP地址。
在具体实施中,为了避免在DHCP服务器都出现问题,如崩溃,而不能进行地址分配时,程序占用过多的CPU和内存资源,可以通过类似定时器等部件设置预设时间,并在进行广播IP地址请求后,判断是否在上述的有效预设时间内收到DHCP OFFER数据包,可以反映DHCP服务器是否处于正常工作状态。
在上述的具体实施中,鉴于DHCP服务器正常状态下对DHCP客户机请求IP地址的响应通常在0.2s左右,因此如果DHCP客户机的等待时间超过了预定时间(如自定义为5s),还没有接收到DHCP服务器回复的DHCP OFFER,那么就判定DHCP服务器不会提供IP地址了。这时DHCP客户机输出DHCP请求失败并结束所述广播IP地址请求等相应进程以节省系统资源。
步骤S104~步骤S105,解析接收到的DHCP OFFER数据包,并将所述DHCP OFFER数据包中的被分配IP地址与所述预设网段进行匹配。
本实施例之所以选择与所述第一IP地址处于同一网段的IP地址,而不是选择与所述第一IP地址相同的IP地址,是因为在获取第一个IP和更换IP的时间段内,DHCP服务器可能已经将该第一IP地址分配给其它DHCP客户端了,因此无法再分配该第一IP地址。
在具体实施中,可以设置钩子函数以截取接收到的数据包,判断如果收到的数据包是DHCP数据包,则该DHCP数据包带回来的IP地址是否是想要的IP地址,即是否与所述第一IP地址处于同一网段。如果是,ACCEPT该数据包,接受所述DHCP OFFER数据包中的IP地址租约,否则丢弃该数据包。
例如,当前使用的IP地址为192.168.1.56/24,用户于所述选择列表中选择 了10.6.61.89/24的IP地址。此时,如果先后接收到了分别包括192.168.1.46/24、172.16.2.8/24以及10.6.61.96/24三个被分配IP地址的DHCP OFFER数据包,则通过比较IP地址二进制数的前24位网络位,即可判断出192.168.1.46/24、172.16.2.8/24的网络位与10.6.61.89/24的网络位均不同,但10.6.61.96/24的网络位与10.6.61.89/24的网络位相同,即两者属于同一网段,因此丢弃前两个DHCP OFFER数据包,接受第三个DHCP OFFER数据包中的IP地址租约。
综上,通过本发明实施例的一种多DHCP服务器网络环境下的IP地址管理方法,可以通过生成一包括所有DHCP OFFER数据包中被分配IP地址的选择列表,进而根据用户对IP地址的自主选择,可以方便快捷地实现用户在使用过程中对想要接入网段的需要做灵活调整和自动匹配接入,从而提高了用户的使用体验。
本发明实施例还公开了另一种多DHCP服务器环境下的IP地址管理方法。与前一实施例相同的是,本发明实施例同样适用于接受所述DHCP服务器IP地址分配的DHCP客户机,由所述DHCP客户机执行所述IP地址管理方法。
如图2所示,所述多DHCP服务器环境下的IP地址管理方法可以包括如下步骤:
步骤S201~步骤S202,解析接收到的DHCP OFFER数据包,并将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配。
与前一实施例不同的是,本实施例中的所述预设网段是在所述DHCP首次联网之前由用户设置并存储在所述DHCP客户机上,而不是如前一实施例在所述DHCP客户机接收到DHCP OFEER之后,由用户选择指定。
步骤S203,当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
在具体实施中,如果DHCP客户机接收到的所有DHCP OFFER中的被分配IP地址均不在所述预设网段中,则采用类似于现有技术的方法,接收最先接收到的DHCP OFFER数据包提供的IP地址租约。
在上述的具体实施中,还可以通过定时器设置相应的预设时间,如果超出该预设时间,则判定不会再接收到新的DHCP OFFER数据包,此时如果还没有收到落入预设网段内的IP地址,则接受第一个接收到的DHCP OFFER数据包中的IP地址租约。
可以理解的是,本实施例与前一实施例所要解决的技术问题相同,即都是要避免迟迟不能接入用户想要接入的网络的情况,以及现有技术中繁琐的后续操作。同时,就技术方案本身来说,两者都是通过将被分配IP与用户事前预先设置的网段,或在使用过程中指定的网段进行匹配,因此两者属于同一技术思想。
本实施例可以和前一实施例组合使用,即在所述步骤S203后执行步骤S101~步骤S105。
综上,本发明实施例的一种多DHCP服务器环境下的IP地址管理方法,通过预先设置想要接入的网段,在接收DHCP服务器发送的DHCP OFFER数据包之初时,就对IP地址进行过滤选择,从而无需用户在使用过程中再重新指定相应的网段,进一步便捷了用户的使用。当然,如果用户在使用过程中需要重新选择接入新的网段,也可以通过如前一实施例的方法方便地进行重新选择和接入。
本发明实施例还提供了一种与第一个实施例中的多DHCP服务器网络环境下的IP地址管理方法相对应的DHCP客户机。如图3所示,所述DHCP客户机30可以包括:
解析单元301,用于解析接收到的DHCP OFFER数据包;
匹配单元302,用于将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配;
处理单元303,用于当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
在具体实施中,所述DHCP客户机30还可以包括:
生成单元304,用于根据所述DHCP服务器反馈的DHCP OFFER数据包,生成一选择列表;所述选择列表包括所有DHCP服务器于DHCP OFFER数据包中分配的IP地址;
设置单元305,用于根据用户对所述选择列表中一第一IP地址的选择指令,将所述第一IP地址所处的网段作为所述预设网段;
请求单元306,用于进行IP地址请求。
在具体实施中,所述请求单元306用于重新广播IP地址请求。
在具体实施中,所述请求单元306用于向分配所述第一IP地址的DHCP服 务器发送IP地址请求。
在具体实施中,所述DHCP客户机30还可以包括:释放单元307,用于于所述请求单元306重新广播IP地址请求前,或向分配所述第一IP地址的DHCP服务器发送IP地址请求前,释放当前使用的IP地址资源。
通过本发明实施例的一种多DHCP服务器环境下的IP地址管理装置30,可以通过生成一包括所有DHCP OFFER数据包中被分配IP地址的选择列表,进而根据用户对IP地址的自主选择,可以方便快捷地实现用户在使用过程中对想要接入网段的需要做灵活调整和自动匹配接入,从而提高了用户的使用体验。
关于本实施例的具体方案,可以参照第一实施例的相应内容,此处不再赘述。
本发明实施例还提供了另一种DHCP客户机,与第二个实施例中的多DHCP服务器环境下的IP地址管理方法相对应。如图4所示,所述DHCP客户机40可以包括:
接收单元401,用于在所述DHCP客户机40首次进行IP地址请求前预先接收所述预设网段的设置;
解析单元402,用于解析接收到的DHCP OFFER数据包;
匹配单元403,用于将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配;
处理单元404,用于当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
在具体实施中,如图4所示,上述的DHCP客户机40,还可包括如上述的DHCP客户机30。
本发明实施例的一种DHCP客户机40,通过预先设置想要接入的网段,在接收DHCP服务器发送的DHCP OFFER数据包之初时,就对IP地址进行过滤选择,从而无需用户在使用过程中再重新指定相应的网段,进一步地便捷了用户的使用。当然,如果用户在使用过程中需要重新选择接入的网段,也可以通过如前一实施例的方法方便地进行重新选择。
关于本实施例的具体方案,可以参照第二实施例的相应内容,此处不再赘述。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤 是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:ROM、RAM、磁盘或光盘等。
虽然本发明披露如上,但本发明并非限定于此。任何本领域技术人员,在不脱离本发明的精神和范围内,均可作各种更动与修改,因此本发明的保护范围应当以权利要求所限定的范围为准。

Claims (12)

  1. 一种多DHCP服务器网络环境下的IP地址管理方法,其特征在于,
    提供一接受所述DHCP服务器IP地址分配的DHCP客户机,所述DHCP客户机执行所述IP地址管理方法,所述IP地址管理方法包括:
    解析接收到的DHCP OFFER数据包,并将所述DHCP OFFER数据包中的被分配IP地址与一预设网段进行匹配;
    当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
  2. 如权利要求1所述的多DHCP服务器网络环境下的IP地址管理方法,其特征在于,还包括:
    根据所述DHCP服务器反馈的DHCP OFFER数据包,生成一选择列表;所述选择列表包括所有DHCP服务器在DHCP OFFER数据包中分配的IP地址;
    根据用户对所述选择列表中一第一IP地址的选择指令,将所述第一IP地址所处的网段作为所述预设网段;
    进行IP地址请求。
  3. 如权利要求2所述的多DHCP服务器网络环境下的IP地址管理方法,其特征在于,所述进行IP地址请求包括:重新广播IP地址请求。
  4. 如权利要求2所述的多DHCP服务器网络环境下的IP地址管理方法,其特征在于,所述进行IP地址请求包括:向分配所述第一IP地址的DHCP服务器发送IP地址请求。
  5. 如权利要求3或4所述的多DHCP服务器网络环境下的IP地址管理方法,其特征在于,还包括:于所述重新广播IP地址请求前,或所述向分配所述第一IP地址的DHCP服务器发送IP地址请求前,释放当前使用的IP地址资源。
  6. 如权利要求1所述的多DHCP服务器网络环境下的IP地址管理方法,其特征在于,在首次进行IP地址请求前预先接收所述预设网段的设置。
  7. 一种DHCP客户机,其特征在于,包括:
    解析单元,用于解析接收到的DHCP OFFER数据包;
    匹配单元,用于将所述DHCP OFFER数据包中的被分配IP地址与一预设网 段进行匹配;
    处理单元,用于当所述被分配的IP地址落入所述预设网段中时,接受所述DHCP OFFER数据包中的IP地址租约。
  8. 如权利要求7所述的DHCP客户机,其特征在于,还包括:
    生成单元,用于根据所述DHCP服务器反馈的DHCP OFFER数据包,生成一选择列表;所述选择列表包括所有DHCP服务器于DHCP OFFER数据包中分配的IP地址;
    设置单元,用于根据用户对所述选择列表中一第一IP地址的选择指令,将所述第一IP地址所处的网段作为所述预设网段;
    请求单元,用于进行IP地址请求。
  9. 如权利要求8所述的DHCP客户机,其特征在于,所述请求单元用于重新广播IP地址请求。
  10. 如权利要求8所述的DHCP客户机,其特征在于,所述请求单元用于向分配所述第一IP地址的DHCP服务器发送IP地址请求。
  11. 如权利要求9或10所述的DHCP客户机,其特征在于,还包括:释放单元,用于于所述请求单元重新广播IP地址请求前,或向分配所述第一IP地址的DHCP服务器发送IP地址请求前,释放当前使用的IP地址资源。
  12. 如权利要求7所述的DHCP客户机,其特征在于,还包括:接收单元,用于在所述DHCP客户机首次进行IP地址请求前预先接收所述预设网段的设置。
PCT/CN2017/077420 2016-05-30 2017-03-21 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机 WO2017206572A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610370652.3A CN105847464B (zh) 2016-05-30 2016-05-30 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机
CN201610370652.3 2016-05-30

Publications (1)

Publication Number Publication Date
WO2017206572A1 true WO2017206572A1 (zh) 2017-12-07

Family

ID=56596184

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/077420 WO2017206572A1 (zh) 2016-05-30 2017-03-21 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机

Country Status (2)

Country Link
CN (1) CN105847464B (zh)
WO (1) WO2017206572A1 (zh)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108471431A (zh) * 2018-07-10 2018-08-31 杭州任你说智能科技有限公司 一种家庭网络流量截获方法及家庭网络流量管理设备
CN112714204A (zh) * 2020-12-22 2021-04-27 赛尔网络有限公司 IPv6地址与网段的匹配方法、装置、电子设备和存储介质
CN113114793A (zh) * 2021-03-22 2021-07-13 珠海格力电器股份有限公司 从机节点地址竞争方法、装置及电器系统
CN114301876A (zh) * 2021-12-23 2022-04-08 深圳创维数字技术有限公司 地址分配方法、系统、设备及计算机可读存储介质

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105847464B (zh) * 2016-05-30 2019-11-29 上海斐讯数据通信技术有限公司 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机
CN106803848B (zh) * 2017-01-17 2020-04-28 深圳市新威尔电子有限公司 电池测试装置中位机管理方法及装置
WO2018196468A1 (zh) 2017-04-27 2018-11-01 华为技术有限公司 一种实现数据业务的方法、装置及终端
CN107276802A (zh) * 2017-06-15 2017-10-20 郑州云海信息技术有限公司 一种存储系统的初始化配置方法、装置及系统
US20200196152A1 (en) * 2017-07-07 2020-06-18 Huawei Technologies Co., Ltd. Method and Apparatus for Restoring Internet Access by Local Area Network Device
EP3562091B1 (en) 2018-04-27 2023-04-19 Hewlett Packard Enterprise Development LP Highly available dhcp service by running dhcp servers on a blockchain network
CN113746653A (zh) * 2020-05-29 2021-12-03 中兴通讯股份有限公司 网关配置方法、客户机、服务器和存储介质
CN114785755B (zh) * 2022-04-19 2024-03-29 深圳市和为顺网络技术有限公司 一种ipv6上网iapd自适应的方法与系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102694821A (zh) * 2012-06-15 2012-09-26 杭州华三通信技术有限公司 一种基于认证信息分配ip地址的方法及装置
CN102801716A (zh) * 2012-08-01 2012-11-28 杭州迪普科技有限公司 一种dhcp防攻击方法及装置
CN103888551A (zh) * 2012-12-19 2014-06-25 华为技术有限公司 一种网络中的因特网协议地址获取方法、中继设备及系统
US8856296B2 (en) * 2012-06-28 2014-10-07 Alcatel Lucent Subnet prioritization for IP address allocation from a DHCP server
CN105847464A (zh) * 2016-05-30 2016-08-10 上海斐讯数据通信技术有限公司 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101478576B (zh) * 2008-01-03 2012-02-15 华为技术有限公司 选择服务网络的方法、装置和系统
CN102209123B (zh) * 2011-05-30 2013-10-30 中国电信股份有限公司 Mac地址管理方法、系统、mac地址服务器及客户机
CN102882861B (zh) * 2012-09-19 2015-11-25 烽火通信科技股份有限公司 基于解析dhcp报文实现防ip地址欺诈的方法

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102694821A (zh) * 2012-06-15 2012-09-26 杭州华三通信技术有限公司 一种基于认证信息分配ip地址的方法及装置
US8856296B2 (en) * 2012-06-28 2014-10-07 Alcatel Lucent Subnet prioritization for IP address allocation from a DHCP server
CN102801716A (zh) * 2012-08-01 2012-11-28 杭州迪普科技有限公司 一种dhcp防攻击方法及装置
CN103888551A (zh) * 2012-12-19 2014-06-25 华为技术有限公司 一种网络中的因特网协议地址获取方法、中继设备及系统
CN105847464A (zh) * 2016-05-30 2016-08-10 上海斐讯数据通信技术有限公司 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108471431A (zh) * 2018-07-10 2018-08-31 杭州任你说智能科技有限公司 一种家庭网络流量截获方法及家庭网络流量管理设备
CN112714204A (zh) * 2020-12-22 2021-04-27 赛尔网络有限公司 IPv6地址与网段的匹配方法、装置、电子设备和存储介质
CN112714204B (zh) * 2020-12-22 2022-09-20 赛尔网络有限公司 IPv6地址与网段的匹配方法、装置、电子设备和存储介质
CN113114793A (zh) * 2021-03-22 2021-07-13 珠海格力电器股份有限公司 从机节点地址竞争方法、装置及电器系统
CN114301876A (zh) * 2021-12-23 2022-04-08 深圳创维数字技术有限公司 地址分配方法、系统、设备及计算机可读存储介质
CN114301876B (zh) * 2021-12-23 2023-11-21 深圳创维数字技术有限公司 地址分配方法、系统、设备及计算机可读存储介质

Also Published As

Publication number Publication date
CN105847464A (zh) 2016-08-10
CN105847464B (zh) 2019-11-29

Similar Documents

Publication Publication Date Title
WO2017206572A1 (zh) 一种多dhcp服务器网络环境下的ip地址管理方法和dhcp客户机
KR102436981B1 (ko) 무선 액세스 네트워크 정보 처리 방법 및 장치, 네트워크 요소 및 저장 매체
US20200366642A1 (en) Address Management Method and System, and Device
EP3742785B1 (en) Session management method and device
US9210124B2 (en) Method, apparatus, and system for allocating public IP address
KR100657316B1 (ko) DHCPv4 환경하에서의 핸드오버 방법, 핸드오버 장치및 상기 핸드오버 방법이 저장된 정보저장매체
CN110677405B (zh) 一种数据处理方法、装置、电子设备及存储介质
US9124438B2 (en) Network communication apparatus, network communication method, and program
WO2022237280A1 (zh) Dns服务器的发现方法、装置、计算机设备、计算机可读存储介质及计算机程序产品
EP3606005A1 (en) Redirection method, control plane network element, aggregation user plane network element, content server and terminal device
CN113612861B (zh) 远程访问方法、系统及计算机可读存储介质
KR102329095B1 (ko) 네트워크 접속 방법, 관련 기기 및 시스템
JP2017022693A (ja) インターネットワークアドレスを割り当てる装置および方法
US20220263879A1 (en) Multicast session establishment method and network device
CN109714376B (zh) 一种固网报文的发送方法、装置及系统
CN114364031A (zh) 服务提供方法、装置及存储介质
CN114866854B (zh) 视频接入方式动态分配方法、系统、电子设备和存储介质
WO2017215381A1 (zh) 虚拟扩展端口的指示方法和装置、存储介质
EP3579502A1 (en) Outer multicast ip address allocation method and device
WO2021190029A1 (zh) 实现运营商级网络地址转换的方法、装置和系统
CN112511440B (zh) 报文转发方法、系统、存储介质和电子设备
KR101681941B1 (ko) 이기종 네트워크 기반 데이터 동시 전송 서비스 방법
KR101823040B1 (ko) 이기종 네트워크 기반 데이터 동시 전송 서비스 방법
JP2017517931A (ja) 情報伝送方法、装置、及びシステム
JP6568002B2 (ja) 通信システム、及び通信方法

Legal Events

Date Code Title Description
NENP Non-entry into the national phase

Ref country code: DE

121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 17805517

Country of ref document: EP

Kind code of ref document: A1

122 Ep: pct application non-entry in european phase

Ref document number: 17805517

Country of ref document: EP

Kind code of ref document: A1