5. Inbounds and Traffic Capture#


Inbounds determine how traffic enters Link1. This chapter introduces them from basic to advanced.

Inbound Overview#

Field/ConfigTypeUse CaseRequires Explicit Client Configuration
mixed-portHTTP + SOCKS5 mixed proxyLocal browsers, system proxy, manual LAN proxyYes
portHTTP proxyClients that only need an HTTP proxyYes
socks-portSOCKS5 proxyClients that support SOCKS5Yes
redir-portLinux REDIRECT transparent proxyRouter-based transparent TCP captureNo
tproxy-portLinux TPROXY transparent proxyRouter-based transparent TCP/UDP captureNo
tunVirtual network interfaceGlobal capture on desktop/router/mobileNo, or configured by the system VPN/TUN
app-proxyApplication transparent proxyDesktop per-application/process captureNo, or authorized by the platform
listenersProtocol serverLink1 as a VLESS/Hysteria2 serverRemote clients must configure the protocol

Explicit Proxy Entrances#

mixed-port#

mixed-port: 7890

Meaning: accepts both HTTP proxy and SOCKS5 requests on the same port.

Practical impact:

port#

port: 7891

Meaning: enables only an HTTP proxy entrance.

Practical impact:

socks-port#

socks-port: 7892

Meaning: enables only a SOCKS5 entrance.

Practical impact:

Listen Address and LAN Access#

allow-lan: true
bind-address: '*'
authentication:
  - alice:password
skip-auth-prefixes:
  - 127.0.0.1/32
lan-allowed-ips:
  - 192.168.0.0/16
lan-disallowed-ips:
  - 192.168.9.99/32

Field impact:

FieldMeaningPractical Impact
allow-lanWhether to allow LAN access to explicit proxy entrancesfalse is safer; true is required for other devices to use them
bind-addressListen address127.0.0.1 only listens locally; * / 0.0.0.0 exposes all interfaces
authenticationHTTP/SOCKS username and password listClients must provide authentication in user:pass format
skip-auth-prefixesSource IP ranges that skip authenticationCommonly used for localhost or trusted intranets
lan-allowed-ipsSource IP ranges allowed to accessReduces exposure
lan-disallowed-ipsSource IP ranges denied accessA denylist used to exclude devices, with priority

Transparent Proxy Entrances#

Transparent proxying sends traffic into Link1 through system routes or firewall rules, without requiring clients to configure a proxy manually.

redir-port#

redir-port: 7893

Meaning: Linux REDIRECT TCP transparent proxy entrance.

Practical impact:

tproxy-port#

tproxy-port: 7894

Meaning: Linux TPROXY transparent proxy entrance.

Practical impact:

Conflict with TUN#

If TUN auto-route or auto-redirect is enabled while redir-port/tproxy-port is also used, the same traffic may be captured twice. Link1 checks for these conflicts during configuration compilation.

Application Transparent Proxy app-proxy#

app-proxy:
  enable: true
  bypass-self: true
  fail-open: true

app-proxy is a per-application transparent proxy entrance for desktop systems. It uses platform capabilities to capture traffic initiated by applications, passes metadata such as destination address, process name, process path, and Bundle ID to the Link1 core, and then lets normal rules decide which policy group or outbound to use.

User configuration only exposes the app-proxy concept. You do not need to, and cannot, specify the underlying backend. Link1 selects the internal implementation by runtime platform: Network Extension on macOS/Darwin, WinDivert on Windows, and NFQUEUE on Linux. The platform capture layer only passes traffic and process metadata to the core; it does not maintain a second rule engine.

macOS App Proxy requires the host App/Extension to have the relevant Apple Network Extension entitlements, such as the App Proxy capability under com.apple.developer.networking.networkextension. The Go core in the current repository already provides app-proxy integration, metadata passthrough, and fallback protection for self-traffic. Actual Network Extension installation/authorization still depends on macOS app packaging and developer account configuration.

Field impact:

FieldMeaningDefault/Limit
enableEnables application transparent proxyingAvailable on desktop platforms; actual capture capability depends on whether the platform bridge is linked into the build
bypass-selfEnables fallback protection for Link1's own trafficDefault true; the platform layer should still actually exclude self-traffic
fail-openPrefer restoring direct connectivity/network availability when the platform bridge failsDefault true; exact behavior depends on the platform bridge

Practical impact:

TUN Inbound#

TUN creates a virtual network interface and lets the system hand IP packets to Link1.

Explicit proxies only capture applications that are willing to use a proxy. TUN is more like inserting a virtual network interface into the system. The system first sends IP packets originally destined for the internet to this virtual interface, and Link1 then decides how to send them out based on DNS, Sniffer, rules, and policy groups. It is suitable for applications that do not support proxy settings, global capture on mobile/desktop, and router gateway mode.

Why TUN Often Needs DNS Hijacking and Fake-IP#

The most common beginner issue is: TUN is enabled and websites load, but DOMAIN-SUFFIX rules do not match. The reason is that the TUN layer naturally sees IP packets, which usually only contain the "destination IP:port" and may not contain the original domain name.

DNS hijacking and Fake-IP can be understood like this:

The app queries www.example.com
  -> Link1 DNS returns a Fake-IP, for example 198.18.1.23
  -> The app connects to 198.18.1.23:443
  -> TUN hands the connection to Link1
  -> Link1 maps the Fake-IP back to www.example.com
  -> Domain rules can match

If DNS is not captured, the application may first obtain a real IP from the system DNS and then send that real IP directly into TUN. Link1 can still handle it with IP-based rules, and it can also try to recover the domain name from TLS SNI/HTTP Host/QUIC SNI using Sniffer. However, this is not reliable for every connection: some applications encrypt SNI, reuse connections, access IPs directly, or cause sniffing to fail during the UDP/QUIC phase.

Therefore, the recommended TUN combination is:

Domains that are not suitable for Fake-IP should be added to fake-ip-filter, such as router management domains, LAN discovery, printers, casting, .local / .lan, and similar names. Otherwise, applications may fail to complete LAN discovery after receiving a Fake-IP.

Minimal TUN Example#

dns:
  enable: true
  enhanced-mode: fake-ip
  fake-ip-range: 198.18.0.1/16

tun:
  enable: true
  backend: auto
  auto-route: true
  auto-detect-interface: true
  dns-hijack:
    - any:53

Core TUN Fields#

FieldMeaningPractical Impact
enableEnables TUNCreates/uses a virtual network interface to capture IP traffic
backendTUN backend, auto/native/packet-tunnelauto selects by platform; packet-tunnel is only suitable for Darwin platforms
deviceTUN device nameCommonly used on Linux/native; the platform may auto-name it when empty
mtuVirtual interface MTUDefault 1500; values too large or too small affect fragmentation and throughput
auto-routeAutomatically configures routesSends the system default route into TUN
auto-detect-interfaceAutomatically detects the outbound interfaceReduces the need to manually specify the physical interface name
strict-routeApplies stricter route constraintsReduces traffic leak risk but may affect LAN access
dns-hijackHijacks DNS queriesSends device DNS into Link1 and improves domain rule match rate
udp-timeoutUDP NAT mapping timeout, in secondsDefault 300; affects UDP session retention
endpoint-independent-natEndpoint-independent NATChanges UDP NAT reuse semantics

TUN Routing Fields#

FieldMeaningPractical Impact
route-addressCIDRs to captureOnly routes these destination networks into TUN
route-exclude-addressCIDRs to excludePrevents intranet, reserved addresses, or special services from going through TUN
route-address-setReferences an ipcidr rule set as captured networksSuitable for maintaining many CIDRs
route-exclude-address-setReferences an ipcidr rule set as excluded networksSuitable for maintaining many excluded CIDRs
inet4-address / inet6-addressTUN interface's own addressIf IPv4 is not specified, it is derived from the Fake-IP range
inet4-route-address / inet6-route-addressCaptured routes by IP familyControls IPv4/IPv6 separately
inet4-route-exclude-address / inet6-route-exclude-addressExcluded routes by IP familyControls IPv4/IPv6 exclusions separately

Default exclusions protect common intranet/reserved addresses, such as 10.0.0.0/8, 192.168.0.0/16, and 127.0.0.0/8, to avoid incorrectly sending management traffic into TUN.

TUN Selector Fields#

These fields only affect which local traffic enters TUN and are mainly used on Linux/Android:

FieldMeaning
include-interface / exclude-interfaceInclude/exclude by network interface
include-uid / include-uid-rangeInclude by UID
exclude-uid / exclude-uid-rangeExclude by UID
exclude-src-port / exclude-src-port-rangeExclude by source port
exclude-dst-port / exclude-dst-port-rangeExclude by destination port
include-android-userInclude Android user ID
include-package / exclude-packageInclude/exclude by Android package name

If auto-route=false, these route selectors are reset to zero or do not take effect, because Link1 is not responsible for automatic routing.

Linux Policy Routing Fields#

FieldMeaningDefault/Limit
iproute2-table-indexLinux routing table numberDefault 2022; reserved tables 253/254/255 cannot be used
iproute2-rule-indexLinux rule priorityDefault 9000
auto-redirectAutomatic redirect rulesLinux/Android related
auto-redirect-input-markInbound markDefault is related to the table index
auto-redirect-output-markOutbound markDefault is related to the table index
auto-redirect-iproute2-fallback-rule-indexfallback rule indexMust be less than iproute2-rule-index

Sniffer#

Sniffer identifies domain names from connection content.

sniffer:
  enable: true
  override-destination: true
  force-dns-mapping: true
  parse-pure-ip: true
  sniff:
    HTTP:
      ports: [80, 8080]
      override-destination: true
    TLS:
      ports: [443]
    QUIC:
      ports: [443]
  force-domain:
    - '+.example.com'
  skip-domain:
    - '+.lan'
  skip-src-address:
    - 192.168.0.0/16

Field impact:

FieldMeaning
enableEnables sniffing
override-destinationWhether to rewrite the actual outbound destination after a domain is sniffed; when disabled, SniffHost can still be recorded for rules/observability
force-dns-mappingTries to recover domains using DNS mappings
parse-pure-ipWhether to parse pure-IP destinations
sniffingCompatibility field that declares enabled sniffing protocols
port-whitelistOnly sniff on specified ports
sniff.HTTP/TLS/QUIC.portsSpecifies ports per protocol
force-domainDomain patterns that force sniffing even when a target host already exists; does not bypass override-destination
skip-domainDomain patterns to skip sniffing
skip-src-addressSkip by source address
skip-dst-addressSkip by destination address

Protocol Listeners#

listeners lets Link1 act as a server and accept protocol connections. Current configuration validation accepts: mixed, http, socks, redir, tproxy, tun, vless, and hysteria2. The main server-side protocols are VLESS and Hysteria2.

For details, see Outbound Protocol Configuration: Inbound Protocol Listeners.