Skip to content

Redir

[!NOTE] This document is partially generated by AI.

Redir is a traditional transparent proxying method used primarily on Linux systems. It is functionally similar to TProxy but handles packet redirection slightly differently. In yuhaiin, it is an inbound-only protocol.

  • TCP: Supported (Intercepted and proxied).
  • UDP: Supported (Intercepted and proxied).
    • NAT Type: Full-Cone NAT.

The redir configuration is extremely simple:

  • host (string): The address and port where the redirection listener will bind (e.g., 0.0.0.0:60081).

A Redir inbound must be paired with a tcpudp listener.

{
"name": "Linux-Redir",
"enabled": true,
"tcpudp": { "host": "127.0.0.1:60081" },
"redir": {
"host": "127.0.0.1:60081"
}
}

Redir uses destination NAT (DNAT) rules in iptables to redirect traffic to a local port. The yuhaiin listener then uses the getsockopt syscall with SO_ORIGINAL_DST to retrieve the intended destination address.

Like TProxy, Redir is primarily intended for Linux environments.

Detailed implementation can be found in pkg/net/proxy/redir.