CN113794703A - Method for acquiring client IP in load balancing system - Google Patents

Method for acquiring client IP in load balancing system Download PDF

Info

Publication number
CN113794703A
CN113794703A CN202111010992.2A CN202111010992A CN113794703A CN 113794703 A CN113794703 A CN 113794703A CN 202111010992 A CN202111010992 A CN 202111010992A CN 113794703 A CN113794703 A CN 113794703A
Authority
CN
China
Prior art keywords
client
server
real
load balancer
load balancing
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.)
Pending
Application number
CN202111010992.2A
Other languages
Chinese (zh)
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.)
Shanghai Hongji Information Technology Co Ltd
Original Assignee
Shanghai Hongji Information Technology 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 Shanghai Hongji Information Technology Co Ltd filed Critical Shanghai Hongji Information Technology Co Ltd
Priority to CN202111010992.2A priority Critical patent/CN113794703A/en
Publication of CN113794703A publication Critical patent/CN113794703A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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
    • 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/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • 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/06Notations for structuring of protocol data, e.g. abstract syntax notation one [ASN.1]
    • 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/22Parsing or analysis of headers

Abstract

The invention discloses a method for obtaining client IP in a load balancing system, which enables a server to obtain a real client IP address under the condition of using a load balancer, thereby enabling services needing to use the client IP to work normally; the method and the device solve the problem that the client IP address is converted into the load balancer IP due to the use of the load balancer, so that the client IP address cannot be acquired, and further the loss is caused.

Description

Method for acquiring client IP in load balancing system
Technical Field
The invention relates to the technical field of load balancing, in particular to a method for acquiring a client IP in a load balancing system.
Background
Load balancing is a key component of the highly available network infrastructure, and is typically used to distribute workload across multiple servers to improve the performance and reliability of a website, application, database, or other service. Currently, if a user is directly connected to a web server, the user naturally has no way to access the web server if the server is down. In addition, if many users attempt to access the server at the same time, beyond the limit they can handle, slow loading or no connection at all may occur.
This failure can be mitigated by introducing a load balancer and additional web servers. Typically, all backend servers will guarantee the same content to be provided so that the user receives consistent content regardless of which server responds. The load is shared by the additional multiple web servers, so that the pressure of a single web server is relieved, and more user requests are processed; the load balancing device may be software or a dedicated hardware device.
IP Address (english: IP Address) is a string of numbers in Internet Protocol (Internet Protocol) used to identify a device that transmits or receives a datagram.
IP addresses consist of 32-bit binary numbers and are often represented for ease of use in the form xxx.xxx.xxx.xxx.xxx.xxx, each group XXX representing a 10-ary number less than or equal to 255, this representation being referred to as dot decimal.
In the existing load balancing system process, a source address in a data packet received by a real server is a load balancer IP, while in practical application, some services need to obtain a real client IP address, but due to the use of the load balancer, the client IP address is converted into the load balancer IP, so that the services cannot be obtained, and further the services fail. Therefore, a method for acquiring the client IP in the load balancing system becomes a problem to be solved urgently.
Disclosure of Invention
The technical problem to be solved by the invention is a method for acquiring a client IP in a load balancing system.
In order to solve the above technical problems, the technical solution provided by the present invention is a method for obtaining a client IP in a load balancing system, comprising the following steps:
the method comprises the following steps: when a data packet sends a request from a client to reach a load balancer, the load balancer extracts a real client IP address from the data packet, and records the real client IP address as a method for acquiring a client IP in a load balancing system, B, C and D;
step two: converting the method B, C and D for acquiring the client IP in the load balancing system into 4 bytes which are respectively marked as h1, h2, h3 and h 4;
step three: constructing 8-byte data, and inserting the 8-byte data into a TCP option field in a data packet sent to a real server according to a certain format;
step four: the real server receives the data packet, analyzes the TCP option field, and extracts h1, h2, h3 and h4 according to a preset format;
step five: and the real server restores the real client IP according to h1, h2, h3 and h 4.
As an improvement, the data format of the 8 bytes is: 0x1c, 0x07, 0x01, h1, h2, h3, h4, 0x 01.
As an improvement, a server pool is configured on the load balancer in advance, and a plurality of servers are contained in the server pool.
As an improvement, after the request of the client reaches the load balancer, the load balancer may select any server from the service pool, and forward the request to the server for processing.
Compared with the prior art, the invention has the advantages that: under the condition of using the load balancer, the invention enables the server to obtain the real IP address of the client, thereby enabling the service needing to use the IP of the client to work normally; the method and the device solve the problem that the client IP address is converted into the load balancer IP due to the use of the load balancer, so that the client IP address cannot be acquired, and further the loss is caused.
Drawings
Fig. 1 is a schematic diagram of a method for acquiring a client IP in a load balancing system according to the present invention.
Fig. 2 is a schematic diagram of load balancing operation of a method for acquiring a client IP in a load balancing system according to the present invention.
Detailed Description
The method for acquiring the client IP in the load balancing system of the present invention is further described in detail with reference to the accompanying drawings.
With reference to fig. 1-2, a method for obtaining a client IP in a load balancing system includes the following steps:
the method comprises the following steps: when a data packet sends a request from a client to reach a load balancer, the load balancer extracts real client IP addresses from the data packet, and the real client IP addresses are marked as A, B, C and D;
step two: converting A, B, C and D into 4 bytes which are respectively marked as h1, h2, h3 and h 4;
step three: constructing 8-byte data, and inserting the 8-byte data into a TCP option field in a data packet sent to a real server according to a certain format;
step four: the real server receives the data packet, analyzes the TCP option field, and extracts h1, h2, h3 and h4 according to a preset format;
step five: and the real server restores the real client IP according to h1, h2, h3 and h 4.
The data format of the 8 bytes is as follows: 0x1c, 0x07, 0x01, h1, h2, h3, h4, 0x 01.
A server pool is configured in advance on the load balancer, and the server pool comprises a plurality of servers.
After the request of the client reaches the load balancer, the load balancer can select any server from the service pool and forward the request to the server for processing.
The specific implementation process of the method for acquiring the client IP in the load balancing system is as follows:
1) the client sends a data packet to the load balancer, and the IP of the carrying source is 192.168.1.100
2) Extracting the client ip, converting into 4 bytes: 0xc0,0xa8,0x01,0x64
3) Constructing 8 bytes of data:
0x1c 0x07 0x01 0xc0 0xa8 0x01 0x64 0x01
4) the 8 bytes of data are inserted into a TCP option field in a data packet sent to the real server.
5) The real server receives the data packet and extracts 0xc0,0xa8,0x01 and 0x64
6) The real server restores the IP of the client to 192.168.1.100
The present invention and its embodiments have been described above, and the description is not intended to be limiting, and the drawings are only one embodiment of the present invention, and the actual structure is not limited thereto. In summary, those skilled in the art should appreciate that they can readily use the disclosed conception and specific embodiments as a basis for designing or modifying other structures for carrying out the same purposes of the present invention without departing from the spirit and scope of the invention as defined by the appended claims.

Claims (4)

1. A method for obtaining client IP in a load balancing system is characterized in that: the method comprises the following steps:
the method comprises the following steps: when a data packet sends a request from a client to reach a load balancer, the load balancer extracts real client IP addresses from the data packet, and the real client IP addresses are marked as A, B, C and D;
step two: converting A, B, C and D into 4 bytes which are respectively marked as h1, h2, h3 and h 4;
step three: constructing 8-byte data, and inserting the 8-byte data into a TCP option field in a data packet sent to a real server according to a certain format;
step four: the real server receives the data packet, analyzes the TCP option field, and extracts h1, h2, h3 and h4 according to a preset format;
step five: and the real server restores the real client IP according to h1, h2, h3 and h 4.
2. The method for obtaining the client IP in the load balancing system according to claim 1, wherein: the data format of the 8 bytes is as follows: 0x1c, 0x07, 0x01, h1, h2, h3, h4, 0x 01.
3. The method for obtaining the client IP in the load balancing system according to claim 1, wherein: a server pool is configured in advance on the load balancer, and the server pool comprises a plurality of servers.
4. The method of claim 3, wherein the method for obtaining the client IP in the load balancing system comprises: after the request of the client reaches the load balancer, the load balancer can select any server from the service pool and forward the request to the server for processing.
CN202111010992.2A 2021-08-31 2021-08-31 Method for acquiring client IP in load balancing system Pending CN113794703A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111010992.2A CN113794703A (en) 2021-08-31 2021-08-31 Method for acquiring client IP in load balancing system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111010992.2A CN113794703A (en) 2021-08-31 2021-08-31 Method for acquiring client IP in load balancing system

Publications (1)

Publication Number Publication Date
CN113794703A true CN113794703A (en) 2021-12-14

Family

ID=78876708

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111010992.2A Pending CN113794703A (en) 2021-08-31 2021-08-31 Method for acquiring client IP in load balancing system

Country Status (1)

Country Link
CN (1) CN113794703A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103297407A (en) * 2012-03-02 2013-09-11 百度在线网络技术(北京)有限公司 Method and device for transmitting IPv6 address and port of client-side to back-end server
CN103297552A (en) * 2012-03-02 2013-09-11 百度在线网络技术(北京)有限公司 Method and device for transmitting IPv4 address and port of client-side to back-end server
US20140108661A1 (en) * 2012-10-17 2014-04-17 Alibaba Group Holding Limited System, method and apparatus of data interaction under load balancing
CN105554065A (en) * 2015-12-03 2016-05-04 华为技术有限公司 Method, conversion unit and application unit for message processing
CN106506700A (en) * 2016-12-28 2017-03-15 北京优帆科技有限公司 A kind of transparent proxy method of load equalizer and SiteServer LBS
CN109729104A (en) * 2019-03-19 2019-05-07 北京百度网讯科技有限公司 Client source address acquiring method, device, server and computer-readable medium
CN111800518A (en) * 2020-08-20 2020-10-20 杭州迪普科技股份有限公司 Client IP address insertion method and device
CN112437127A (en) * 2020-11-10 2021-03-02 新华三大数据技术有限公司 Message processing method and device, load balancer and server
CN113014490A (en) * 2021-02-25 2021-06-22 杭州迪普科技股份有限公司 IP message forwarding method and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103297407A (en) * 2012-03-02 2013-09-11 百度在线网络技术(北京)有限公司 Method and device for transmitting IPv6 address and port of client-side to back-end server
CN103297552A (en) * 2012-03-02 2013-09-11 百度在线网络技术(北京)有限公司 Method and device for transmitting IPv4 address and port of client-side to back-end server
US20140108661A1 (en) * 2012-10-17 2014-04-17 Alibaba Group Holding Limited System, method and apparatus of data interaction under load balancing
CN105554065A (en) * 2015-12-03 2016-05-04 华为技术有限公司 Method, conversion unit and application unit for message processing
CN106506700A (en) * 2016-12-28 2017-03-15 北京优帆科技有限公司 A kind of transparent proxy method of load equalizer and SiteServer LBS
CN109729104A (en) * 2019-03-19 2019-05-07 北京百度网讯科技有限公司 Client source address acquiring method, device, server and computer-readable medium
CN111800518A (en) * 2020-08-20 2020-10-20 杭州迪普科技股份有限公司 Client IP address insertion method and device
CN112437127A (en) * 2020-11-10 2021-03-02 新华三大数据技术有限公司 Message processing method and device, load balancer and server
CN113014490A (en) * 2021-02-25 2021-06-22 杭州迪普科技股份有限公司 IP message forwarding method and device

Similar Documents

Publication Publication Date Title
US11647009B2 (en) Access request conversion method and apparatus
US8892768B2 (en) Load balancing apparatus and load balancing method
WO2017076327A1 (en) Method and apparatus for processing domain name resolution request, and server
CN110602269B (en) Method for converting domain name
JP2005539298A (en) Method and system for remotely and dynamically configuring a server
CN111917900B (en) Domain name agent request processing method and device
CN108989420B (en) Method and system for registering service and method and system for calling service
US10067862B2 (en) Tracking asynchronous entry points for an application
US10775751B2 (en) Automatic generation of regular expression based on log line data
CN110958127A (en) Exception handling method, device and equipment and computer storage medium
WO2022179353A1 (en) Domain name resolution method and apparatus, and computer device
JP2004280815A (en) Method and apparatus for server load sharing based on external port distribution
CN107911496A (en) A kind of VPN service terminal acts on behalf of the method and device of DNS
CN111711675B (en) Solution for concurrent message transmission in local area network
CN113794703A (en) Method for acquiring client IP in load balancing system
US8447839B2 (en) Three-layer web management protocol device emulation
US20030204586A1 (en) Intelligent data replicator
US20160006821A1 (en) Correlation Identity Generation Method For Cloud Environment
US9967331B1 (en) Method, intermediate device and computer program code for maintaining persistency
KR101066610B1 (en) A transmission system for compression and division of xml and json data
US6219804B1 (en) Debugging client server programs from third party workstations
CN113886064A (en) Method for selecting service pool members in load balancing system
CN112333106A (en) High-concurrency scene offline psychological consultation doctor resource allocation method
US20100241740A1 (en) System and method for resolving network addresses
CN115174683B (en) Request method and system for calling query interface

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
RJ01 Rejection of invention patent application after publication

Application publication date: 20211214