Skip to content

The dial block ​

How an outbound opens the connection to its server (and direct to the target): through which interface, with which mark, through which other outbound. Outbounds only; for an inbound, the socket parameters are the listening fields.

All outbounds take the block: direct, socks, http, shadowsocks, trojan, vless, anytls, shadowtls, hysteria, hysteria2, tuic.

Fields ​

FieldTypeDefaultMeaning
detouroutbound name—Open the connection through another outbound (a proxy chain)
interfacestring—Bind the socket to an interface (SO_BINDTODEVICE)
fwmarknumberthe default markThe SO_MARK mark for policy routing
netnsname—A network namespace from the network_namespaces section
bindblock—Source addresses: inet4 for IPv4, inet6 for IPv6, no_port for IP_BIND_ADDRESS_NO_PORT (the port is chosen at connect)
reuse_addrboolfalseSO_REUSEADDR
connect_timeoutduration5sThe limit for establishing a TCP connection
tcpblock—fast_open (TCP Fast Open), multi_path (MPTCP), congestion — the congestion control algorithm (TCP_CONGESTION, for example bbr, cubic), keep_alive — false turns it off, the block {idle, interval} sets the idle time before the first probe and the interval between probes. The same block as in listener
udpblock—fragment — allow fragmentation of outgoing UDP datagrams (true by default for direct)
interfacesblock—Choosing the interface by network type, see below
fallback_delayduration300ms / 250msPause before the fallback interface (default 300ms) and between Happy Eyeballs attempts (default 250ms, min 10ms). One value set here applies to both

Durations are strings like 300ms, 5s, 1m. The value of dial is a block of fields; any other value (a string, a number) is the error dial: expected a mapping.

detour ​

The connection to the server is opened through the given outbound; this is how chains are built (a → b → internet) and, for example, Shadowsocks over ShadowTLS. The target of detour is the name of an outbound or a group. detour is forbidden for direct: `detour` is not supported in direct context.

Happy Eyeballs ​

A TCP connection to a domain that the dialer resolved itself follows RFC 8305 (Happy Eyeballs v2): addresses are taken alternating between families, starting with the family of the first address in the DNS answer (IPv6, IPv4, IPv6, …); each next attempt starts after fallback_delay (250ms by default, no less than 10ms) or as soon as the previous one fails, so a family without a route does not delay the connection. The first attempt to connect wins, the others are closed. Addresses of an IP target and addresses from the resolve action are tried one by one.

tcp.congestion ​

The algorithm must be in /proc/sys/net/ipv4/tcp_available_congestion_control, otherwise loading ends with the error tcp_congestion: `bbr` is not available in this kernel (available: reno cubic); load it with `modprobe tcp_bbr`. An algorithm not in net.ipv4.tcp_allowed_congestion_control requires CAP_NET_ADMIN. Without the field, the system's default algorithm is used; the one shared by all sockets of the kernel is route.dial.tcp.congestion.

yaml
dial:
  tcp:
    congestion: bbr

fwmark and auto_nft ​

If a tproxy inbound has auto_nft enabled, an outbound's fwmark must not touch the bits of its mask (auto_nft.mark): loading ends with an error.

interfaces ​

yaml
dial:
  interfaces:
    strategy: fallback
    type: [wifi]
    fallback: [cellular]
  fallback_delay: 300ms

strategy as in sing-box: default is the default interface limited by type; fallback is type first, then fallback after fallback_delay; hybrid is all matching interfaces in parallel. The types are wifi, cellular, ethernet, other; the type of an interface is determined from sysfs. Cannot be combined with interface, bind or tcp.fast_open. fallback_delay stands next to the block, not inside: it also sets the pause before the second address family.

Not supported ​

  • protect_path — dial: `protect_path` is not implemented yet.
  • domain_resolver, domain_strategy — which DNS server resolves the outbound's server name is set by dns.rules rules with the outbound condition, see Resolvers for outbounds.
  • The sing-box names bind_interface and routing_mark are an error with a hint (`bind_interface` is `interface` here); write interface and fwmark. The same goes for grouped fields: `network_strategy` is `interfaces.strategy`, `disable_tcp_keep_alive` is `tcp.keep_alive: false`.

outbounds.defaults ​

An outbound named defaults is not created: its blocks are the defaults for all outbounds, including subscription servers. Every outbound gets the dial block from defaults; the other blocks (tls, mux, …) only complement the outbounds that already have such a block. An outbound's own fields take precedence over inherited ones.

Example ​

yaml
outbounds:
  defaults:
    dial:
      connect_timeout: 10s
  wan2:
    direct:
    dial:
      interface: eth0
      fwmark: 0x10
      tcp:
        keep_alive:
          idle: 5m
  chained:
    socks:
      server: 127.0.0.1:1080
    dial:
      detour: wan2
route:
  final:
    outbound: chained

For developers: the dial module.

GPL-3.0-or-later