WALL-E / Practice

练习手册
0 stars 0 forks source link

proxy_bind #14

Open WALL-E opened 7 years ago

WALL-E commented 7 years ago

底层技术

socket有一个IP_TRANSPARENT选项,其含义就是可以使一个服务器程序侦听所有的IP地址,哪怕不是本机的IP地址,这个特性在实现透明代理服务器时十分有用

IP_TRANSPARENT (since Linux 2.6.24)
              Setting this boolean option enables transparent proxying on
              this socket.  This socket option allows the calling
              application to bind to a nonlocal IP address and operate both
              as a client and a server with the foreign address as the local
              endpoint.  NOTE: this requires that routing be set up in a way
              that packets going to the foreign address are routed through
              the TProxy box (i.e., the system hosting the application that
              employs the IP_TRANSPARENT socket option).  Enabling this
              socket option requires superuser privileges (the CAP_NET_ADMIN
              capability).

              TProxy redirection with the iptables TPROXY target also
              requires that this option be set on the redirected socket.

https://www.kernel.org/doc/Documentation/networking/tproxy.txt