CN115514735B - Method and device for acquiring real IP address of server and storage medium - Google Patents

Method and device for acquiring real IP address of server and storage medium Download PDF

Info

Publication number
CN115514735B
CN115514735B CN202211463087.7A CN202211463087A CN115514735B CN 115514735 B CN115514735 B CN 115514735B CN 202211463087 A CN202211463087 A CN 202211463087A CN 115514735 B CN115514735 B CN 115514735B
Authority
CN
China
Prior art keywords
address
server
real
network card
acquiring
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
CN202211463087.7A
Other languages
Chinese (zh)
Other versions
CN115514735A (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.)
Guangdong Baolun Electronics Co ltd
Original Assignee
Guangzhou Baolun Electronics 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 Guangzhou Baolun Electronics Co Ltd filed Critical Guangzhou Baolun Electronics Co Ltd
Priority to CN202211463087.7A priority Critical patent/CN115514735B/en
Publication of CN115514735A publication Critical patent/CN115514735A/en
Application granted granted Critical
Publication of CN115514735B publication Critical patent/CN115514735B/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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/163In-band adaptation of TCP data exchange; In-band control procedures

Abstract

The invention discloses a method, a device and a storage medium for acquiring a real IP address of a server, wherein the method comprises the following steps: after a client searches a service communication port of a server in a preset search format, acquiring first network card information of all physical network cards connected with the server; according to the first network card information, selecting any one physical network card as a first physical network card, and acquiring an IP address of the first physical network card as a real IP address of the server; if the IP address of the first physical network card fails to be acquired, detecting whether IP conflicts exist between a plurality of preset first IP addresses and a local area network connected with the first physical network card or not until an IP address which does not conflict with the local area network connected with the first physical network card is detected and used as a real IP address of the server; the real IP address and the corresponding port thereof are output through the client loopback port, the automation of IP acquisition and configuration is realized, and the error rate of real IP identification and configuration of the server is reduced.

Description

Method and device for acquiring real IP address of server and storage medium
Technical Field
The invention relates to the technical field of internet data access, in particular to a method and a device for acquiring a real IP address of a server and a storage medium.
Background
When an existing WEB site builds a WEB HTTP service, if a server is configured with a plurality of network cards or a virtual machine is installed, the WEB site server has a plurality of IP addresses, and an existing IP address acquisition mode needs an operation and maintenance worker or a developer to manually install and set configuration information of the WEB HTTP and the TCP service. The manual configuration and IP address acquisition method not only has tedious process at the client and wastes manpower and material resources, but also has complex configuration between the client and the server, and is prone to cause the problem of server IP address configuration error.
Disclosure of Invention
The invention provides a method, a device and a storage medium for acquiring a real IP address of a server, which are used for automatically identifying the real IP address of the server and connecting the real IP address with a corresponding port, realizing the automation of IP acquisition and configuration and reducing the error rate of the identification and configuration of the real IP of the server.
In order to realize the automation of real IP acquisition and reduce the error rate of real IP identification of a server, the embodiment of the invention provides a method for acquiring the real IP address of the server, which comprises the steps of searching a service communication port of the server in a preset search format at a client, and acquiring first network card information of all physical network cards connected with the server;
according to the first network card information, selecting any one physical network card as a first physical network card, and acquiring the IP address of the first physical network card as the real IP address of the server;
if the IP address of the first physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses have IP conflicts with the current local area network or not until an IP address which does not have conflicts with the current local area network is detected and used as a real IP address of the server;
and outputting the real IP address of the server and the corresponding port thereof through a client loopback port.
As a preferred scheme, in the method for acquiring the real IP address of the address server, under the condition that the server is configured with a plurality of network cards, the method can effectively filter the IP address of the virtual network card, acquire the network card information of the physical network card, and acquire the IP address of any one of the physical network cards as the real IP address of the server; if the IP address of the physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses conflict with the current local area network or not until an IP address which does not conflict with the current local area network is detected and taking the IP address as a real IP address of the server; the real IP address can be quickly and automatically acquired without manual configuration of a client and running back and forth among different IP floors, so that the steps of acquiring the IP address of the server are simplified, and the error rate of real IP identification of the server is reduced.
As a preferred scheme, before the client searches for the service communication port of the server in a preset search format, the method further includes:
starting UDP service of the server, setting common headers of UDP of the server and the client, setting search format of UDP of the server, and setting service communication port and client loopback port of UDP of the server.
As a preferred scheme, the method for acquiring the real IP address of the address server comprises the steps that the client and the server agree on the common header of the UDP, the server is prevented from transmitting the IP information of the server to other places, the communication ports of the client and the server and the client loopback port are arranged, so that the client can search the service communication port of the server in a preset search format, required data are acquired from the client loopback port, the confidentiality of the information is improved due to the agreement of the common header of the UDP and the arrangement of the UDP port of the server, and the error rate of real IP identification of the server is reduced.
As a preferred scheme, the obtaining of the first network card information of all physical network cards connected to the server specifically includes:
the method comprises the steps of obtaining network card information of all network cards connected with a server, inquiring whether all network cards connected with the server point to a virtual interface or not, deleting the network card information pointing to the virtual interface, and reserving the network card information not pointing to the virtual interface to obtain first network card information.
As a preferred scheme, in the method for acquiring the real IP address of the address server, the virtual network card does not have the real IP address, so that all network cards connected with the server need to be filtered, the virtual network card is deleted, and the error rate of real IP identification of the server is reduced.
As a preferred scheme, the detecting step of sequentially detecting whether IP conflicts exist between a plurality of preset first IP addresses and a current local area network until an IP address which does not conflict with the current local area network is detected as a real IP address of a server specifically comprises:
sequentially inquiring whether each first IP address can receive data in the current local area network by using a rap broadcast packet;
if the first IP address can receive data, the first IP address conflicts with the current local area network, and whether the next first IP address can receive data in the current local area network is inquired;
and if the first IP address cannot receive the data, the first IP address does not conflict with the current local area network, the query is stopped, and the first IP address is used as the real IP address of the server.
As a preferred scheme, the method for acquiring the real IP address of the server according to the present invention detects whether IP conflicts exist between a plurality of preset first IP addresses and the current local area network or not under the condition that the IP address acquisition of the physical network card fails, until an IP address that does not conflict with the current local area network is detected, the detected IP address serves as the real IP address of the server; the server can automatically identify the real IP address, so that the identification process of the real IP address is simplified, and the error rate of the real IP identification of the server is reduced.
Correspondingly, the invention also provides a method for connecting the real IP address of the server, which comprises the steps of obtaining the real IP address and the corresponding port thereof by using the method for obtaining the real IP address of the server;
judging a transmission protocol to be used by the real IP address of the server; the transport protocols include HTTP and TCP;
and requesting HTTP service or TCP service according to the transmission protocol, and establishing connection with the real IP address of the server.
As a preferred scheme, most of the existing communication is based on an HTTP protocol and a TCP protocol, so that a transmission protocol to be used by a real IP address of a server is judged; the transport protocols include HTTP and TCP; the real IP address of the server and the corresponding port of the server are output to the client through the client loopback port, so that the client can acquire the real IP address, the TCP address and the corresponding port, automatically request HTTP service and TCP service, realize the communication between the server and the client, realize that the server automatically configures the real IP address through the corresponding port, simplify the configuration between the client and the server, and reduce the error rate of the real IP configuration of the server. The local area network can realize the automatic identification of the real IP address by the server and the communication between the server and the client even if the IP needs to be re-planned and the real IP address of the server with multiple network cards is re-inquired and fixed.
Correspondingly, the invention also provides a device for acquiring the real IP address of the server, which comprises: the device comprises an acquisition module, an identification module and an output module;
the acquisition module is used for acquiring first network card information of all physical network cards connected with the server after a client searches a service communication port of the server in a preset search format;
the identification module is used for selecting any one physical network card as a first physical network card according to the first network card information, acquiring the IP address of the first physical network card and taking the IP address as the real IP address of the server;
if the IP address of the first physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses have IP conflicts with the current local area network or not until an IP address which does not have conflicts with the current local area network is detected and used as a real IP address of the server;
the output module is used for outputting the real IP address of the server and the corresponding port thereof through a client loopback port.
As a preferred scheme, the device for acquiring a real IP address of an address server provided by the present invention can effectively filter an IP address of a virtual network card, acquire network card information of a physical network card, and acquire an IP address of any one of the physical network cards as a real IP address of the server, in a case that the server is configured with a plurality of network cards; if the IP address of the physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses conflict with the current local area network or not until an IP address which does not conflict with the current local area network is detected and taking the IP address as a real IP address of the server; the real IP address can be quickly and automatically acquired without manual configuration of a client and running back and forth among different IP floors, so that the steps of acquiring the IP address of the server are simplified, and the error rate of real IP identification of the server is reduced.
As the preferred scheme, also include the port and dispose the module;
the port configuration module is used for starting UDP service of the server, setting common headers of UDP of the server and the client, setting search format of UDP of the server, and setting a service communication port of UDP of the server and a loopback port of the client.
As a preferred scheme, the apparatus for obtaining the real IP address of the address server provided by the present invention further comprises a port configuration module; the client and the server agree on a common header of UDP to avoid the server from transmitting own IP information to other places, and a communication port of the client and the server and a client loopback port are arranged to enable the client to search a service communication port of the server in a preset search format, so that required data can be acquired from the client loopback port.
The acquisition module comprises a screening unit;
the screening unit is used for acquiring network card information of all network cards connected with the server, inquiring whether all network cards connected with the server point to the virtual interface or not, deleting the network card information pointing to the virtual interface, and reserving the network card information not pointing to the virtual interface to obtain first network card information.
As a preferred scheme, under the condition that the server is provided with a plurality of network cards, the screening unit can effectively filter the IP address of the virtual network card and acquire the network card information of the physical network card, so that the step of acquiring the IP address of the server is simplified, and the error rate of real IP identification of the server is reduced.
Preferably, the identification module comprises a query unit;
the query unit is used for sequentially querying whether each first IP address can receive data in the current local area network by using a rap broadcast packet;
if the first IP address can receive data, the first IP address conflicts with the current local area network, and whether the next first IP address can receive data in the current local area network is inquired;
and if the first IP address cannot receive the data, the first IP address does not conflict with the current local area network, the query is stopped, and the first IP address is used as the real IP address of the server.
As a preferred scheme, under the condition that the IP address of the physical network card fails to be acquired, detecting whether a plurality of preset first IP addresses conflict with the current local area network or not through a query unit until an IP address which does not conflict with the current local area network is detected and used as a real IP address of a server; the server can automatically identify the real IP address, so that the identification process of the real IP address is simplified, and the error rate of the real IP identification of the server is reduced.
Accordingly, the present invention also provides a computer readable storage medium comprising a stored computer program; wherein, the computer program controls the device where the computer readable storage medium is located to execute the method for acquiring the real IP address of the address server according to the present invention.
Drawings
Fig. 1 is a schematic flowchart of an embodiment of a method for acquiring a real IP address of a server according to the present invention;
fig. 2 is a flowchart illustrating an embodiment of a method for connecting a real IP address of a server according to the present invention;
fig. 3 is a schematic structural diagram of an apparatus for acquiring a real IP address of a server according to an embodiment of the present invention.
Detailed Description
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 only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
Example one
Referring to fig. 1, a method for acquiring a real IP address of a server according to an embodiment of the present invention includes steps S101 to S104:
step S101: after a client searches a service communication port of a server in a preset search format, first network card information of all physical network cards connected with the server is acquired.
In this embodiment, before the client searches for the service communication port of the server in the preset search format, the method further includes:
starting UDP service of the server, setting common headers of UDP of the server and the client, setting search format of UDP of the server, and setting service communication port and client loopback port of UDP of the server.
In this embodiment, a client starts a server UDP service based on a paperless terminal, sets a service communication port of UDP to 9090, sets a client loopback port to 9091, and sets a common header of the server and the client agreed UDP to be { get _ server _ ip _ port, get _ server _ tcp _ port };
the search format of the server UDP is set as follows: { [ server _ ip: 'ip address' ], [ server _ port: port ], [ tcp _ ip: 'ip address' ], [ tcp _ port: port ] };
the client searches a local area network server UDP port 9090 by using the search format UDP based on the paperless terminal.
In this embodiment, the obtaining of the first network card information of all the physical network cards connected to the server specifically includes:
and inquiring whether all network cards connected with the server point to the virtual interface or not, deleting the network card information pointing to the virtual interface, and reserving the network card information not pointing to the virtual interface to obtain the first network card information.
In this embodiment, the server decompresses the PHP runtime, and issues the following instructions in the/proc/net/dev directory by the shell command: and ls/sys/devices/virtual/net, wherein the information of all network cards is passed through, if the network card points to the virtual interface, the network card is judged to be the virtual network card, the network card information of the virtual network card is deleted, if the network card does not point to the virtual interface, the network card is judged to be the physical network card, and the network card information of the physical network card is reserved to obtain the information of the first network card.
Step S102: and according to the first network card information, selecting any one of the physical network cards as a first physical network card, and acquiring the IP address of the first physical network card as the real IP address of the server.
Exemplarily, inquiring information of all the first network cards, and if 4 physical network cards exist, respectively identifying the 4 physical network cards as a first network card, a second network card, a third network card and a fourth network card; selecting any one physical network card, such as a first network card, detecting the IP address allocated by the local area network of the IP address of the first network card by using a shell command, acquiring the IP address of the first network card, storing the IP address in a database, and using the IP address as the real IP address of the server, namely the real IP address of the server and the client communication.
Step S103: if the IP address of the first physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses conflict with the current local area network or not until an IP address which does not conflict with the current local area network is detected and taking the IP address as a real IP address of the server.
In this embodiment, if the IP address of the first physical network card fails to be obtained, it is detected whether an IP address between 192.168.19.130-192.168.19.140 has an IP conflict with the current local area network, until an IP address having no conflict with the current local area network is detected, which is used as the real IP address of the server.
In this embodiment, a rap broadcast packet is used to sequentially query whether each first IP address can receive data in the current local area network;
if the first IP address can receive data, the first IP address conflicts with the current local area network, and whether the next first IP address can receive data in the current local area network is inquired;
and if the first IP address cannot receive the data, the first IP address does not conflict with the current local area network, the query is stopped, and the first IP address is used as the real IP address of the server.
Illustratively, if the shell command cannot detect the IP address allocated by the DHCP, 192.168.19.130 is used as the server IP address, the rap broadcast packet is used to check whether the current IP address can receive data in the current lan, if so, the IP collision occurs, 192.168.19.131 is used as the server IP address, the rap broadcast packet is used to check whether the current IP address can receive data in the current lan, if not, the next IP address does not need to be detected, and 192.168.19.131 is used as the real IP address of the server.
Step S104: and outputting the real IP address of the server and the corresponding port thereof through a client loopback port.
In this embodiment, after the client searches the service communication port 9090 of the lan server in the paperless terminal using the UDP as the search format, the server can automatically identify and return the real IP address, and the client receives the real IP address and the corresponding port sent by the server at the client loopback port 9091.
The embodiment of the invention has the following effects:
according to the method for acquiring the real IP address of the server, under the condition that the server is provided with the plurality of network cards, the method can effectively filter the IP address of the virtual network card, acquire the network card information of the physical network card and acquire the IP address of any one physical network card as the real IP address of the server; if the IP address of the physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses conflict with the current local area network or not until an IP address which does not conflict with the current local area network is detected and taking the IP address as a real IP address of the server; the real IP address can be quickly and automatically acquired without manual configuration of a client and running back and forth between different IP floors, so that the step of acquiring the server IP address is simplified, and the error rate of real IP identification of the server is reduced.
Example two
Referring to fig. 2, the present invention further provides a method for connecting a real IP address of a server, which includes the following steps S201 to S203:
step S201: the method for acquiring the real IP address of the address server of the embodiment of the method is used for acquiring the real IP address and the corresponding port thereof;
step S202: judging a transmission protocol to be used by the real IP address of the server; the transport protocols include HTTP and TCP;
step S203: and requesting HTTP service or TCP service according to the transmission protocol, and establishing connection with the real IP address of the server.
Exemplarily, the method for acquiring the real IP address of the address server according to the above method embodiment is used to acquire the real IP address and the corresponding port thereof;
and if the real IP address and the corresponding port are judged to be the HTTP address and the port, that is, only the HTTP is needed to access the server resource, requesting HTTP service and establishing connection with the real IP address of the server.
And if the real IP address and the corresponding port are judged to be the TCP address and the TCP port, namely the TCP is used for accessing the server resource, the TCP service is requested, and the connection is established with the real IP address of the server.
The embodiment of the invention has the following effects:
most of the existing communication is based on an HTTP protocol and a TCP protocol, so that a transmission protocol used by a real IP address of a server is judged; the transport protocols include HTTP and TCP; the real IP address of the server and the corresponding port thereof are output to the client through the client loopback port so that the client can acquire the real IP address, the TCP address and the corresponding port to automatically request HTTP service and TCP service, the communication between the server and the client is realized, the server can automatically configure the real IP address through the corresponding port, the configuration between the client and the server is simplified, and the error rate of the real IP configuration of the server is reduced. The local area network can realize the automatic identification of the real IP address by the server and the communication between the server and the client even if the IP needs to be re-planned and the real IP address of the server with multiple network cards is re-inquired and fixed.
EXAMPLE III
Referring to fig. 3, an apparatus for acquiring a real IP address of an address server according to an embodiment of the present invention includes: an acquisition module 301, an identification module 302 and an output module 303;
the obtaining module 301 is configured to obtain first network card information of all physical network cards connected to the server after the client searches a service communication port of the server in a preset search format;
the identification module 302 is configured to select any one of the physical network cards as a first physical network card according to the first network card information, and acquire an IP address of the first physical network card as a real IP address of the server;
if the IP address of the first physical network card fails to be acquired, sequentially detecting whether IP conflicts exist between a plurality of preset first IP addresses and the current local area network or not until an IP address which does not conflict with the current local area network is detected and used as a real IP address of the server;
the output module 303 is configured to output the real IP address of the server and the corresponding port thereof through a client loopback port.
In this embodiment, the system further includes a port configuration module;
the port configuration module is used for starting UDP service of the server, setting common headers of UDP of the server and the client, setting search format of UDP of the server, and setting a service communication port of UDP of the server and a loopback port of the client.
The acquisition module comprises a screening unit;
the screening unit is used for acquiring network card information of all network cards connected with the server, inquiring whether all network cards connected with the server point to the virtual interface or not, deleting the network card information pointing to the virtual interface, and reserving the network card information not pointing to the virtual interface to obtain first network card information.
The detection module comprises a query unit;
the query unit is used for sequentially querying whether each first IP address can receive data in the current local area network by using rap broadcast packets;
if the first IP address can receive data, the first IP address conflicts with the current local area network, and whether the next first IP address can receive data in the current local area network is inquired;
and if the first IP address cannot receive the data, the first IP address does not conflict with the current local area network, the query is stopped, and the first IP address is used as the real IP address of the server.
The device for acquiring the real IP address of the address server may implement the method for acquiring the real IP address of the address server in the above method embodiment. The alternatives in the above-described method embodiments are also applicable to this embodiment and will not be described in detail here. The rest of the embodiments of the present application may refer to the contents of the above method embodiments, and in this embodiment, details are not repeated.
The embodiment of the invention has the following effects:
according to the device for acquiring the real IP address of the address server, provided by the invention, under the condition that the server is provided with a plurality of network cards, the method can effectively filter the IP address of the virtual network card, acquire the network card information of the physical network card and acquire the IP address of any one physical network card as the real IP address of the server; if the IP address of the physical network card fails to be acquired, sequentially detecting whether IP conflicts exist between a plurality of preset first IP addresses and the current local area network or not until an IP address which does not conflict with the current local area network is detected and used as a real IP address of the server; the real IP address can be quickly and automatically acquired without manual configuration of a client and running back and forth among different IP floors, so that the steps of acquiring the IP address of the server are simplified, and the error rate of real IP identification of the server is reduced.
Example four
Correspondingly, the present invention further provides a computer-readable storage medium, where the computer-readable storage medium includes a stored computer program, where when the computer program runs, the apparatus where the computer-readable storage medium is located is controlled to execute the method for acquiring a real IP address of an address server according to any one of the above embodiments.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory and executed by the processor to implement the invention. The one or more modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used for describing the execution process of the computer program in the terminal device.
The terminal device can be a desktop computer, a notebook, a palm computer, a cloud server and other computing devices. The terminal device may include, but is not limited to, a processor, a memory.
The Processor 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 or the processor may be any conventional processor or the like, said processor being the control center of said terminal device, and various interfaces and lines are used to connect the various parts of the whole terminal device.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the terminal device by running or executing the computer programs and/or modules stored in the memory and calling data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the mobile terminal, and the like. In addition, the memory may include high speed random access memory, and may also include non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), at least one magnetic disk storage device, a Flash memory device, or other volatile solid state storage device.
Wherein, the terminal device integrated module/unit can be stored in a computer readable storage medium if it is implemented in the form of software functional unit and sold or used as an independent product. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. 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 the computer program code, recording medium, U.S. disk, removable hard disk, magnetic diskette, optical disk, computer Memory, read-Only Memory (ROM), random Access Memory (RAM), electrical carrier wave signal, telecommunications signal, and software distribution medium, etc.
The above-mentioned embodiments are provided to further explain the objects, technical solutions and advantages of the present invention in detail, and it should be understood that the above-mentioned embodiments are only examples of the present invention and are not intended to limit the scope of the present invention. It should be understood that various changes, substitutions and alterations can be made herein without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (10)

1. A method for acquiring a real IP address of a server is characterized by comprising the following steps:
after a client searches a service communication port of a server in a preset search format, acquiring first network card information of all physical network cards connected with the server;
according to the first network card information, selecting any one physical network card as a first physical network card, and acquiring the IP address of the first physical network card as the real IP address of the server;
if the IP address of the first physical network card fails to be acquired, sequentially detecting whether a plurality of preset first IP addresses have IP conflicts with the current local area network or not until an IP address which does not have conflicts with the current local area network is detected and used as a real IP address of the server;
and outputting the real IP address of the server and the corresponding port thereof through a client loopback port.
2. The method as claimed in claim 1, wherein before the client searches the service communication port of the server in the preset search format, the method further comprises:
starting UDP service of a server, setting common headers of UDP of the server and a client, setting search format of UDP of the server, and setting a service communication port of UDP of the server and a client loopback port.
3. The method for acquiring the real IP address of the server according to claim 1, wherein the acquiring the first network card information of all the physical network cards connected to the server specifically includes:
the method comprises the steps of obtaining network card information of all network cards connected with a server, inquiring whether all network cards connected with the server point to a virtual interface or not, deleting the network card information pointing to the virtual interface, and reserving the network card information not pointing to the virtual interface to obtain first network card information.
4. The method as claimed in claim 1, wherein the step of sequentially detecting whether IP conflicts exist between the preset first IP addresses and the current lan until an IP address with no IP conflict with the current lan is detected is specifically performed as the real IP address of the server:
sequentially inquiring whether each first IP address can receive data in the current local area network by using a rap broadcast packet;
if the first IP address can receive data, the first IP address conflicts with the current local area network, and whether the next first IP address can receive data in the current local area network is inquired;
and if the first IP address cannot receive the data, the first IP address does not conflict with the current local area network, the query is stopped, and the first IP address is used as the real IP address of the server.
5. A method for connecting a real IP address of a server, comprising:
acquiring the real IP address and the corresponding port thereof by using the acquisition method of the real IP address of the server as claimed in any one of claims 1 to 4;
judging a transmission protocol to be used by the real IP address of the server; the transport protocols include HTTP and TCP;
and establishing connection with the real IP address of the server according to the HTTP service or the TCP service requested by the transmission protocol.
6. An apparatus for obtaining a real IP address of an address server, comprising: the device comprises an acquisition module, an identification module and an output module;
the acquisition module is used for acquiring first network card information of all physical network cards connected with the server after a client searches a service communication port of the server in a preset search format;
the identification module is used for selecting any one physical network card as a first physical network card according to the first network card information, acquiring the IP address of the first physical network card and taking the IP address as the real IP address of the server;
if the IP address of the first physical network card fails to be acquired, sequentially detecting whether IP conflicts exist between a plurality of preset first IP addresses and the current local area network or not until an IP address which does not conflict with the current local area network is detected and used as a real IP address of the server;
and the output module is used for outputting the real IP address of the server and the corresponding port thereof through a client loopback port.
7. The apparatus for acquiring the real IP address of the address server as claimed in claim 6, further comprising a port configuration module;
the port configuration module is used for starting UDP service of the server, setting common headers of UDP of the server and the client, setting search format of UDP of the server, and setting a service communication port of UDP of the server and a loopback port of the client.
8. The apparatus for acquiring true IP address of address server of claim 6, wherein the acquiring module comprises a screening unit;
the screening unit is used for acquiring network card information of all network cards connected with the server, inquiring whether all network cards connected with the server point to the virtual interface or not, deleting the network card information pointing to the virtual interface, and reserving the network card information not pointing to the virtual interface to acquire the first network card information.
9. The apparatus for acquiring real IP address of address server of claim 6, wherein the identification module comprises a query unit;
the query unit is used for sequentially querying whether each first IP address can receive data in the current local area network by using rap broadcast packets;
if the first IP address can receive data, the first IP address conflicts with the current local area network, and whether the next first IP address can receive data in the current local area network is inquired;
and if the first IP address cannot receive the data, the first IP address does not conflict with the current local area network, the query is stopped, and the first IP address is used as the real IP address of the server.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored computer program; wherein the computer program controls, when running, an apparatus in which the computer readable storage medium is located to execute a method for acquiring a real IP address of a server according to any one of claims 1 to 4.
CN202211463087.7A 2022-11-22 2022-11-22 Method and device for acquiring real IP address of server and storage medium Active CN115514735B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211463087.7A CN115514735B (en) 2022-11-22 2022-11-22 Method and device for acquiring real IP address of server and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211463087.7A CN115514735B (en) 2022-11-22 2022-11-22 Method and device for acquiring real IP address of server and storage medium

Publications (2)

Publication Number Publication Date
CN115514735A CN115514735A (en) 2022-12-23
CN115514735B true CN115514735B (en) 2023-03-14

Family

ID=84514285

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211463087.7A Active CN115514735B (en) 2022-11-22 2022-11-22 Method and device for acquiring real IP address of server and storage medium

Country Status (1)

Country Link
CN (1) CN115514735B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108347472A (en) * 2018-01-12 2018-07-31 网宿科技股份有限公司 Configuration method, Cloud Server, cloud platform and the readable storage medium storing program for executing of IP address
CN109921930A (en) * 2019-02-27 2019-06-21 苏州浪潮智能科技有限公司 A kind of method and device that more network interface card IP address are set automatically
CN110933191A (en) * 2019-10-18 2020-03-27 深圳市元征科技股份有限公司 IP address obtaining method and device, upper computer and storage medium

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102281180A (en) * 2011-07-14 2011-12-14 冶金自动化研究设计院 Virtual network interface card (NIC) communication device applied in mutual communication of terminals in different local area networks
CN103067290B (en) * 2012-11-30 2016-06-01 成都卫士通信息产业股份有限公司 The VPN tunnel implementation of load balancing network is adapted to based on virtual network interface card
CN104468304B (en) * 2013-09-22 2018-07-03 华为技术有限公司 A kind of method of pond elementary state synchronizing information, pond Register and pond element
CA2867589A1 (en) * 2013-10-15 2015-04-15 Coho Data Inc. Systems, methods and devices for implementing data management in a distributed data storage system
US11394685B2 (en) * 2016-05-27 2022-07-19 Walmart Apollo, Llc Systems and methods of database instance container deployment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108347472A (en) * 2018-01-12 2018-07-31 网宿科技股份有限公司 Configuration method, Cloud Server, cloud platform and the readable storage medium storing program for executing of IP address
CN109921930A (en) * 2019-02-27 2019-06-21 苏州浪潮智能科技有限公司 A kind of method and device that more network interface card IP address are set automatically
CN110933191A (en) * 2019-10-18 2020-03-27 深圳市元征科技股份有限公司 IP address obtaining method and device, upper computer and storage medium

Also Published As

Publication number Publication date
CN115514735A (en) 2022-12-23

Similar Documents

Publication Publication Date Title
CN107809383B (en) MVC-based path mapping method and device
CN111460460B (en) Task access method, device, proxy server and machine-readable storage medium
CN110908770A (en) Operation and creation method of virtual machine, virtual machine and virtual machine management platform
CN103346974A (en) Controlling method of service process and network device
CN112235175B (en) Access method and access device of network bridge equipment and network bridge equipment
CN104572372A (en) System and method for building server performance testing environment
CN110677405A (en) Data processing method and device, electronic equipment and storage medium
CN107547274B (en) Multi-network-port aggregation method and device
CN113434249A (en) Mirror image synchronization method and device, docker host and storage medium
CN111008254A (en) Object creating method and device, computer equipment and storage medium
CN115514735B (en) Method and device for acquiring real IP address of server and storage medium
CN115333933B (en) Automatic management method, medium and equipment for servers on machine room
CN111988446B (en) Message processing method and device, electronic equipment and storage medium
CN110858846A (en) Resource allocation method, device and storage medium
CN112399378B (en) Internet of vehicles-based over-the-air downloading method, system, equipment and medium
CN114979286A (en) Access control method, device and equipment for container service and computer storage medium
CN114827115A (en) Access method and device of Web service in container, electronic equipment and storage medium
CN114356456A (en) Service processing method, device, storage medium and electronic equipment
CN111565176B (en) Intelligent disguising host method, system, device and readable storage medium
CN114244555A (en) Method for adjusting security policy
CN113904871A (en) Network slice access method, PCF entity, terminal and communication system
CN111614790B (en) Virtual machine address configuration system, method and device
CN115643576A (en) Method, device, system, device and storage medium for controlling terminal to access network
CN113691575A (en) Communication method, device and system
CN111338758A (en) Resource management method and device and electronic equipment

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
CP03 Change of name, title or address
CP03 Change of name, title or address

Address after: No. 56 Nanli East Road, Shiqi Town, Panyu District, Guangzhou City, Guangdong Province, 510000

Patentee after: Guangdong Baolun Electronics Co.,Ltd.

Address before: No.19 Chuangyuan Road, Zhongcun street, Panyu District, Guangzhou, Guangdong 510000

Patentee before: GUANGZHOU ITC ELECTRONIC TECHNOLOGY Co.,Ltd.