Disclosure of Invention
The present invention aims to provide an IP address query method, an IP address query device, a server, a control device, and a medium, which are used to solve the problems in the related art that when a communication network between a control platform and a device is a wide area network, a device management platform needs to be developed to acquire the IP address of the device, which reduces the efficiency of acquiring the IP address and increases the cost of acquiring the IP address.
In order to achieve the above purpose, the embodiment of the present invention adopts the following technical solutions:
in a first aspect, an embodiment of the present invention provides an IP address query method, which is applied to a server, where a communication network among the server, a control device, and a target device is a wide area network, and the method includes:
receiving an inquiry request sent by the control equipment, wherein the inquiry request comprises: a physical address of the target device;
searching the IP address of the target equipment according to the physical address of the target equipment;
sending an inquiry response to the control device, the inquiry response including: the IP address of the target device is used for enabling the control device to control the target device.
Optionally, the query request further includes: before the controlling device identifies the information and searches for the IP address of the target device according to the physical address of the target device, the method further includes:
determining whether the control equipment is preset white list equipment or not according to preset identification information and the identification information of the control equipment;
the searching for the IP address having the target device according to the physical address of the target device includes:
and if the control equipment is the white list equipment, searching the IP address of the target equipment according to the physical address of the target equipment.
Optionally, the preset identification information is a preset physical address, and the identification information of the control device is a physical address of the control device; the determining whether the control device is a preset white list device according to the preset identification information and the identification information of the control device includes:
and determining whether the control equipment is the white list equipment or not according to the preset physical address and the physical address of the control equipment.
Optionally, the query request includes: a query command, wherein the query command carries a physical address of the target device; the searching the IP address of the target device according to the physical address of the target device includes:
calling a command query window by adopting a preset application program;
and executing the query command based on the command query window to search the IP address of the target device.
Optionally, before receiving the query request sent by the control device, the method further includes:
receiving an address allocation request of the target device;
and allocating an IP address to the target equipment according to the address allocation request.
In a second aspect, an embodiment of the present invention further provides an IP address query method, which is applied to a control device, where a communication network among the control device, a server, and a target device is a wide area network, and the method includes:
sending a query request to the server, the query request including: the query request is used for enabling the server to search the IP address of the target equipment according to the physical address of the target equipment;
and receiving the IP address of the target equipment sent by the server so as to control the target equipment according to the IP address of the target equipment.
Optionally, the sending the query request to the server includes:
and if the connection between the target equipment and the control equipment is detected to be disconnected or the control is abnormal, sending the query request to the server.
Optionally, the sending the query request to the server includes:
and sending the query request to the server in a socket communication mode.
In a third aspect, an embodiment of the present invention further provides an IP address querying apparatus, which is applied to a server, where a communication network among the server, a control device, and a target device is a wide area network, and the apparatus includes:
a receiving module, configured to receive an inquiry request sent by the control device, where the inquiry request includes: a physical address of the target device;
the searching module is used for searching the IP address of the target equipment according to the physical address of the target equipment;
a sending module, configured to send an inquiry response to the control device, where the inquiry response includes: the IP address of the target device is used for enabling the control device to control the target device.
Optionally, the query request further includes: identification information of the control device, the apparatus further comprising:
the determining module is used for determining whether the control equipment is preset white list equipment or not according to preset identification information and the identification information of the control equipment;
the searching module is further configured to search, if the control device is the white list device, an IP address of the target device according to the physical address of the target device.
Optionally, the preset identification information is a preset physical address, and the identification information of the control device is a physical address of the control device; the determining module is further configured to determine whether the control device is the white list device according to the preset physical address and the physical address of the control device.
Optionally, the query request includes: a query command, wherein the query command carries a physical address of the target device; the searching module is also used for calling a command to query a window by adopting a preset application program; and executing the query command based on the command query window to search the IP address of the target device.
Optionally, the apparatus further comprises:
a first receiving module, configured to receive an address allocation request of the target device;
and the allocation module is used for allocating the IP address to the target equipment according to the address allocation request.
In a fourth aspect, an embodiment of the present invention further provides an IP address querying apparatus, which is applied to a control device, where a communication network among the control device, a server, and a target device is a wide area network, and the apparatus includes:
a sending module, configured to send a query request to the server, where the query request includes: the query request is used for enabling the server to search the IP address of the target equipment according to the physical address of the target equipment;
and the receiving module is used for receiving the IP address of the target equipment sent by the server so as to control the target equipment according to the IP address of the target equipment.
Optionally, the sending module is further configured to send the query request to the server if it is detected that the connection between the target device and the control device is disconnected or the control is abnormal.
Optionally, the sending module is further configured to send the query request to the server in a socket communication manner.
In a fifth aspect, an embodiment of the present invention further provides a server, including: a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor implements the IP address querying method according to any one of the first aspect when executing the computer program.
In a sixth aspect, an embodiment of the present invention further provides a control device, including: a memory and a processor, wherein the memory stores a computer program executable by the processor, and the processor implements the IP address querying method according to any one of the first aspect when executing the computer program.
In a seventh aspect, an embodiment of the present invention further provides a storage medium, where the storage medium stores a computer program, and when the computer program is read and executed, the IP address query method according to any one of the first aspect and the second aspect is implemented.
The invention has the beneficial effects that: the embodiment of the invention provides an IP address query method, which receives a query request sent by control equipment, wherein the query request comprises the following steps: a physical address of the target device; searching an IP address of the target equipment according to the physical address of the target equipment; sending an inquiry response to the control device, the inquiry response comprising: and the IP address of the target device is used for enabling the control device to control the target device. For a server, a control device and a target device of which a communication network is a wide area network, when the IP address of the target device is acquired, the server can search the IP address of the target device according to the physical address of the target device in an inquiry request sent by the control device, and send the IP address of the target device to the control device, so that the process of acquiring the IP address of the target device by the control device is more convenient and efficient, a device management platform does not need to be developed, and the cost of acquiring the IP address is reduced.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention.
A DHCP (Dynamic Host Configuration Protocol) server may allocate an IP Address (Internet Protocol Address) to the device to be tested, and the control platform may test or otherwise control the device according to the IP Address of the device. When the IP address of the equipment is replaced, the control platform has the problem that the equipment to be tested is off-line, so that the equipment to be tested cannot be controlled, and therefore the control platform is more and more important to acquire the IP address of the equipment to be tested. In the related art, research and development personnel develop an equipment management platform, when an equipment IP address changes, the equipment sends the changed IP address to the equipment management platform, and a control platform can acquire the IP address of the equipment to be tested from the equipment management platform.
However, in the related art, a device management platform needs to be developed to acquire the device IP address, which reduces the efficiency of acquiring the IP address and increases the cost of acquiring the IP address. The embodiment of the application provides an IP address query method, a server can search an IP address of a target device according to a physical address of the target device included in a query request sent by a control device, and feed back the IP address of the target device to the control device, so that the control device can control the target device based on the IP address of the target device, the cost of obtaining the IP address is reduced, and the implementation process is convenient and efficient.
Fig. 1 is a schematic structural diagram of an IP address query system according to an embodiment of the present invention, where the IP address query system may include: a control device 101, aserver 102, and a controlleddevice 103.
The communication network among the control device 101, theserver 102 and the controlleddevice 103 is a wide area network, the control device 101 is in communication connection with theserver 102, theserver 102 is in communication connection with the controlleddevice 103, and the control device 101 is in communication connection with the controlleddevice 103. The number of the controlleddevices 103 may be at least one, and when the number of the controlleddevices 103 is plural, each of the controlleddevices 103 is communicatively connected to theserver 102, and each of the controlleddevices 103 is communicatively connected to the control device 101.
In one possible implementation, when the control device 101 detects that the IP address of the controlleddevice 103 changes, the control device 101 determines that the controlleddevice 103 is a target device, and the control device 101 may send an inquiry request to theserver 102, where the inquiry request includes: a physical address of the target device; theserver 102 may receive the query request sent by the control device 101, search for the IP address of the target device according to the physical address of the target device, and then send a query response to the control device 101, where the query response includes: the IP address of the target device; the control device 101 may receive the IP address of the target device transmitted by theserver 102 and may control the target device based on the IP address of the target device.
In practical applications, the control device 101 may be a device with an automatic test function, the target device may be a device to be tested, and the control device 101 may perform an automatic test on the target device based on an IP address of the target device.
It should be noted that theserver 102 in the embodiment of the present application may have a function of allocating an IP address to the target device, for example, theserver 102 may be a DHCP server.
The control device 101 may be a terminal device having a function of controlling the controlleddevice 103, aserver 102 device having a function of controlling the controlleddevice 103, or another electronic device capable of controlling the controlleddevice 103, which is not particularly limited in the embodiment of the present application.
In this embodiment, the controlleddevice 103 may be a network device, aserver 102 on the network, a device capable of accessing the internet, and the like, which have an IP address. For example, the controlleddevice 103 may be: cell phones, laptops, tablets, desktops, switches, routers, and the like.
Fig. 2 is a schematic flowchart of an IP address query method according to an embodiment of the present invention, where the method may be applied to the control device 101 and theserver 102 in the IP address query system shown in fig. 1, and as shown in fig. 2, the method may include:
s201, the control device sends a query request to the server.
Wherein, the query request includes: the physical address of the target device, the query request is used for enabling the server to search the IP address of the target device according to the physical address of the target device.
In some embodiments, the control device may obtain status information of the target device, and when the control device detects that the status information of the target device satisfies a preset condition, may determine a physical address of the target device, generate an inquiry request according to the physical address of the target device, and then send the inquiry request to the server.
It should be noted that, when the control device detects that the state information of the target device satisfies the preset condition, the control device may determine that the IP address of the target device changes, and then the control device needs to obtain the IP address of the target device again, and then the control device may send the query request by the server.
S202, the server receives the query request sent by the control equipment.
Wherein, the query request includes: the physical address of the target device.
In this embodiment of the application, the communication mode between the control device and the server may be a preset communication mode, the control device may send an inquiry request based on the preset communication mode, and the server may receive the inquiry request.
S203, the server searches the IP address of the target device according to the physical address of the target device.
The physical address of the target device may also be referred to as a Media Access control address (MAC address), a local area network address, a MAC address, an ethernet address, and the like.
In some embodiments, the query request is a standard query request of the server, so that the server may directly search the IP address of the target device according to the physical address of the target device in the query request in a preset manner.
It should be noted that the IP address of the target device found above is the IP address newly allocated by the server to the target device, that is, the current IP address applied by the target device.
S204, the server sends a query response to the control equipment.
Wherein the query response includes: and the IP address of the target device is used for enabling the control device to control the target device.
In this embodiment, the server may directly send query information including the IP address of the target device to the control device based on a preset communication manner. In addition, the server can also encrypt the IP address of the target device and then safely transmit the IP address of the target device.
S205, the control device receives the IP address of the target device sent by the server, so as to control the target device according to the IP address of the target device.
After the control device analyzes the query response, the IP address of the target device can be acquired. And when the IP address of the target equipment is the encrypted IP address, the control equipment decrypts the encrypted IP address of the target equipment so as to acquire the IP address of the target equipment.
In a possible implementation manner, the server may send a control command to the target device based on the IP address of the target device, and correspondingly, the target device may receive the control command and execute the control command, thereby implementing the control of the target device by the control device.
For example, in practical applications, the control device may be a device having an automatic test function, the control device may also be referred to as an automatic test platform, the target device may be a device to be tested, and the automatic test platform may perform an automatic test on the device to be tested after acquiring an IP address of the device to be tested.
In summary, an embodiment of the present invention provides an IP address query method, which receives a query request sent by a control device, where the query request includes: a physical address of the target device; searching an IP address of the target equipment according to the physical address of the target equipment; sending an inquiry response to the control device, the inquiry response comprising: and the IP address of the target device is used for enabling the control device to control the target device. For a server, a control device and a target device of which a communication network is a wide area network, when the IP address of the target device is acquired, the server can search the IP address of the target device according to the physical address of the target device in an inquiry request sent by the control device, and send the IP address of the target device to the control device, so that the process of acquiring the IP address of the target device by the control device is more convenient and efficient, a device management platform does not need to be developed, and the cost of acquiring the IP address is reduced.
Moreover, the IP address query method provided in the embodiment of the present application can query the IP address of the target device from the server that allocates the IP address to the target device, that is, can query the IP address of the target device from the source, and can avoid the bottleneck of analysis on each gateway and router. In addition, the IP address query method provided by the embodiment of the application has the advantages of light deployment, extremely small data volume and extremely high concurrent query efficiency.
Optionally, the query request further includes: controlling identification information of a device, fig. 3 is a schematic flowchart of an IP address querying method according to an embodiment of the present invention, and as shown in fig. 3, before the process of S202, the method may further include:
s301, the server determines whether the control equipment is the preset white list equipment or not according to the preset identification information and the identification information of the control equipment.
The server may store at least one preset identification information therein. For example, the at least one preset identification information may be provided in a look-up table.
In a possible implementation manner, after obtaining the query request, the server may obtain identification information of the control device from the query request, and determine whether at least one preset identification information exists, where the preset identification information is the same as the identification information of the control device, and if at least one preset identification information exists, determine that the control device corresponding to the identification information of the control device is a preset white list device.
It should be noted that the identification information of the control device may be a unique identification of the control device, for example, the identification information of the control device may be a fingerprint of the control device. The identification information of the control device may be a character string, a number, or a combination of a character string and a number, which is not specifically limited in the embodiment of the present application.
The process of S202 may include:
s302, if the control device is a white list device, the server searches the IP address of the target device according to the physical address of the target device.
In this embodiment of the application, when the server determines that the control device is a preset white list device, the IP address of the target device may be searched according to the physical address of the target device. When the server determines that the control device is the preset white list device, the server cannot search the IP address of the target device, and the server can also send prompt information to the control device, wherein the prompt information can indicate that the control device is not the white list device and cannot have the authority of searching the IP address of the target device.
In summary, the server determines whether the control device is a preset white list device according to the preset identification information and the identification information of the control device, and if the control device is the white list device, the server searches for the IP address of the target device according to the physical address of the target device. When the control equipment is verified to be the white list equipment, the server searches the IP address of the target equipment according to the physical address of the target equipment sent by the control equipment, verifies the identity of the control equipment, can avoid unnecessary leakage caused by the IP address of the target equipment, and ensures the safety of the IP address of the target equipment.
Optionally, the preset identification information is a preset physical address, the identification information of the control device is a physical address of the control device, and the process of S301 may include:
and the server determines whether the control equipment is white list equipment or not according to the preset physical address and the physical address of the control equipment.
At least one physical address can be preset in the server.
In some embodiments, after obtaining the query request, the server may obtain a physical address of the control device from the query request, determine whether there is a preset physical address that is the same as the physical address of the control device in at least one preset physical address, and determine that the control device corresponding to the physical address of the control device is a preset white list device if there is a preset physical address that is the same as the physical address of the control device in the at least one preset physical address.
In this embodiment of the application, the server may further determine whether the control device is a white list device according to the preset physical address and the physical address of the control device, so that the server may determine whether the control device is a white list more flexibly.
Optionally, the query request includes: and the query command carries the physical address of the target equipment. Fig. 4 is a flowchart illustrating an IP address querying method according to an embodiment of the present invention, and as shown in fig. 4, the process of S202 may include:
s401, the server calls a command query window by adopting a preset application program.
It should be noted that a preset application program may be installed in the server, and after the server verifies that the control device is the blacklisting device, the server may directly call the command query window through the preset application program, so as to implement starting of the command query window in the server.
In the embodiment of the application, the preset application program is adopted to call the command query window, and compared with a remote control call query window, the safety of the call command query window can be improved, and the safety of querying the IP address of the target device is improved. Moreover, the preset application program is adopted to call the command query window, and the server does not need to be logged in according to the login password.
S402, the server executes the query command based on the command query window to search the IP address of the target device.
Wherein the command query window may be a PowerShell (a command line shell and scripting environment) window.
The query command may be a query command of a server standard, and the query command may be in the form of a query Interface, for example, the query command may be an Application Programming Interface (API) query Interface of the server standard.
In some embodiments, the server may execute an API query interface command of the server standard based on the PowerShell window, and find the IP address of the target device according to the physical address of the target device in the API query interface command.
Optionally, fig. 5 is a schematic flowchart of an IP address querying method provided in an embodiment of the present invention, as shown in fig. 5, before S201, the method may further include:
s501, the server receives an address allocation request of the target device.
S502, the server allocates an IP address for the target equipment according to the address allocation request.
Here, the address assignment request may also be referred to as a DHCP request.
In this embodiment of the present application, when the IP address of the target device changes, the target device may send an address allocation request to the server, and the server may receive the address allocation request sent by the target device and allocate an IP address to the target device according to the address allocation request.
Optionally, the process of S201 may include: and if the connection between the target equipment and the control equipment is detected to be disconnected or the control is abnormal, the control equipment sends a query request to the server.
It should be noted that the control device may have an initial IP address of the target device, the control device may control the target device based on the initial IP address of the target device, and when the IP address of the target device changes, the control device may determine that the current state of the target device is a connection drop, or when the control is abnormal, the control device may generate the query request based on a physical address of the target device.
In practical applications, when the lease of the DHCP address pool expires, the network deployment of the target device changes (e.g., network segment replacement), and the network attribute of the target device changes (e.g., switching to the virtual local area network), the IP address of the target device changes.
Optionally, the process of S201 may include: and the control equipment sends a query request to the server in a socket communication mode.
It should be noted that the communication mode of the socket may also be referred to as socket, the socket is an abstraction layer, and the control device may send the query request to the server in the communication mode of the socket, or obtain the query response sent by the server in the communication mode of the socket.
Of course, the server and the control device may also communicate with each other in other communication manners, which is not specifically limited in the embodiment of the present application.
The following describes an IP address query apparatus, a server, a control device, a medium, and the like for executing the IP address query method provided in the present application, and specific implementation processes and technical effects thereof refer to relevant contents of the above parking area risk identification method, which will not be described in detail below.
Fig. 6 is a schematic structural diagram of an IP address querying device according to an embodiment of the present invention, and as shown in fig. 6, the IP address querying device may include:
areceiving module 601, configured to receive an inquiry request sent by a control device, where the inquiry request includes: a physical address of the target device;
a searchingmodule 602, configured to search an IP address of a target device according to a physical address of the target device;
a sendingmodule 603, configured to send an inquiry response to the control device, where the inquiry response includes: and the IP address of the target device is used for enabling the control device to control the target device.
Optionally, the query request further includes: control the identification information of the device, the apparatus further comprising:
the determining module is used for determining whether the control equipment is preset white list equipment or not according to the preset identification information and the identification information of the control equipment;
the searchingmodule 602 is further configured to search, if the control device is a white list device, an IP address of the target device according to the physical address of the target device.
Optionally, the preset identification information is a preset physical address, and the identification information of the control device is a physical address of the control device; and the determining module is further used for determining whether the control equipment is the white list equipment or not according to the preset physical address and the physical address of the control equipment.
Optionally, the query request includes: the query command carries the physical address of the target equipment; the searchingmodule 602 is further configured to query the window by using a preset application program call command; based on the command query window, a query command is executed to find the IP address of the target device.
Optionally, the apparatus further comprises:
the first receiving module is used for receiving an address allocation request of target equipment;
and the allocation module is used for allocating the IP address to the target equipment according to the address allocation request.
Fig. 7 is a schematic structural diagram of an IP address querying device according to an embodiment of the present invention, and as shown in fig. 7, the IP address querying device may include:
a sendingmodule 701, configured to send a query request to a server, where the query request includes: the inquiry request is used for enabling the server to search the IP address of the target equipment according to the physical address of the target equipment;
areceiving module 702, configured to receive an IP address of a target device sent by a server, so as to control the target device according to the IP address of the target device.
Optionally, the sendingmodule 701 is further configured to send, if it is detected that the connection between the target device and the control device is disconnected or the control is abnormal, an inquiry request to the server.
Optionally, the sendingmodule 701 is further configured to send the query request to the server in a socket communication manner.
The above-mentioned apparatus is used for executing the method provided by the foregoing embodiment, and the implementation principle and technical effect are similar, which are not described herein again.
These above modules may be one or more integrated circuits configured to implement the above methods, such as: one or more Application Specific Integrated Circuits (ASICs), or one or more microprocessors (DSPs), or one or more Field Programmable Gate Arrays (FPGAs), among others. For another example, when one of the above modules is implemented in the form of a processing element scheduler code, the processing element may be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 8 is a schematic structural diagram of a server according to an embodiment of the present invention, and as shown in fig. 8, the server includes: aprocessor 801 and amemory 802.
Thememory 802 is used for storing programs, and theprocessor 801 calls the programs stored in thememory 802 to execute the above-mentioned method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
Fig. 9 is a schematic structural diagram of a control device according to an embodiment of the present invention, and as shown in fig. 9, the server includes: aprocessor 901, amemory 902.
Thememory 902 is used for storing programs, and theprocessor 901 calls the programs stored in thememory 902 to execute the above method embodiments. The specific implementation and technical effects are similar, and are not described herein again.
Optionally, the present invention also provides a program product, such as a computer readable storage medium, comprising a program which, when executed by a processor, is adapted to perform the method embodiments described in any of the above fig. 2 to 5.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. 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.
The 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 invention 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, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: a U disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.