Skip to content

Dokodemo / port-forwarder — sing-box

Use the Direct inbound

sing-box does not have a dedicated dokodemo or tunnel inbound. The Direct inbound covers the same use case — accept on a port, optionally override the destination, and let the routing engine or override_address / override_port decide where the traffic goes.

Static port-forwarder

json
{
  "inbounds": [
    {
      "type": "direct",
      "tag": "dns-forward",
      "listen": "0.0.0.0",
      "listen_port": 5353,
      "override_address": "1.1.1.1",
      "override_port": 53
    }
  ],
  "outbounds": [
    { "type": "direct", "tag": "direct" }
  ]
}

TPROXY receiver

For Linux transparent-proxy mode, set the inbound's tcp_fast_open sniff options as usual and use a redirect inbound. See Direct — sing-box for the inbound option set, and the upstream Route documentation (Phase 5) for how to recover the original destination.

Multi-port forwarding

sing-box has no built-in portMap field. To forward each port to a different target, declare one Direct inbound per port:

json
{
  "inbounds": [
    {
      "type": "direct",
      "tag": "fwd-80",
      "listen_port": 80,
      "override_address": "10.0.0.10",
      "override_port": 80
    },
    {
      "type": "direct",
      "tag": "fwd-443",
      "listen_port": 443,
      "override_address": "10.0.0.10",
      "override_port": 443
    },
    {
      "type": "direct",
      "tag": "fwd-53",
      "network": "udp",
      "listen_port": 5353,
      "override_address": "1.1.1.1",
      "override_port": 53
    }
  ]
}

Cross-core notes

  • Xray-core has the dedicated dokodemo-door protocol with a portMap for multi-port forwarding in a single inbound. See Dokodemo — Xray-core.
  • mihomo offers listeners: type: tunnel and a top-level tunnels: block. See Tunnel — mihomo.

Core Tutorial by Argsment