# US 2019/0379641 A1 · Method and system for bidirectional transparent proxying

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2019/0379641 A1
- Document ID: US20190379641A1
- Status: Published application
- Kind: A1
- Application number: 15/774,046
- Filed: 2017-08-25
- Published: 2019-12-12
- Earliest claimed: 2017-08-22
- Assignees: Wangsu Science & Technology Co., Ltd.
- Applicants: Wangsu Science & Technology Co., Ltd.
- Inventors: Peng LIN; Zhaoxin LU; Xun CHEN
- Web page: https://patentgrep.com/patent/US20190379641A1

## CPC

- H04L 63/0281: {Proxies}
- H04L 61/5007: Internet protocol [IP] addresses
- H04L 63/0236: {Filtering by address, protocol, port number or service, e.g. IP-address or URL}
- H04L 63/0263: {Rule management}
- H04L 67/563: Data redirection of data network streams
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)

## Abstract

A method for bidirectional transparent proxying, includes: configuring, by a first proxy end, iptables rules based on a protocol type of a requesting-end-requested packet, and receiving, by the first proxy end, the requesting-end-requested packet that is guided based on the iptables rules; sending, by the first proxy end, the requesting-end-requested packet and the protocol type of the requesting-end-requested packet to a second proxy end; based on the requesting-end-requested packet and the protocol type of the requesting-end-requested packet, sending, by the second proxy end, the requesting-end-requested packet to an acknowledging end by configuring ospf service, iptables rules and routing rules, guiding and receiving, by the second proxy end, an acknowledging-end-responded packet, and sending, by the second proxy end, the acknowledging-end-responded packet to the first proxy end; sending, by the first proxy end, the received acknowledging-end-responded packet to the requesting end.

## Claims

### Claim 1

A method for bidirectional transparent proxying, comprising:
configuring, by a first proxy end, iptables rules based on a protocol type of a requesting-end-requested packet, and receiving, by the first proxy end, the requesting-end-requested packet that is guided based on the iptables rules, wherein the requesting-end-requested packet is a packet requested by a requesting end;
sending, by the first proxy end, the requesting-end-requested packet and the protocol type of the requesting-end-requested packet to a second proxy end;
based on the requesting-end-requested packet and the protocol type of the requesting-end-requested packet, sending, by the second proxy end, the requesting-end-requested packet to an acknowledging end, wherein a requesting-end ip address and a requesting-end port in the requesting-end-requested packet are used as a source ip address and a source port;
by configuring ospf service, iptables rules and routing rules, guiding and receiving, by the second proxy end, an acknowledging-end-responded packet, and sending, by the second proxy end, the acknowledging-end-responded packet to the first proxy end, wherein the acknowledging-end-responded packet is a packet responded by the acknowledging end;
sending, by the first proxy end, the acknowledging-end-responded packet to the requesting end.

### Claim 2 (depends on 1)

The method according to claim 1, wherein:
the protocol type of the requesting-end-requested packet is a connection-oriented protocol type, and
the configuring, by a first proxy end, iptables rules based on a protocol type of a requesting-end-requested packet, and receiving, by the first proxy end, the requesting-end-requested packet that is guided based on the iptables rules further comprises:
configuring, by the first proxy end, the iptables rules based on the connection-oriented protocol type, and utilizing, by the first proxy end, a redirect mechanism of NetFilter to redirect the requesting-end-requested packet to the first proxy end, thereby establishing a connection-oriented connection relationship between the first proxy end and the requesting end.

### Claim 3 (depends on 1)

The method according to claim 1, wherein:
the protocol type of the requesting-end-requested packet is a connectionless protocol type, and
the configuring, by a first proxy end, iptables rules based on a protocol type of a requesting-end-requested packet, and receiving, by the first proxy end, the requesting-end-requested packet that is guided based on the iptables rules further comprises:
configuring, by the first proxy end, the iptables rules based on the connectionless protocol type, utilizing, by the first proxy end, a mark mechanism of the NetFilter to mark the requesting-end-requested packet, and configuring, by the first proxy end, routing rules to guide the marked requesting-end-requested packet to the first proxy end.

### Claim 4 (depends on 3)

The method according to claim 3, wherein:
when the protocol type of the requesting-end-requested packet is the connectionless protocol type, of the configuring, by the first proxy end, iptables rules based on the protocol type of the requesting-end-requested packet, and receiving, by the first proxy end, the requesting-end-requested packet that is guided based on the iptables rules further comprises:
when the connectionless protocol type is a UDP protocol type, utilizing, by the first proxy end, a tproxy mechanism of the NetFilter to redirect the requesting-end-requested packet, marking, by the first proxy end, the redirected requesting-end-requested packet, and configuring, by the first proxy end, routing rules to guide the marked requesting-end-requested packet to the first proxy end.

### Claim 5 (depends on 1)

The method according to claim 1, wherein:
based on the requesting-end-requested packet and the protocol type of the requesting-end-requested packet, sending, by the second proxy end, the requesting-end-requested packet to an acknowledging end, wherein the requesting-end ip address and the requesting-end port in the requesting-end-requested packet are used as the source ip address and the source port further comprises:
when the protocol type of the requesting-end-requested packet is a connection-oriented protocol type, based on the connection-oriented protocol type, utilizing, by the second proxy end, an ip_transparent option of socket to establish a connection-oriented connection relationship with the acknowledging end, wherein the requesting-end ip address and the requesting-end port in the requesting-end-requested packet are used as the source ip address and the source port; and sending, by the second proxy end, the requesting-end-requested packet to the acknowledging end; or
when the protocol type of the requesting-end-requested packet is a connectionless protocol type, based on the connectionless protocol type, utilizing, by the second proxy end, the ip_transparent option of the socket to directly send the requesting-end-requested packet to the acknowledging end, wherein the requesting-end ip address and the requesting-end port in the requesting-end-requested packet are used as the source ip address and the source port.

### Claim 6 (depends on 2)

The method according to claim 2, wherein:
when the protocol type of the acknowledging-end-responded packet is a connection-oriented protocol type, the sending, by the first proxy end, the received acknowledging-end-responded packet to the requesting end further comprises:
through the connection relationship between the first proxy end and the requesting end, sending, by the first proxy end, the received acknowledging-end-responded packet to the requesting end.

### Claim 7 (depends on 3)

The method for bidirectional transparent proxying according to claim 3, wherein:
when the protocol type of the acknowledging-end-responded packet is a connectionless protocol type, the sending, by the first proxy end, the received acknowledging-end-responded packet to the requesting end further comprises:
through raw socket, sending, by the first proxy end, the received acknowledging-end-responded packet to the requesting end.

### Claim 8

A system for bidirectional transparent proxying, comprising:
a first proxy end and a second proxy end, the first proxy end including a first configuration module and a second configuration module, and the second proxy end including a third configuration module and a fourth configuration module;
the first configuration module is configured for configuring iptables rules based on a protocol type of a requesting-end-requested packet, and receiving the requesting-end-requested packet that is guided based on the iptables rules, wherein the requesting-end-requested packet is a packet requested by a requesting end;
the second configuration module is configured for sending the requesting-end-requested packet and the protocol type of the requesting-end-requested packet to the second proxy end;
the third configuration module is configured for, based on the requesting-end-requested packet and the protocol type of the requesting-end-requested packet, sending the requesting-end-requested packet to an acknowledging end, wherein a requesting-end ip address and a requesting-end port in the requesting-end-requested packet are used as a source ip address and a source port;
the fourth configuration module is configured for guiding and receiving an acknowledging-end-responded packet by configuring ospf service, iptables rules and routing rules, and sending the acknowledging-end-responded packet to the first proxy end, wherein the acknowledging-end-responded packet is a packet responded by the acknowledging end;
the first configuration module is further configured for sending the received acknowledging-end-responded packet to the requesting end.

### Claim 9 (depends on 8)

The system according to claim 8, wherein:
when the protocol type of the requesting-end-requested packet is a connection-oriented protocol type, the first configuration module is further configured for configuring iptables rules based on the connection-oriented protocol type, and utilizing a redirect mechanism of NetFilter to redirect the requesting-end-requested packet to the first proxy end, thereby establishing a connection-oriented connection relationship between the first proxy end and the requesting end.

### Claim 10 (depends on 8)

The system according to claim 8, wherein:
when the protocol type of the requesting-end-requested packet is a connectionless protocol type, the first configuration module is further configured for configuring iptables rules based on the connectionless protocol type, utilizing a mark mechanism of the NetFilter to mark the requesting-end-requested packet, and configuring routing rules to guide the marked requesting-end-requested packet to the first proxy end.

### Claim 11 (depends on 10)

The system according to claim 10, wherein:
when the connectionless protocol type is a UDP protocol type, the first configuration module is further configured for utilizing a tproxy mechanism of the NetFilter to redirect the requesting-end-requested packet, marking the redirected requesting-end-requested packet, and configuring routing rules to guide the marked requesting-end-requested packet to the first proxy end.

### Claim 12 (depends on 8)

The system according to claim 8, wherein:
when the protocol type of the requesting-end-requested packet is a connection-oriented protocol type, the third configuration module is further configured for, based on the connection-oriented protocol type, utilizing an ip_transparent option of socket to establish a connection-oriented connection relationship with the acknowledging end, wherein a requesting-end ip address and a requesting-end port in the requesting-end-requested packet are used as a source ip address and a source port; and sending the requesting-end-requested packet to the acknowledging end; and
when the protocol type of the requesting-end-requested packet is a connectionless protocol type, the third configuration module is further configured for utilizing the ip_transparent option of the socket to directly send the requesting-end-requested packet to the acknowledging end based on the connectionless protocol type, wherein the requesting-end ip address and the requesting-end port in the requesting-end-requested packet are used as the source ip address and the source port.

### Claim 13 (depends on 9)

The system according to claim 9, wherein:
when the protocol type of the acknowledging-end-responded packet is the connection-oriented protocol type, the first configuration module is further configured for, through the connection relationship between the first proxy end and the requesting end, sending the received acknowledging-end-responded packet to the requesting end.

### Claim 14 (depends on 10)

The system according to claim 10, wherein:
when the protocol type of the acknowledging-end-responded packet is the connectionless protocol type, the first configuration module is further configured for, through raw socket, sending the received acknowledging-end-responded packet to the requesting end.
