IP address determination method and device, equipment and storage medium
By introducing Option 60 and Option 125 fields into DHCP messages, the problem that the router cannot distinguish the source when receiving multiple DHCP Offer messages is solved, ensuring that the target router selects the correct IP address and avoids network connection abnormalities.
Patent Information
- Application Number
- CN202510467868.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-07-04
AI Technical Summary
In the prior art, when a router that supports WAN adaptation receives multiple DHCP Offer messages, the DHCP protocol cannot distinguish the source of the message, and may choose the wrong IP address provided by the non-gateway as the management IP, resulting in abnormal WAN port configuration or network connection.
By introducing Option 60 and Option 125 fields into the DHCP message, it is used to identify the router and gateway identification respectively, to ensure that the target router can identify and select the correct IP address provided by the gateway, and avoid incorrect selection.
It effectively solves the problem of accurately selecting the IP address provided by the gateway when the router receives multiple DHCP Offer messages, so as to avoid the WAN port configuration and network connection abnormalities.
Smart Images

Figure CN120263772A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of network configuration, and particularly relates to an IP address determination method, an IP address determination device, an electronic device, and a machine-readable storage medium. Background Art
[0002] A typical scenario of home networking is as shown in the appendix. Figure 2 Among them, the gateway operates in routing mode, and the router operates in bridging mode. For a router that supports WAN self-adaptation (hereinafter simply referred to as the target router), after it completes the power-on initialization operation and before obtaining the management IP address, it will start the DHCP service and probe the WAN port by broadcasting DHCP Discover messages to obtain the management IP address. After receiving the DHCP Discover message sent by the target router, the gateway will immediately reply with a DHCP Offer message to provide the target router with the management IP address it needs. However, in the same network environment, since other routers that also operate in bridging mode have also started the DHCP service, after receiving the DHCP Discover message sent by the target router, they will also reply with a DHCP Offer message and provide the management IP address.
[0003] Since the DHCP protocol cannot distinguish the source of the message, that is, the target router itself cannot identify which DHCP Offer message is sent by the gateway, the target router is very likely to incorrectly select the IP address provided by other routers as its own management IP, resulting in abnormal network connection. In addition, other access devices (such as computers) in the home network may sometimes accidentally start the DHCP service, and the DHCP Offer messages sent by these devices will also interfere with the target router's acquisition of the correct management IP address, further increasing the risk of network configuration errors. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide an IP address determination method, an IP address determination device, a device, and a storage medium to solve the problem that when a router that supports WAN self-adaptation receives multiple DHCP Offer messages at the same time in the prior art, due to the DHCP protocol itself being unable to distinguish the source of the message, the router may select an incorrect IP address provided by a non-gateway as the management IP, ultimately resulting in abnormal configuration of its WAN port or abnormal network connection.
[0005] To achieve the above purpose, the first aspect of this application provides an IP address determination method, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. The method is executed by a target router in the routers, and the method includes:
[0006] Start the DHCP service and broadcast the first DHCP Discover message; wherein, the field value of the first DHCP field in the first DHCP Discover message is an identifier characterizing the target router.
[0007] Obtain the first DHCP Offer message in response to the first DHCP Discover message from other devices in the home network system.
[0008] Determine the first DHCP Offer message that contains a second DHCP field and the field value of the second DHCP field is an identifier characterizing the gateway as the target message, and determine the IP address in the target message as the management IP address of the target router.
[0009] In an embodiment of the present application, the method further includes:
[0010] When the DHCP service status is the start status, based on obtaining the second DHCP Discover message sent by other devices in the home network system, determine whether the second DHCP Discover message comes from other routers in the home network system; if so, do not respond to the second DHCP Discover message.
[0011] In an embodiment of the present application, the method further includes:
[0012] When the DHCP service status is the start status, if it is determined that the second DHCP Discover message does not come from other routers in the home network system, then in response to the second DHCP Discover message, reply to the device that sent the second DHCP Discover message with a second DHCP Offer message.
[0013] Wherein, the second DHCP Offer message contains a second DHCP field and the field value of the second DHCP field is an identifier characterizing the target router.
[0014] In an embodiment of the present application, after determining the IP address in the target message as the management IP address of the target router, the method further includes: shutting down the DHCP service.
[0015] A second aspect of the present application provides an IP address determination method, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. The method is executed by the gateway, and the method includes:
[0016] Obtain DHCP Discover packets sent by other devices in the home network system;
[0017] If it is determined that the DHCP Discover packet contains a first DHCP field and the field value of the first DHCP field is an identifier representing the target router, in response to the DHCP Discover packet, send a first DHCP Offer packet to the target router, so that the target router determines the IP address in the first DHCP Offer packet as its management IP address;
[0018] Wherein, the first DHCP Offer packet contains a second DHCP field and the field value of the second DHCP field is an identifier representing the gateway.
[0019] In an embodiment of the present application, the method further includes:
[0020] If it is determined that the DHCP Discover packet does not contain the first DHCP field or the field value of the included first DHCP field is not an identifier representing the target router, in response to the DHCP Discover packet, send a third DHCP Offer packet to the device that sent the DHCP Discover packet;
[0021] Wherein, the third DHCP Offer packet does not contain the second DHCP field.
[0022] A third aspect of the present application provides an IP address determination device, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. The device is configured in a target router among the routers. The device includes:
[0023] A packet sending module, configured to start a DHCP service and broadcast and send a first DHCP Discover packet; wherein, the field value of the first DHCP field in the first DHCP Discover packet is an identifier representing the target router;
[0024] A first packet obtaining module, configured to obtain a first DHCP Offer packet in response to the first DHCP Discover packet by other devices in the home network system;
[0025] An IP address determination module, configured to determine a first DHCP Offer packet that contains a second DHCP field and the field value of the second DHCP field is an identifier representing the gateway as a target packet, and determine the IP address in the target packet as the management IP address of the target router.
[0026] A fourth aspect of the present application provides an IP address determination device, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. The device is configured in the gateway, and the device includes:
[0027] A second message acquisition module, configured to acquire DHCP Discover messages sent by other devices in the home network system;
[0028] A message response module, configured to, if it is determined that the DHCP Discover message includes a first DHCP field and the field value of the first DHCP field is an identifier representing a target router, in response to the DHCP Discover message, reply a first DHCP Offer message to the target router, so that the target router determines the IP address in the first DHCP Offer message as its management IP address;
[0029] Wherein, the first DHCP Offer message includes a second DHCP field and the field value of the second DHCP field is an identifier representing the gateway.
[0030] A fifth aspect of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the IP address determination method described in the first aspect or the IP address determination method described in the second aspect.
[0031] A sixth aspect of the present application provides a machine-readable storage medium, on which instructions are stored. When the instructions are executed by a processor, the processor is configured to execute the IP address determination method described in the first aspect or the IP address determination method described in the second aspect.
[0032] The IP address determination method, device, equipment, and storage medium provided by the present application utilize the fields in the DHCP message to perform an extended design on the DHCP address allocation mechanism, enabling the gateway and the router to perform specific processing on the specific DHCP fields in the message, ensuring that the router can accurately determine the IP address in the message replied by the gateway as its own management IP address, and avoiding the problems of abnormal WAN port configuration or abnormal network connection.
[0033] Other features and advantages of the embodiments of the present application will be described in detail in the subsequent specific implementation part. Description of the Drawings
[0034] The accompanying drawings are used to provide a further understanding of the embodiments of the present application and form a part of the specification. Together with the following specific implementation manners, they are used to explain the embodiments of the present application, but do not constitute a limitation to the embodiments of the present application. In the accompanying drawings:
[0035] Figure 1 Schematically shows a first flowchart of the IP address determination method according to an embodiment of the present application;
[0036] Figure 2 Schematically shows a connection diagram of an existing home network;
[0037] Figure 3 Schematically shows a data structure diagram of the Option 60 field in an embodiment of the present application;
[0038] Figure 4 Schematically shows a data structure diagram of the Option 125 field in an embodiment of the present application;
[0039] Figure 5 Schematically shows a flowchart of implementing the determination of the management IP address in an application example according to an embodiment of the present application;
[0040] Figure 6 Schematically shows a second flowchart of the IP address determination method according to an embodiment of the present application;
[0041] Figure 7 Schematically shows a first structural block diagram of an IP address determination device according to an embodiment of the present application;
[0042] Figure 8 Schematically shows a second structural block diagram of an IP address determination device according to an embodiment of the present application;
[0043] Figure 9 Schematically shows an internal structure diagram of a computer device according to an embodiment of the present application.
[0044] Description of the reference numerals
[0045] A01 - Processor; A02 - Network interface; A03 - Internal memory; A04 - Display screen; A05 - Input device; A06 - Non-volatile storage medium; B01 - Operating system; B02 - Computer program. Specific implementation manners
[0046] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the following will clearly and completely describe the technical solutions in the embodiments of this application with reference to the accompanying drawings in the embodiments of this application. It should be understood that the specific embodiments described herein are only used to illustrate and explain the embodiments of this application, and are not used to limit the embodiments of this application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in this application without creative efforts belong to the scope protected by this application.
[0047] It should be noted that if there are directional indications (such as up, down, left, right, front, back, etc.) involved in the embodiments of this application, then such directional indications are only used to explain the relative positional relationship and movement conditions between components in a specific posture (as shown in the accompanying drawings). If this specific posture changes, then the directional indications will also change accordingly.
[0048] In addition, if there are descriptions involving "first", "second", etc. in the embodiments of this application, then such descriptions of "first", "second", etc. are only for descriptive purposes, and cannot be understood as indicating or implying their relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one such feature. In addition, the technical solutions between various embodiments can be combined with each other, but it must be based on the fact that those of ordinary skill in the art can implement them. When the combination of technical solutions results in contradictions or cannot be implemented, it should be considered that such a combination of technical solutions does not exist and is not within the scope of protection required by this application.
[0049] In view of the problem that when a router supporting WAN self - adaptation in the related art receives multiple DHCP Offer messages simultaneously, since the DHCP protocol itself cannot distinguish the source of the messages, the router may select an incorrect IP address provided by a non - gateway as the management IP, ultimately resulting in abnormal WAN port configuration or abnormal network connection, this application provides an IP address determination method, device, equipment, and storage medium. The following will, with reference to the accompanying drawings, detail the IP address determination method, device, equipment, and storage medium provided by this application through specific embodiments and implementation manners.
[0050] Figure 1 Schematically shows a first flowchart of the IP address determination method according to the embodiments of this application. As Figure 1 shown, in an embodiment of this application, an IP address determination method is provided, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. Among them, the gateway operates in a routing mode and by default starts a DHCP service; the router operates in a bridging mode.
[0051] In an embodiment of the present application, the method is executed by a target router in a router, and the method may include the following steps.
[0052] Step A100: Start the DHCP service and broadcast a first DHCP Discover message.
[0053] It should be understood that in an embodiment of the present application, any router in the router that meets the preset conditions can be used as the target router. Among them, the preset conditions are: the power-on initialization operation has been completed and the management IP address has not been obtained yet. In addition, it is worth mentioning that the target router has a WAN self-adaptive function and can receive and obtain the management IP address through the WAN port.
[0054] Among them, after the target router starts the DHCP service, the target router has the ability of dual roles. Specifically, the LAN port acts as a DHCP server to assign network parameters such as IP addresses and subnet masks to home networking devices (such as mobile phones and computers); the WAN port acts as a DHCP client to obtain the configuration information (such as the management IP address) it needs from the upper-level gateway (such as an optical modem).
[0055] Among them, the field value of the first DHCP field in the first DHCP Discover message is an identifier representing the target router. It should be noted that in an embodiment of the present application, the field value of the first DHCP field in the first DHCP Discover message is specifically the unique identifier representing the target router.
[0056] In a specific embodiment, the first DHCP field is a field included in the Option 60 field. The data structure of the Option 60 field is as Figure 3 shown, and the field names and their related information included in the Option 60 field are shown in Table 1 below.
[0057] Table 1 - Field Names and Their Related Information Included in the Option 60 Field
[0058]
[0059]
[0060] In this specific embodiment, the first DHCP field is specifically of the Option 60 field type (i.e., Type). When the field value of the first DHCP field is 1, it indicates that the message where it is located comes from a router; when the field value of the first DHCP field is 2, it indicates that the message where it is located comes from a gateway. It can be understood that in this specific embodiment, for the field value of the first DHCP field, the numerical value 1 is the identifier representing the target router, and the numerical value 2 is the identifier representing the gateway.
[0061] It should be understood that after starting the DHCP service in step A100, by making the field value of the first DHCP field in the sent first DHCP Discover message be the identifier characterizing the target router, it is convenient for other devices in the home network system to perform corresponding processing based on the field value of the first DHCP field after obtaining the first DHCP Discover message.
[0062] Step A200: Obtain the first DHCP Offer message in response to the first DHCP Discover message from other devices in the home network system.
[0063] Specifically, for each device other than the target router in the home network system (such as a gateway, router, computer), if the device has started the DHCP service, then when the device obtains the first DHCP Discover message, it will respond to the first DHCP Discover message and reply with a first DHCP Offer message.
[0064] Step A300: Determine the first DHCP Offer message that contains a second DHCP field and the field value of the second DHCP field is the identifier characterizing the gateway as the target message, and determine the IP address in the target message as the management IP address of the target router.
[0065] It should be understood that in the embodiments of the present application, for each device other than the target router in the home network system, the first DHCP Offer message in response to the first DHCP Discover message may or may not contain a second DHCP field.
[0066] When the replied first DHCP Offer message contains a second DHCP field and the field value of the second DHCP field is the identifier characterizing the gateway, it indicates that the first DHCP Offer message comes from the gateway. At this time, determining the IP address in the first DHCP Offer message as the management IP address of the target router can ensure that the target router can correctly select the IP address as its own management IP address.
[0067] In a specific embodiment, the second DHCP field is the field included in the Option 125 field. The data structure of the Option 125 field is as Figure 4 shown, and the field names and their related information included in the Option 125 field are shown in Table 2 below.
[0068] Table 2 - Field names and their related information included in the Option 125 field
[0069] Field Name Length (bit) Content Code 8 125 Length 8 Message Length Enterprise Number low 16 Enterprise Identification Code Enterprise Number high 16 Reserved Type 8 Device Type; 1 represents router, 2 represents gateway Reserved 8 Reserved
[0070] In this specific embodiment, the second DHCP field is specifically of the Option 125 field type (i.e., Type). When the field value of the second DHCP field is 1, it indicates that the message where it is located comes from the router. When the field value of the second DHCP field is 2, it indicates that the message where it is located comes from the gateway. It can be understood that in this specific embodiment, for the field value of the second DHCP field, the numerical value 1 is the identifier representing the target router, and the numerical value 2 is the identifier representing the gateway.
[0071] It should be understood that after the target router selects to determine the IP address in the target message sent by the gateway as its own management IP address, it will send a DHCP Request message to the gateway to confirm the acceptance of the management IP address provided by the gateway. After receiving the DHCP Request message, the gateway will send a DHCP ACK message to the target router to officially lease information such as the management IP address to the target router, thereby completing the IP address allocation process.
[0072] Optionally, in the embodiments of the present application, the method may further include the following steps.
[0073] Step A400, when the DHCP service status is in the startup state, based on the second DHCP Discover message obtained from other devices in the home network system, determine whether the second DHCP Discover message comes from other routers in the home network system; if so, do not respond to the second DHCP Discover message.
[0074] In a specific embodiment, the specific method for the target router to determine whether the second DHCP Discover message comes from other routers in the home network system is: determine whether the second DHCP Discover message contains the first DHCP field and the field value of the first DHCP field is the identifier representing the target router; if so, determine that the second DHCP Discover message comes from other routers in the home network system, and if not, determine that the second DHCP Discover message does not come from other routers in the home network system.
[0075] It should be understood that when the target server determines that the second DHCP Discover message is from other routers in the home network system, by not responding to the second DHCP Discover message, the probability that the router sending the second DHCP Discover message incorrectly selects the management IP address can be reduced.
[0076] Optionally, in the embodiment of the present application, when the DHCP service status is the start state, step A400 may further include: if it is determined that the second DHCP Discover message is not from other routers in the home network system, then in response to the second DHCP Discover message, a second DHCP Offer message is sent back to the device that sent the second DHCP Discover message.
[0077] That is to say, step A400 specifically includes:
[0078] When the DHCP service status is the start state, based on obtaining the second DHCP Discover message sent by other devices in the home network system, it is determined whether the second DHCP Discover message is from other routers in the home network system; if so, the second DHCP Discover message is not responded to; if not, in response to the second DHCP Discover message, a second DHCP Offer message is sent back to the device that sent the second DHCP Discover message.
[0079] Wherein, the second DHCP Offer message includes a second DHCP field and the field value of the second DHCP field is an identifier characterizing the target router.
[0080] It should be understood that when the target server determines that the second DHCP Discover message is not from other routers in the home network system, by making the field value of the second DHCP field in the replied second DHCP Offer message be an identifier characterizing the target router, the legal service identity of itself can be declared to the device that sent the second DHCP Discover message, so that the device can perform corresponding processing according to the received second DHCP Offer message to ensure the normal operation of the device.
[0081] Optionally, in the embodiment of the present application, after step A400, the method may further include the following steps.
[0082] Step A500, turn off the DHCP service.
[0083] It should be understood that when the target router operates in the bridging mode, by turning off its DHCP service so that it only forwards data without allocating IP addresses, the probability that other routers in the home network system incorrectly select the management IP address can be reduced.
[0084] The following uses a specific application example to explain the IP address determination method provided by the embodiments of the present application.
[0085] As Figure 5 shown, a certain home network system includes four devices: a gateway, a computer, Router 1, and Router 2. Among them, the gateway operates in the routing mode, Router 1 and Router 2 both operate in the bridging mode, and the DHCP service status of Router 2 and the computer is in the started state.
[0086] After Router 1 (the target router) is powered on and initialized, and before obtaining the WAN port management IP (that is, before determining its own management IP address), it starts the DHCP service and broadcasts a DHCP Discover message. In this message, the Option 60 field type is an ASCII string representing Router 1 (that is, the Option 60 field type is a router). When Router 1 receives a DHCP Offer message, if it determines that the message contains an Option 125 field and the Option 125 field type is a gateway (that is, the Option 125 field type is an ASCII string representing the gateway), it accepts the management IP address in the message (that is, determines the IP address in the message as its own management IP address), and sets the receiving port to the WAN port; if it determines that the message does not contain an Option 125 field, or the Option 125 field type is not a gateway, it does not accept the management IP address in the message.
[0087] Before Router 1 obtains the WAN port management IP, if it receives a DHCP Discover message, it determines whether the message contains an Option 60 field and the Option 60 field type is a router. If so, it does not process the message. If not (that is, the message does not contain an Option 60 field, or the Option 60 field type is not a router), it replies with a DHCP Offer message, and the Option 125 field type of this message is a router.
[0088] After Router 1 obtains the WAN port management IP, it turns off its own DHCP service.
[0089] In this home network system, when the computer receives the DHCP Discover message sent by Router 1, it replies with a DHCP Offer message, and the type of the Option 125 field in this message is empty. It should be noted that in the case of no network security attack, the computer DHCP service will not construct an Option 125 field with the type of router or gateway.
[0090] It can be seen from this example that in the DHCP protocol framework, by defining a new field Type (device type) for the DHCP Option 60 and DHCP Option 125 field structures, Router 1 performs corresponding processing according to specific DHCP fields in the received message, ensuring that Router 1 can accurately determine the IP address in the message replied by the gateway as its own managed IP address, and avoiding problems such as abnormal WAN port configuration or network connection abnormality.
[0091] It can be seen that the IP address determination method provided by the embodiment of the present application uses the fields in the DHCP message to expand the design of the DHCP address allocation mechanism, enabling the gateway and the router to perform specific processing on specific DHCP fields in the message, effectively solving the problem that when an existing router supporting WAN self - adaptation receives multiple DHCP Offer messages, since the DHCP protocol itself cannot distinguish the source of the messages, the router may select an incorrect IP address provided by a non - gateway as the management IP, ultimately resulting in abnormal WAN port configuration or network connection abnormality.
[0092] Figure 1 It is a schematic diagram of the first process of the IP address determination method in an embodiment. It should be understood that although Figure 1 the steps in the flowchart are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, Figure 1 at least a part of the steps in
[0093] Figure 6 can include multiple sub - steps or multiple stages. These sub - steps or stages are not necessarily executed at the same moment, but can be executed at different moments, and the execution order of these sub - steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or sub - steps or stages of other steps. Figure 6As shown, in an embodiment of the present application, an IP address determination method is provided, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. Among them, the gateway operates in routing mode and the DHCP service is started by default; the router operates in bridging mode, and the router has a WAN self-adaptive function.
[0094] In the embodiment of the present application, the method is executed by the gateway, and the method may include the following steps.
[0095] Step B100: Obtain DHCP Discover packets sent by other devices in the home network system.
[0096] Step B200: If it is determined that the DHCP Discover packet contains a first DHCP field and the field value of the first DHCP field is an identifier representing the target router, then in response to the DHCP Discover packet, send a first DHCP Offer packet to the target router, so that the target router determines the IP address in the first DHCP Offer packet as its management IP address.
[0097] Among them, the first DHCP Offer packet contains a second DHCP field and the field value of the second DHCP field is an identifier representing the gateway.
[0098] It should be understood that by making the field value of the second DHCP field in the replied first DHCP Offer packet be an identifier representing the gateway, the target router can accurately determine the IP address in the first DHCP Offer packet replied by the gateway as its own management IP address, avoiding problems such as abnormal WAN port configuration or abnormal network connection.
[0099] Optionally, in the embodiment of the present application, step B200 may further include: If it is determined that the DHCP Discover packet does not contain a first DHCP field or the field value of the included first DHCP field is not an identifier representing the target router, then in response to the DHCP Discover packet, send a third DHCP Offer packet to the device that sent the DHCP Discover packet. Among them, the third DHCP Offer packet does not contain a second DHCP field.
[0100] It should be understood that when a DHCP Discover message is obtained and it is determined that the message does not come from the router in the home network system, a third DHCP Offer message is replied to the device that sent the message, so that the device can perform corresponding processing according to the received third DHCP Offer message to ensure the normal operation of the device.
[0101] Based on the application examples provided in the above embodiments, the IP address determination method provided in the embodiments of the present application will be explained.
[0102] After the gateway receives a DHCP Discover message, if it is determined that the message contains an Option 60 field and the Option 60 field type is a router, a DHCP Offer message is replied, and the Option 125 field type of this message is a gateway; if it is determined that the message does not contain an Option 60 field, or the Option 60 field type is a non-router, a DHCP Offer message is replied, and this message does not contain an Option 125 field.
[0103] It can be seen that the IP address determination method provided in the embodiments of the present application, under the DHCP protocol framework, through the optimized design of the DHCP messages of the gateway and the router, ensures that the router can accurately determine the IP address in the message replied by the gateway as its own management IP address, effectively solving the problem that when an existing router supporting WAN self-adaptation receives multiple DHCP Offer messages at the same time, since the DHCP protocol itself cannot distinguish the source of the messages, the router may select an incorrect IP address provided by a non-gateway as the management IP, ultimately resulting in abnormal configuration of its WAN port or abnormal network connection.
[0104] Figure 7 Schematically shows the first structural block diagram of the IP address determination device according to the embodiments of the present application. As Figure 7 shown, in an embodiment of the present application, an IP address determination device is provided, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. The device is configured in a target router among the routers, and the device may include the following functional modules.
[0105] A message sending module, configured to start a DHCP service and broadcast and send a first DHCP Discover message; wherein, the field value of the first DHCP field in the first DHCP Discover message is an identifier characterizing the target router.
[0106] The first message acquisition module is configured to acquire a first DHCP Offer message in response to the first DHCP Discover message from other devices in the home network system.
[0107] The IP address determination module is configured to determine a first DHCP Offer message that contains a second DHCP field and the field value of the second DHCP field represents the identifier of the gateway as the target message, and determine the IP address in the target message as the management IP address of the target router.
[0108] In an embodiment of the present application, the apparatus may further include a message reply module, and the message reply module is configured to:
[0109] When the DHCP service status is the start status, based on the acquired second DHCP Discover message sent by other devices in the home network system, determine whether the second DHCP Discover message comes from other routers in the home network system; if so, do not respond to the second DHCP Discover message.
[0110] In an embodiment of the present application, the message reply module may further be configured to:
[0111] When the DHCP service status is the start status, if it is determined that the second DHCP Discover message does not come from other routers in the home network system, then in response to the second DHCP Discover message, reply a second DHCP Offer message to the device that sent the second DHCP Discover message; wherein, the second DHCP Offer message contains a second DHCP field and the field value of the second DHCP field represents the identifier of the target router.
[0112] In an embodiment of the present application, the apparatus may further include a DHCP service status control module, and the DHCP service status control module is configured to:
[0113] After determining the IP address in the target message as the management IP address of the target router, turn off the DHCP service.
[0114] Since the IP address determination apparatus provided in the embodiment of the present application is a virtual apparatus corresponding to the IP address determination method in the above embodiment, it can also solve the problem in the prior art that when a router supporting WAN adaption receives multiple DHCP Offer messages at the same time, since the DHCP protocol itself cannot distinguish the message sources, the router may select an incorrect IP address provided by a non-gateway as the management IP address, ultimately resulting in abnormal configuration of its WAN port or abnormal network connection.
[0115] Figure 8 Schematically shows a second structural block diagram of the IP address determination device according to an embodiment of the present application. As Figure 8 shown, in an embodiment of the present application, an IP address determination device is provided, which is applied to a home network system. The home network system includes multiple devices, and the multiple devices include a gateway and multiple routers. The device is configured in the gateway, and the device may include the following functional modules.
[0116] A second message acquisition module, configured to acquire DHCP Discover messages sent by other devices in the home network system.
[0117] A message response module, configured to, if it is determined that the DHCP Discover message includes a first DHCP field and the field value of the first DHCP field is an identifier representing the target router, in response to the DHCP Discover message, send a first DHCP Offer message to the target router, so that the target router determines the IP address in the first DHCP Offer message as its management IP address; wherein, the first DHCP Offer message includes a second DHCP field and the field value of the second DHCP field is an identifier representing the gateway.
[0118] In the embodiment of the present application, the message response module is further configured to:
[0119] If it is determined that the DHCP Discover message does not include the first DHCP field or the field value of the included first DHCP field is not an identifier representing the target router, in response to the DHCP Discover message, send a third DHCP Offer message to the device that sent the DHCP Discover message; wherein, the third DHCP Offer message does not include the second DHCP field.
[0120] Since the IP address determination device provided in the embodiment of the present application is a virtual device corresponding to the IP address determination method in the above embodiment, it can also solve the problem in the prior art that when a router supporting WAN adaption receives multiple DHCP Offer messages at the same time, because the DHCP protocol itself cannot distinguish the source of the messages, the router may select an incorrect IP address provided by a non-gateway as the management IP, ultimately resulting in abnormal configuration of its WAN port or abnormal network connection.
[0121] The embodiment of the present application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the IP address determination method described in the above embodiment is implemented.
[0122] The electronic device provided by the embodiment of the present application includes a processor capable of running the IP address determination method of the foregoing embodiment, so it can also solve the problem in the prior art that when a router supporting WAN self - adaptation receives multiple DHCP Offer messages simultaneously, since the DHCP protocol itself cannot distinguish the source of the messages, the router may select an incorrect IP address provided by a non - gateway as the management IP, ultimately resulting in abnormal configuration of its WAN port or abnormal network connection.
[0123] The embodiment of the present application provides a machine - readable storage medium. Instructions are stored on the machine - readable storage medium, and when the instructions are executed by a processor, the processor is configured to execute the IP address determination method described in the foregoing embodiment.
[0124] The machine - readable storage medium provided by the embodiment of the present application stores instructions for causing a machine to execute the IP address determination method described in the foregoing embodiment, so it can also solve the problem in the prior art that when a router supporting WAN self - adaptation receives multiple DHCP Offer messages simultaneously, since the DHCP protocol itself cannot distinguish the source of the messages, the router may select an incorrect IP address provided by a non - gateway as the management IP, ultimately resulting in abnormal configuration of its WAN port or abnormal network connection.
[0125] Figure 9 Schematically shows the internal structure diagram of the computer device according to the embodiment of the present application. As Figure 9 shown, in an embodiment of the present application, a computer device is provided. The computer device may be a terminal. The computer device includes a processor A01, a network interface A02, a display screen A04, an input device A05, and a memory (not shown in the figure) connected through a system bus. Among them, the processor A01 of the computer device is used to provide computing and control capabilities. The memory of the computer device includes an internal memory A03 and a non - volatile storage medium A06. The non - volatile storage medium A06 stores an operating system B01 and a computer program B02. The internal memory A03 provides an environment for the operation of the operating system B01 and the computer program B02 in the non - volatile storage medium A06. The network interface A02 of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor A01, it implements an IP address determination method. The display screen A04 of the computer device may be a liquid crystal display screen or an electronic ink display screen. The input device A05 of the computer device may be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0126] Those skilled in the art can understand, Figure 9The structure shown is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have a different component layout.
[0127] In one embodiment, the IP address determination device provided by this application can be implemented in the form of a computer program, and the computer program can run on a computer device as shown in Figure 9 the figure. Each program module that makes up the IP address determination device can be stored in the memory of the computer device, and the computer program composed of each program module enables the processor to execute the steps in the IP address determination methods of various embodiments of this application described in this specification.
[0128] For example, Figure 9 the computer device shown in the figure can execute the step A100 through the message sending module in the IP address determination device shown in Figure 7 the figure, the first message acquisition module execute the step A200, and the IP address determination module execute the step A300.
[0129] Those skilled in the art should understand that the embodiments of this application can be provided as a method, a system, or a computer program product. Therefore, this application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0130] This application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of this application. It should be understood that each flow and / or block in the flowchart and / or block diagram, and the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in Figure 1 one or more flows and / or blocks Figure 1 one or more blocks.
[0131] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction means that implements the functions specified in one or more of the procedures Figure 1 one or more of the procedures and / or blocks Figure 1 specified in one or more of the blocks or blocks.
[0132] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus, such that a series of operational steps are performed on the computer or other programmable apparatus to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable apparatus provide steps for implementing the functions specified in one or more of the procedures Figure 1 one or more of the procedures and / or blocks Figure 1 specified in one or more of the blocks or blocks.
[0133] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and memory.
[0134] The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM) and / or non-volatile memory such as read-only memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
[0135] Computer-readable media includes both permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. The information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.
[0136] It should also be noted that the term "comprising", "including" or any other variation thereof is intended to cover non-exclusive inclusion, such that a process, method, commodity or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or further includes elements inherent to such process, method, commodity or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, commodity or device comprising the element.
[0137] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included within the scope of the claims of the present application.
Claims
1. An IP address determination method, characterized in that Applied to a home network system, the home network system includes multiple devices, the multiple devices include a gateway and multiple routers, and the method is executed by a target router in the routers. The method includes: Start the DHCP service and broadcast a first DHCP Discover message; wherein, the field value of the first DHCP field in the first DHCP Discover message is an identifier characterizing the target router; Obtain a first DHCPOffer message from other devices in the home network system in response to the first DHCP Discover message; Determine the first DHCP Offer message containing a second DHCP field and with the field value of the second DHCP field being an identifier characterizing the gateway as the target message, and determine the IP address in the target message as the management IP address of the target router.
2. The method according to claim 1, wherein The method further includes: When the DHCP service status is the start status, based on obtaining a second DHCP Discover message sent by other devices in the home network system, determine whether the second DHCP Discover message comes from other routers in the home network system; if so, do not respond to the second DHCP Discover message.
3. The method according to claim 2, characterized in that, The method further includes: When the DHCP service status is the start status, if it is determined that the second DHCP Discover message does not come from other routers in the home network system, then in response to the second DHCP Discover message, reply to the device sending the second DHCP Discover message with a second DHCP Offer message; wherein, the second DHCP Offer message contains a second DHCP field and the field value of the second DHCP field is an identifier characterizing the target router.
4. The method according to claim 1, wherein After determining the IP address in the target message as the management IP address of the target router, the method further includes: shutting down the DHCP service.
5. A method for determining an IP address, characterized in that Applied to a home network system, the home network system includes multiple devices, the multiple devices include a gateway and multiple routers, and the method is executed by the gateway. The method includes: Obtain a DHCP Discover message sent by other devices in the home network system; If it is determined that the DHCP Discover message contains a first DHCP field and the field value of the first DHCP field is an identifier characterizing the target router, then in response to the DHCP Discover message, reply to the target router with a first DHCPOffer message, so that the target router determines the IP address in the first DHCP Offer message as its management IP address; wherein, the first DHCP Offer message contains a second DHCP field and the field value of the second DHCP field is an identifier characterizing the gateway.
6. The method according to claim 4, characterized in that, The method further includes: If it is determined that the DHCP Discover message does not contain the first DHCP field or the field value of the included first DHCP field is not an identifier characterizing the target router, in response to the DHCP Discover message, a third DHCP Offer message is returned to the device that sent the DHCP Discover message; Among them, the third DHCP Offer message does not contain the second DHCP field.
7. An IP address determination device, characterized in that, Applied to a home network system, the home network system includes multiple devices, the multiple devices include a gateway and multiple routers, the device is configured in the target router among the routers, and the device includes: A message sending module, configured to start a DHCP service and broadcast and send a first DHCP Discover message; wherein, the field value of the first DHCP field in the first DHCP Discover message is an identifier characterizing the target router; A first message acquisition module, configured to acquire a first DHCP Offer message of other devices in the home network system in response to the first DHCP Discover message; An IP address determination module, configured to determine a first DHCP Offer message that includes a second DHCP field and the field value of the second DHCP field is an identifier characterizing the gateway as a target message, and determine the IP address in the target message as the management IP address of the target router.
8. An IP address determination device, characterized in that Applied to a home network system, the home network system includes multiple devices, the multiple devices include a gateway and multiple routers, the device is configured in the gateway, and the device includes: A second message acquisition module, configured to acquire a DHCP Discover message sent by other devices in the home network system; A message response module, configured to, if it is determined that the DHCP Discover message includes a first DHCP field and the field value of the first DHCP field is an identifier characterizing the target router, in response to the DHCP Discover message, return a first DHCP Offer message to the target router, so that the target router determines the IP address in the first DHCP Offer message as its management IP address; Among them, the first DHCP Offer message includes a second DHCP field and the field value of the second DHCP field is an identifier characterizing the gateway.
9. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the IP address determination method according to any one of claims 1 to 4 or the IP address determination method according to any one of claims 5 to 6.
10. A machine-readable storage medium having instructions stored thereon, characterized in that, When the instruction is executed by the processor, the processor is configured to execute the IP address determination method according to any one of claims 1 to 4 or the IP address determination method according to any one of claims 5 to 6.