CN113037880B - Gateway IP address configuration method and device, gateway and readable storage medium - Google Patents

Gateway IP address configuration method and device, gateway and readable storage medium Download PDF

Info

Publication number
CN113037880B
CN113037880B CN202110155789.8A CN202110155789A CN113037880B CN 113037880 B CN113037880 B CN 113037880B CN 202110155789 A CN202110155789 A CN 202110155789A CN 113037880 B CN113037880 B CN 113037880B
Authority
CN
China
Prior art keywords
gateway
address
network segment
service
wan interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110155789.8A
Other languages
Chinese (zh)
Other versions
CN113037880A (en
Inventor
林英想
庄严
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Minew Technologies Co ltd
Original Assignee
Shenzhen Minew Technologies Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Minew Technologies Co ltd filed Critical Shenzhen Minew Technologies Co ltd
Priority to CN202110155789.8A priority Critical patent/CN113037880B/en
Publication of CN113037880A publication Critical patent/CN113037880A/en
Application granted granted Critical
Publication of CN113037880B publication Critical patent/CN113037880B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/66Arrangements for connecting between networks having differing types of switching systems, e.g. gateways
    • 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/5038Address allocation for local use, e.g. in LAN or USB networks, or in a controller area network [CAN]
    • 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/5046Resolving address allocation conflicts; Testing of addresses

Landscapes

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

Abstract

The application belongs to the technical field of gateways, and mainly provides a gateway IP address configuration method, a gateway IP address configuration device, a gateway and a readable storage medium, wherein the gateway IP address configuration method comprises the following steps: the method comprises the steps of detecting a cascade mode of the gateway, configuring the bridge service, the DHCP service and the switch state of a firewall of the gateway into a preset switch state according to the cascade mode, modifying the IP address of the gateway LAN interface when a network segment to which the IP address of the gateway LAN interface belongs is consistent with a network segment to which the IP address of the gateway WAN interface belongs until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, completing the configuration of the IP address of the gateway, realizing the automatic configuration of the IP address of the gateway, achieving the effect of plug and play, not needing to manually set the IP address of the gateway, and simplifying the deployment of the gateway.

Description

Method and device for configuring gateway IP address, gateway and readable storage medium
Technical Field
The present application belongs to the technical field of gateways, and in particular, to a method and an apparatus for configuring a gateway IP address, a gateway, and a readable storage medium.
Background
The gateway of the Internet of things not only has a network routing function, but also has a function of connecting the equipment of the Internet of things to the Internet. In the internet of things gateway industry, the number of deployed gateways is often more than one, and therefore, the gateways of the internet of things need to handle the cascade relationship among multiple gateways.
However, in all the existing cascade connection modes between gateways, the setting of the gateway IP address needs to be manually performed, and plug and play cannot be realized.
Disclosure of Invention
The application aims to provide a method and a device for configuring a gateway IP address, a gateway and a readable storage medium, which can realize automatic configuration of the gateway IP address, achieve the effect of plug and play and simplify the deployment of the gateway.
A first aspect of an embodiment of the present application provides a method for configuring a gateway IP address, where the method is applied to a gateway, and the method for configuring a gateway IP address includes:
detecting a cascade mode of the gateway;
configuring the bridge service, DHCP service and firewall switch state of the gateway to a preset switch state according to the cascade mode, and detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs when the bridge service and DHCP service switch state of the gateway are in the preset switch state;
and if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, modifying the IP address of the gateway LAN interface until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and finishing the configuration of the IP address of the gateway.
A second aspect of the embodiments of the present application provides a gateway IP address configuration device, where the gateway IP address configuration device includes:
the detection unit is used for detecting the cascade mode of the gateway;
the configuration unit is used for configuring the bridge service, the DHCP service and the switch state of the firewall of the gateway into a preset switch state according to the cascade mode, and detecting whether a network segment to which an IP address of the gateway LAN interface belongs is consistent with a network segment to which an IP address of the gateway WAN interface belongs when the bridge service and the DHCP service of the gateway are in the preset switch state;
and the modifying unit is used for modifying the IP address of the gateway LAN interface if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and finishing the configuration of the IP address of the gateway.
A third aspect of the embodiments of the present application provides a gateway, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the steps of the method for configuring an IP address of the gateway according to the first aspect when executing the computer program.
A fourth aspect of the embodiments of the present application provides a computer-readable storage medium, where a computer program is stored, and when being executed by a processor, the computer program implements the steps of the method for configuring an IP address of a gateway according to the first aspect.
In the embodiment of the application, after the gateway is started, a cascade mode of the gateway is detected, then, a bridge service, a DHCP service and a switch state of a firewall of the gateway are configured to be a preset switch state according to the cascade mode, and whether a network segment to which an IP address of a gateway LAN interface belongs is consistent with a network segment to which an IP address of a gateway WAN interface belongs is detected when the bridge service and the DHCP service of the gateway are in the preset switch state; and when the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, modifying the IP address of the gateway LAN interface until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, completing the configuration of the gateway IP address, realizing the automatic configuration of the gateway IP address, achieving the plug-and-play effect, avoiding the need of manually setting the gateway IP address, and simplifying the deployment of the gateway.
Drawings
Fig. 1 is a schematic diagram of a first configuration result of an IP address of an internet of things gateway provided in an embodiment of the present application;
fig. 2 is a schematic diagram of a second configuration result of an IP address of an internet of things gateway provided in the embodiment of the present application;
fig. 3 is a schematic view of an implementation flow of a method for configuring an IP address of a gateway according to an embodiment of the present application.
Fig. 4 is a schematic structural diagram of a configuration apparatus for a gateway IP address according to an embodiment of the present application.
Fig. 5 is a schematic diagram of a gateway provided in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The gateway of the internet of things is also a router in nature, and not only has the network routing function of a civil router, but also has the function of connecting the devices of the internet of things (such as Bluetooth devices, zigBee devices and the like) to the internet.
In addition, different from a civil router, in the internet of things gateway industry, the number of deployed gateways is often more than one, and therefore, the gateways of the internet of things need to handle the cascade relationship among multiple gateways.
At present, there are two main ways of cascading between gateways, a bridge mode and a non-bridge mode.
When the gateways are cascaded in a bridging mode, the newly added gateway does not add a network segment but continues the network segment of the upstream network, namely, the upstream network can communicate with the downstream network, and the batch management of the Internet of things equipment is favorably realized.
For example, as shown in fig. 1, after the gateways are cascaded in the bridge mode, the IP addresses of the WAN interfaces of the gateway 1 and the gateway 2 are 192.168.0.2 and 192.168.0.3, and the IP address of the WAN interface of the newly added gateway 3 is configured to be 192.168.0.4; namely, the gateway 1, the gateway 2 and the newly added gateway 3 are in the same network segment, and the upstream network can communicate with the downstream network, which is beneficial to realizing the batch management of the internet of things devices.
When the gateways are cascaded in a non-bridging mode, each time a gateway is added, a network segment is added in the internet of things system, and after the network segment is added, an upstream network cannot directly access a downstream network.
For example, as shown in fig. 2, the IP addresses of the WAN interfaces of the gateway 1 and the gateway 2 are 192.168.0.2, 192.168.98.2, and the IP address of the WAN interface of the newly added gateway 3 is configured to be 192.168.97.2; the gateway 1, the gateway 2 and the gateway 3 are all in different network segments, and an upstream network cannot directly access a downstream network, so that the method has the characteristic of higher network security.
However, in practical applications, when the gateways are deployed, the gateways that are cascaded in the bridge mode are adopted, and in order to better manage the gateways, a static IP address needs to be manually set for each gateway in sequence; however, in the gateways that are cascaded in the non-bridging mode, because each gateway needs to be located in a different network segment, an IP address needs to be manually set for each gateway in sequence, that is, the two gateways are cascaded in a manner that the IP addresses of the gateways need to be manually set, and plug and play cannot be realized.
Based on this, embodiments of the present application provide a method and an apparatus for configuring a gateway IP address, a gateway, and a readable storage medium, which can implement automatic configuration of a gateway IP address, achieve an effect of plug and play, and simplify deployment of a gateway.
Fig. 3 is a schematic view illustrating an implementation flow of a method for configuring an IP address of a gateway according to an embodiment of the present application, where the method for configuring an IP address of a gateway is applied to the gateway, and after the gateway is powered on, a device for configuring an IP address of the gateway can execute the method for configuring an IP address of a gateway. Specifically, the method for configuring the gateway IP address may include: step 101 to step 103 are detailed as follows:
step 101, detecting a cascade mode of a gateway.
In this embodiment, the cascading manner between the gateways may include a bridge mode and a non-bridge mode.
Optionally, the cascade mode of the detection gateway may be implemented by: detecting whether a mode switch of the gateway is turned on, and confirming that a cascade mode of the gateway is a bridge mode or a non-bridge mode when the mode switch of the gateway is turned on; and when the mode switch of the gateway is closed, determining that the cascade mode of the gateway is a non-bridge mode or a bridge mode. Or acquiring factory setting information of the gateway and confirming the cascade mode of the gateway.
It should be noted that, this is merely an example for detecting the cascading mode of the gateway, and is not meant to limit the scope of the present application, and in other embodiments of the present application, the cascading mode of the gateway may be detected in other manners.
And 102, configuring the bridge service, the DHCP service and the switch state of the firewall of the gateway into a preset switch state according to the cascade mode, and detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs when the bridge service and the DHCP service of the gateway are in the preset switch state.
Optionally, the configuring, according to the cascade mode, the bridge service of the gateway, the DHCP service, and the switch state of the firewall to the preset switch state may include: if the cascade mode of the gateway is a bridge mode, configuring the bridge service of the gateway to be in an open state, and configuring the DHCP service and the firewall of the gateway to be in a closed state; and if the cascade mode of the gateway is a non-bridge mode, configuring the bridge service of the gateway to be in a closed state, and configuring the DHCP service and the firewall of the gateway to be in an open state.
That is, when the cascade mode of the gateway is the bridge mode, the preset switch states corresponding to the bridge service, the DHCP service and the firewall are that the bridge service is in the on state, and the DHCP service and the firewall are in the off state; when the cascade mode of the gateway is a non-bridge mode, the preset switch states corresponding to the bridge service, the DHCP service and the firewall are that the bridge service is in a closed state, and the DHCP service and the firewall are in an open state.
Specifically, in the embodiment of the present application, when the cascade mode of the gateway is the bridge mode, the newly added gateway does not add a network segment but continues the network segment of the upstream network, so that when the cascade mode of the gateway is the bridge mode, the bridge service is in an open state, and the DHCP service and the firewall are in a closed state, so that the newly added gateway and the downstream device thereof can obtain the DHCP service from the upstream gateway or router, and the firewall of the downstream device of the newly added gateway is in the same state as that in a local area network.
For example, as shown in fig. 1, when accessing the internet of things, the newly added gateway 3 may send an IP address acquisition request to the upstream network, and receive the IP address 192.168.0.4 of the WAN interface of the gateway 3 forwarded by the gateway 1 and the gateway 2 and allocated by the router 4 of the upstream network, where the gateway 1 and the gateway 2 only forward the IP address and do not allocate the IP address.
In addition, when the cascade mode of the gateway is a non-bridge mode, a network segment is added to the newly added gateway instead of the network segment of the continuous upstream network, that is, the IP address of the newly added gateway is not in the same network segment with the IP addresses of other gateways and routers in the upstream, so that when the cascade mode of the gateway is the non-bridge mode, the bridge service is in a closed state, and the DHCP service and the firewall are in an open state, so that the downstream equipment of the newly added gateway can obtain the DHCP service from the newly added gateway, and the firewall of the newly added gateway can protect the downstream Internet of things equipment.
For example, as shown in fig. 2, the gateway 2 and the gateway 3 are cascaded in a non-bridge mode, and when the new gateway 3 accesses the internet of things, the IP address 192.168.97.2 of the WAN interface can be obtained from the DHCP service of the gateway 2 of the upstream network, and at this time, the IP address 192.168.98.2 of the WAN interface of the gateway 2 and the IP address 192.168.97.2 of the WAN interface of the gateway 3 are in different network segments.
In the embodiment of the application, after the gateway acquires the DHCP service from an upstream gateway or router and obtains the IP address of the WAN interface, it is necessary to detect whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, so as to avoid the collision of the gateway IP addresses and the abnormality of the network of the gateway itself.
And 103, if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, modifying the IP address of the gateway LAN interface until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and finishing the configuration of the gateway IP address.
In practical application, the default IP address of the LAN interface when the gateway leaves the factory is generally 192.168.98.1, and therefore, when the gateway accesses the internet of things, and after the IP address of the WAN interface is acquired from an upstream gateway or router, the IP address of the WAN interface acquired from the upstream gateway or router may be located in a network segment with the IP address of the default LAN interface when leaving the factory, and therefore, it is necessary to detect whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, and modify the IP address of the gateway LAN interface when the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, so as to avoid conflict between the IP addresses of the gateway and cause abnormality of the network of the gateway itself.
For example, as shown in fig. 2, the IP address of the WAN interface acquired by the gateway 2 from the DHCP service of the gateway 1 is 192.168.98.2, and the default IP address of the LAN interface when the gateway 2 leaves the factory is 192.168.98.1, at this time, the gateway 2 and the gateway 1 are in a network segment, and therefore, the IP address of the LAN interface of the gateway 2 needs to be modified to make the network segment to which the IP address of the LAN interface of the gateway 2 belongs coincide with the network segment to which the IP address of the WAN interface of the gateway 2 belongs, so as to avoid the collision of the IP addresses of the gateway 2 and the abnormality of the network of the gateway 2 itself.
Optionally, in some embodiments of the present application, the modifying the IP address of the gateway LAN interface may be implemented by a circular decrement or a circular increment.
For example, the IP address of the gateway LAN interface is 192.168.X.1, and x ranges from 0 to 255, and when the network segment to which the IP address of the gateway LAN interface belongs is identical to the network segment to which the IP address of the gateway WAN interface belongs, the value of x may be reduced by 1 until the network segment to which the IP address of the gateway LAN interface belongs is not identical to the network segment to which the IP address of the gateway WAN interface belongs, and the configuration of the gateway IP address is completed. Wherein, when x is zero, x minus 1 is 255.
Since the correspondence between the IP address of the gateway LAN interface and the domain name of the gateway is changed after the IP address of the gateway LAN interface is modified, in order to ensure that the gateway can be accessed by using the domain name of the gateway, after the IP address of the gateway LAN interface is modified, the modified IP address of the gateway LAN interface may be written into a preset storage path of the gateway, for example, into an/etc/hosts file, so as to update the correspondence between the IP address of the gateway LAN interface and the domain name of the gateway.
Optionally, in some embodiments of the present application, before detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs in step 102, it may be detected whether the IP address of the gateway WAN interface is empty; and when the IP address of the gateway WAN interface is empty, outputting a prompt message that the upstream network of the gateway is abnormal. And when the IP address of the gateway WAN interface is not empty, detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs.
Specifically, after the gateway accesses the internet of things, the gateway can request to allocate an IP address of a WAN interface to an upstream network, so that when the IP address of the WAN interface is empty, it indicates that the upstream network of the gateway is abnormal, and the IP address of the WAN interface cannot be allocated to the gateway, and therefore, a prompt message indicating that the upstream network of the gateway is abnormal can be output without detecting whether a network segment to which the IP address of the LAN interface of the gateway belongs is consistent with a network segment to which the IP address of the WAN interface of the gateway belongs.
Optionally, after the notification message that the upstream network of the gateway is abnormal is output, or when the gateway does not complete the configuration of the IP address due to other reasons, the gateway may be controlled to enter the sleep state first, and after a first preset time interval, the gateway is awakened, and the IP address is configured for the gateway again.
The first preset duration may be set according to actual experience, or may be set by default when leaving a factory.
When the cascade mode of the gateway is the bridge mode, the bridge service is in an open state, and in order to ensure that the bridge mode of the gateway can work normally, optionally, when the IP address of the gateway WAN interface is detected not to be empty, whether the IP address of the gateway WAN interface is consistent with the IP address configured in the bridge service of the gateway can be detected; and when the IP address of the gateway WAN interface is inconsistent with the IP address configured in the bridging service of the gateway, updating the IP address configured in the bridging service of the gateway into the IP address of the gateway WAN interface so as to ensure that the bridging mode of the gateway can work normally.
In some embodiments of the present application, after the configuration of the IP address of the gateway is completed, the gateway may be further controlled to enter a sleep state, and after a second preset time interval, the gateway is awakened again, and the IP address of the gateway is configured.
In the embodiment of the application, after the gateway is started, a cascade mode of the gateway is detected, then, a bridge service, a DHCP service and a switch state of a firewall of the gateway are configured to be a preset switch state according to the cascade mode, and whether a network segment to which an IP address of a gateway LAN interface belongs is consistent with a network segment to which an IP address of a gateway WAN interface belongs is detected when the bridge service and the DHCP service of the gateway are in the preset switch state; and when the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, modifying the IP address of the gateway LAN interface until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, completing the configuration of the gateway IP address, realizing the automatic configuration of the gateway IP address, achieving the plug-and-play effect, avoiding the need of manually setting the gateway IP address, simplifying the deployment of the gateway, and greatly improving the deployment efficiency of the gateway especially when the number of the gateway is large.
In addition, the IP address and the domain name of the gateway LAN interface are written into the preset storage path of the gateway, so that the access of the gateway is realized through the domain name, and the IP address of the gateway does not need to be memorized.
It should be noted that for simplicity of description, the aforementioned method embodiments are all presented as a series of combinations of acts, but those skilled in the art will appreciate that the present invention is not limited by the order of acts described, as some steps may occur in other orders in accordance with the present invention.
Fig. 4 is a schematic structural diagram illustrating an apparatus 400 for configuring an IP address of a gateway according to an embodiment of the present application, where the apparatus 400 for configuring an IP address of a gateway is configured at the gateway, and includes:
a detecting unit 401, configured to detect a cascade mode of the gateway;
a configuration unit 402, configured to configure the bridge service, the DHCP service, and the switch state of the firewall of the gateway to a preset switch state according to the cascade mode, and detect whether a network segment to which an IP address of the gateway LAN interface belongs is consistent with a network segment to which an IP address of the gateway WAN interface belongs when the bridge service and the DHCP service of the gateway are in the preset switch state;
a modifying unit 403, configured to modify the IP address of the gateway LAN interface if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and complete configuration of the gateway IP address.
Optionally, the configuring unit 402 is further configured to configure the bridge service of the gateway to be in an open state and configure the DHCP service and the firewall of the gateway to be in a closed state if the cascade mode of the gateway is the bridge mode; and if the cascade mode of the gateway is a non-bridge mode, configuring the bridge service of the gateway to be in a closed state, and configuring the DHCP service and the firewall of the gateway to be in an open state.
Optionally, the configuration unit 402 is further configured to detect whether the IP address of the gateway WAN interface is empty before the detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs; and if the IP address of the gateway WAN interface is null, outputting a prompt message that the upstream network of the gateway is abnormal.
Optionally, the configuring unit 402 is further configured to, after detecting whether the IP address of the gateway WAN interface is empty, if the IP address of the gateway WAN interface is not empty and the cascade mode of the gateway is the bridge mode, detect whether the IP address of the gateway WAN interface is consistent with the IP address configured in the bridge service of the gateway; and if the IP address of the gateway WAN interface is inconsistent with the IP address configured in the bridging service of the gateway, updating the IP address configured in the bridging service of the gateway to the IP address of the gateway WAN interface.
Optionally, the apparatus 400 for configuring an IP address of a gateway may further include a sleep unit, configured to reconfigure the IP address of the gateway at an interval of a first preset time after the output of the prompt message that the upstream network of the gateway is abnormal; and/or after the configuration of the gateway IP address is completed, the IP address is reconfigured for the gateway at an interval of second preset time.
Optionally, the modifying unit 403 is further configured to, after modifying the IP address of the gateway LAN interface, write the modified IP address of the gateway LAN interface into a preset storage path of the gateway, so as to update a corresponding relationship between the IP address of the gateway LAN interface and the domain name of the gateway.
It should be noted that, for convenience and simplicity of description, the specific working process of the above-described gateway IP address configuration apparatus 400 may refer to the corresponding process of the method described in fig. 1 and fig. 3, and is not described herein again.
Optionally, an embodiment of the present application further provides a gateway, where the gateway may be configured with the configuration apparatus for the gateway IP address in each of the foregoing embodiments; alternatively, the gateway may be a gateway for implementing the configuration method of the IP addresses of the gateways.
Specifically, as shown in fig. 5, the gateway may include: a processor 50, a memory 51 and a computer program 52 stored in the memory 51 and executable on the processor 50. The processor 50 executes the computer program 52 to implement the steps in the above-mentioned configuration method embodiment of the gateway IP address, for example, the steps 101 to 103 shown in fig. 3.
The Processor 50 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. The general purpose processor may be a microprocessor, any conventional processor, etc.
The storage 51 may be an internal storage unit of the gateway 5, for example, a hard disk or a memory. The memory 51 may also be an external storage device for the gateway 5, such as a plug-in hard disk provided on the gateway 5, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 51 may also include both an internal storage unit of the gateway 5 and an external storage device. The memory 51 is used for storing the above-mentioned computer programs and other programs and data required by the gateway.
The computer program may be divided into one or more modules/units, which are stored in the memory 51 and executed by the processor 50 to complete the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, and the instruction segments are used for describing the execution process of the computer program in the configuration of the gateway IP address. For example, the computer program may be divided into: the detection unit, the configuration unit and the modification unit have the following specific functions:
the detection unit is used for detecting the cascade mode of the gateway;
the configuration unit is used for configuring the bridge service, the DHCP service and the switch state of the firewall of the gateway into a preset switch state according to the cascade mode, and detecting whether a network segment to which an IP address of the gateway LAN interface belongs is consistent with a network segment to which an IP address of the gateway WAN interface belongs when the bridge service and the DHCP service of the gateway are in the preset switch state;
and the modifying unit is used for modifying the IP address of the gateway LAN interface if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and finishing the configuration of the gateway IP address.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed gateway and method may be implemented in other ways. For example, the gateway embodiments described above are merely illustrative. For example, a division of modules or units into only one logical division may be implemented in an alternate manner, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not implemented. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the embodiments described above may be implemented by a computer program, which is stored in a computer readable storage medium and used by a processor to implement the steps of the embodiments of the methods described above. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, U.S. disk, removable hard disk, magnetic disk, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, in accordance with legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunications signals.
The above embodiments are only used to illustrate the technical solutions of the present application, and not to limit the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present application and are intended to be included within the scope of the present application.

Claims (9)

1. A method for configuring a gateway IP address, comprising:
after a gateway is started, detecting a cascade mode of the gateway; the detecting the cascade mode of the gateway includes: according to the on or off of a mode selector switch of the gateway, confirming that the cascade mode of the gateway is a bridge mode or a non-bridge mode; the gateway is any one of a plurality of internet of things gateways;
configuring the bridge service, the DHCP service and the switch state of the firewall of the gateway into a preset switch state according to the cascade mode, and detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs when the bridge service and the DHCP service of the gateway are in the preset switch state;
if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, modifying the IP address of the gateway LAN interface until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and finishing the configuration of the gateway IP address;
before the detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, the method comprises the following steps:
detecting whether the IP address of the gateway WAN interface is empty;
if the IP address of the gateway WAN interface is not empty and the cascade mode of the gateway is the bridge mode, detecting whether the IP address of the gateway WAN interface is consistent with the IP address configured in the bridge service of the gateway;
and if the IP address of the gateway WAN interface is inconsistent with the IP address configured in the bridging service of the gateway, updating the IP address configured in the bridging service of the gateway to the IP address of the gateway WAN interface.
2. The method for configuring the gateway IP address according to claim 1, wherein the configuring the bridge service, the DHCP service, and the switch state of the firewall of the gateway to the preset switch state according to the cascade mode comprises:
if the cascade mode of the gateway is the bridge mode, configuring the bridge service of the gateway to be in an open state, and configuring the DHCP service and the firewall of the gateway to be in a closed state;
and if the cascade mode of the gateway is a non-bridge mode, configuring the bridge service of the gateway to be in a closed state, and configuring the DHCP service and the firewall of the gateway to be in an open state.
3. The method for configuring a gateway IP address of claim 1, wherein before said detecting whether the segment to which the IP address of the gateway LAN interface belongs is consistent with the segment to which the IP address of the gateway WAN interface belongs, comprising:
and if the IP address of the gateway WAN interface is empty, outputting a prompt message that the upstream network of the gateway is abnormal.
4. The method for configuring the IP address of the gateway according to claim 3, wherein after the outputting the notification message that the upstream network of the gateway is abnormal, the method further comprises:
and after a first preset time interval, reconfiguring the IP address of the gateway.
5. The method for configuring gateway IP address according to claim 1, comprising, after said modifying the IP address of the gateway LAN interface:
and writing the modified IP address of the gateway LAN interface into a preset storage path of the gateway so as to update the corresponding relation between the IP address of the gateway LAN interface and the domain name of the gateway.
6. The method for configuring a gateway IP address according to claim 1, wherein after the completion of the configuration of the gateway IP address, comprising:
and after a second preset time interval, reconfiguring the IP address of the gateway.
7. An apparatus for configuring an IP address of a gateway, comprising:
the detection unit is used for detecting the cascade mode of the gateway after the gateway is started; the detecting the cascade mode of the gateway includes: according to the on or off of a mode selector switch of the gateway, confirming that the cascade mode of the gateway is a bridge mode or a non-bridge mode; the gateway is any one of a plurality of internet of things gateways;
the configuration unit is used for configuring the bridge service, the DHCP service and the on-off state of the firewall of the gateway into a preset on-off state according to the cascade mode, and detecting whether a network segment to which the IP address of the gateway LAN interface belongs is consistent with a network segment to which the IP address of the gateway WAN interface belongs when the bridge service and the DHCP service of the gateway are in the preset on-off state;
a modification unit, configured to modify the IP address of the gateway LAN interface if the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, until the network segment to which the IP address of the gateway LAN interface belongs is inconsistent with the network segment to which the IP address of the gateway WAN interface belongs, and complete configuration of the gateway IP address;
before the detecting whether the network segment to which the IP address of the gateway LAN interface belongs is consistent with the network segment to which the IP address of the gateway WAN interface belongs, the method comprises the following steps:
detecting whether the IP address of the gateway WAN interface is empty;
if the IP address of the gateway WAN interface is not empty and the cascade mode of the gateway is the bridge mode, detecting whether the IP address of the gateway WAN interface is consistent with the IP address configured in the bridge service of the gateway;
and if the IP address of the gateway WAN interface is inconsistent with the IP address configured in the bridging service of the gateway, updating the IP address configured in the bridging service of the gateway to the IP address of the gateway WAN interface.
8. A gateway comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 6.
CN202110155789.8A 2021-02-04 2021-02-04 Gateway IP address configuration method and device, gateway and readable storage medium Active CN113037880B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110155789.8A CN113037880B (en) 2021-02-04 2021-02-04 Gateway IP address configuration method and device, gateway and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110155789.8A CN113037880B (en) 2021-02-04 2021-02-04 Gateway IP address configuration method and device, gateway and readable storage medium

Publications (2)

Publication Number Publication Date
CN113037880A CN113037880A (en) 2021-06-25
CN113037880B true CN113037880B (en) 2022-12-13

Family

ID=76460002

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110155789.8A Active CN113037880B (en) 2021-02-04 2021-02-04 Gateway IP address configuration method and device, gateway and readable storage medium

Country Status (1)

Country Link
CN (1) CN113037880B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116248635B (en) * 2023-03-23 2024-07-09 广东保伦电子股份有限公司 Method, equipment and medium for modifying local area network conflict protocol addresses in batches

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105577853A (en) * 2016-03-09 2016-05-11 上海斐讯数据通信技术有限公司 Method and device for automatically solving IP network segment conflict

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105744012A (en) * 2016-03-09 2016-07-06 上海斐讯数据通信技术有限公司 Automatic solving method and device for IP (Internet Protocol) network segment conflicts of multiple WAN (wide area network) and LAN (local area network)
CN108234687B (en) * 2017-12-29 2021-03-19 深圳华望技术有限公司 Intelligent IP address configuration method and device and terminal equipment

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105577853A (en) * 2016-03-09 2016-05-11 上海斐讯数据通信技术有限公司 Method and device for automatically solving IP network segment conflict

Also Published As

Publication number Publication date
CN113037880A (en) 2021-06-25

Similar Documents

Publication Publication Date Title
CN111371638B (en) Intelligent equipment testing method and device, server and storage medium
CN110719209B (en) Cluster network configuration method, system, equipment and readable storage medium
CN111880901B (en) Network configuration method, device, equipment and readable storage medium
US11080404B2 (en) Firmware upgrade method, slave station of robot, and machine readable storage medium
CN108243407B (en) Method for managing network interfaces of multiple wireless module devices and terminal device
CN111182659B (en) Mode switching method and mode switching device of Mesh equipment and Mesh equipment
CN104518910B (en) Apparatus for configuring Ethernet device and method for configuring Ethernet device
CN111132267A (en) Network distribution method and device and terminal equipment
CN111654399B (en) Networking method, device, equipment and storage medium based on SD-WAN
CN113037880B (en) Gateway IP address configuration method and device, gateway and readable storage medium
EP3561741A1 (en) Method and apparatus for optimised remote management of programmable logic controllers
CN115514586A (en) Access control policy configuration method and electronic equipment
CN114157639B (en) Method, device and equipment for collecting information of intelligent network card of server and readable medium
EP3767410A1 (en) Control system, controller, and control method
CN111404951A (en) Tenant creating method of cloud network, computer equipment and storage medium
CN108234687B (en) Intelligent IP address configuration method and device and terminal equipment
CN113965548A (en) Hardware drive updating method, system, equipment and medium of storage server
CN111026047B (en) Software configuration method and device
CN109889421B (en) Router management method, device, terminal, system and storage medium
US11411797B2 (en) Device management method and related device
CN109254932B (en) Multi-network-port driving method, device and storage medium
CN115208671B (en) Firewall configuration method, device, electronic equipment and storage medium
CN111130976B (en) Method, equipment and medium for configuring virtual local area network of white box switch
US20180295017A1 (en) Dynamic interface identification and configuration
CN107544928B (en) Direct memory access control device and method for operating the same

Legal Events

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