[Regression 1.14.5] auto_redirect: DNS queries to the gateway's own IP (:53) time out, no longer hijacked (worked in 1.14.4)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- go, linux
- Ambito
- backend, networking
Direzione di ricerca
Start by reading the 1.14.5 auto_redirect changes and the Linux routing and nftables code that handles TUN DNS hijacking; the issue does not name source files or tests. Reproduce the marked route lookup described in the report on the affected kernel and compare it with the working host. Done means LAN DNS queries to the gateway’s own IP are answered through sing-box again.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Operating system
Linux
System version
Rocky Linux 10, x86_64
Installation type
Original sing-box Command Line
If you are using a graphical client, please provide the version of the client.
No response
Version
sing-box 1.14.5 (official RPM package sing-box-1.14.5-1.x86_64). This is a regression: the identical setup works correctly on 1.14.4.
Description
Transparent-proxy gateway deployment: LAN clients use the gateway itself (192.168.10.1) as their DNS server, relying on the tun inbound's DNS hijack (dns_mode: "hijack", auto_route + auto_redirect) so that sing-box's DNS routing rules apply (fakeip for proxied domains, local resolver for direct domains).
After upgrading 1.14.4 -> 1.14.5 (config unchanged; sing-box check passes on both versions), DNS queries addressed to the gateway's own LAN IP time out with no reply, so every client configured this way loses DNS completely and with it all internet access.
What still works on 1.14.5:
- DNS queries from the same clients to any other resolver address (e.g. 192.168.10.2) are hijacked and answered normally.
- The gateway host's own DNS and traffic work normally.
- All proxied/direct data-plane traffic works normally.
Reproduction
Gateway tun inbound:
{"type":"tun","tag":"tun-in","interface_name":"tun0","address":["172.18.0.1/30","fdfe:dcba:9876::1/126"],"mtu":9000,"dns_mode":"hijack","auto_route":true,"auto_redirect":true,"strict_route":true,"stack":"system"}
From a LAN client (e.g. 192.168.10.30) whose default gateway is 192.168.10.1:
nslookup www.google.com 192.168.10.1
- 1.14.5:
;; communications error to 192.168.10.1#53: timed out - 1.14.4: instant answer (fakeip, e.g. fc00::9 for AAAA / a 198.18.0.0/15 address for A); domestic names return real IPs via the local DNS rule, as configured.
Observations (nftables, 1.14.5)
- 1.14.5 installs a new
prerouting_prematchfilter chain (priority dstnat-1, NFQUEUEqueue to 100based) ahead of the NAT prerouting chain; this chain layout does not exist in 1.14.4. - In
prerouting_prematch, packets with a local (LAN) source address and destination port 53 hit an earlyreturnand are never queued. - The NAT
preroutingchain does contain a rule DNAT-ing port-53 traffic from local sources to the tun DNS address (172.18.0.2), but it is followed by rules returning packets whose destination is a local address (ip daddr @inet4_local_address_set return,fib daddr type local return). A query destined to the gateway's own IP appears to fall through without ever being answered by the tun DNS hijack. - Downgrading to 1.14.4 with the same config immediately restores the expected behavior, which points to the auto_redirect rework in 1.14.5.
Expected behavior
DNS queries sent by LAN clients to the gateway's own IP on port 53 should be hijacked and answered by sing-box's DNS, as in 1.14.4.
Workaround
Downgrade to 1.14.4.
Additional evidence (production bisection + minimal config)
Minimal complete configuration (passes sing-box check on both 1.14.4 and 1.14.5):
{
"log": { "level": "info" },
"dns": {
"servers": [ { "type": "udp", "tag": "dns-remote", "server": "223.5.5.5" } ],
"final": "dns-remote"
},
"inbounds": [
{
"type": "tun", "tag": "tun-in", "interface_name": "tun0",
"address": [ "172.18.0.1/30", "fdfe:dcba:9876::1/126" ], "mtu": 9000,
"dns_mode": "hijack", "auto_route": true, "auto_redirect": true,
"strict_route": true, "stack": "system"
}
],
"outbounds": [ { "type": "direct", "tag": "direct" } ],
"route": { "final": "direct", "auto_detect_interface": true }
}
The version bisection was performed on the production gateway host (KVM VM, Rocky Linux 10.3, official RPM, firewalld active, real LAN clients using the gateway IP as their DNS server) and is deterministic: 1.14.5 -> 100% timeout for DNS queries to the gateway's own IP; 1.14.4 -> instant correct replies. Note: a quick test of the minimal config inside a Docker container on Debian did not reproduce the issue, so it may also depend on the host environment; the production-host bisection above is the primary evidence.
Packet-level forensics (nft trace on the production host, 1.14.5)
A controlled 1.14.5 window was run on the production host with nft monitor trace and tcpdump on both the LAN interface and tun0, while a LAN client queried the gateway's own IP :53:
- The query arrives on the LAN interface (tcpdump) and matches the
prerouting_prematchDNS rule (return). - In the
preroutingNAT chain the DNS rule fires: fwmark 0x04000000 is set and the packet is DNAT'd to the tun address 172.18.0.2 (chain counter incremented; the traced packet header shows daddr rewritten to 172.18.0.2 inprerouting_udp_icmp, verdict accept). - After the last prerouting chain (verdict accept), the packet disappears: it never traverses any FORWARD chain, never appears on tun0 (tcpdump empty), and sing-box logs no
inbound DNS packetfor the whole window. The packet is lost at the routing decision immediately following the DNAT. - A second traced flow (a retransmission on a pre-existing conntrack entry) was instead delivered to the local INPUT path with its destination unchanged and rejected by firewalld — the hijack is equally ineffective there.
With 1.14.4 the identical client query is answered in ~0.1 s. Controlled tests ruled out as triggers: the configuration (minimal and full), the binary build (tarball and RPM), firewalld being active, a Tailscale interface and its nft/policy-routing footprint, the client host, rp_filter (tested up to strict everywhere), ip_forward (enabled), and leftover policy-routing state from an unclean 1.14.4 stop (1.14.5 rebuilds its table correctly). Sandbox tests (Docker, netns — including one on the identical kernel 6.12.0-264.el10_3) did not reproduce; the failure is deterministic on the production gateway host (main network namespace, real LAN clients).
Routing state on the affected host (1.14.5, production config)
The production tun inbound additionally sets "route_exclude_address": ["100.64.0.0/10"], so table 2022 holds the prefix-decomposed default (0.0.0.0/2, 64.0.0.0/3, 96.0.0.0/6, 100.0.0.0/10, 100.128.0.0/9, 101.0.0.0/8, 102.0.0.0/7, 104.0.0.0/5, 112.0.0.0/4, 128.0.0.0/1, all via 172.18.0.2 dev tun0). The main table has the connected route 172.18.0.0/30 dev tun0. The policy rules are the stock 1.14.5 set (9001: fwmark 0x4000000 lookup 2022, 9000: fwmark 0x8000000/0x1c000000 goto 9002, 32768: not fwmark 0x8000000/0x1c000000 lookup 2022, plus Tailscale's 5210-5270 and a priority-1 lookup of sing-box's local-address table).
Simulating exactly the DNAT'd packet's routing decision on the affected host fails:
# ip route get 172.18.0.2 mark 0x04000000 from 192.168.10.30 iif ens18
RTNETLINK answers: Invalid argument
# ip route get 172.18.0.2 from 192.168.10.30 iif ens18 (no mark: works)
172.18.0.2 from 192.168.10.30 dev tun0
cache iif ens18
On a comparison host (same distro family, kernel 6.12.0-211.el10_2, same 1.14.5 RPM binary, equivalent config with route_exclude_address) the rule set and table 2022 are identical, but the marked lookup resolves and DNS to the gateway's own IP works:
# ip route get 172.18.0.2 mark 0x04000000 from 192.168.10.30 iif ens18
172.18.0.2 from 192.168.10.30 via 172.18.0.2 dev tun0 table 2022 mark 0x4000000
cache iif ens18
So on the affected host the marked fib lookup for the DNAT target errors out instead of falling through to the main table's connected route, and the packet is dropped at the routing decision — matching the nft trace above. The affected host runs kernel 6.12.0-264.17.1.el10_3; whether the trigger is the kernel's fib behavior with this rule/table shape, or another host-state difference we could not isolate, is the open question. Full ip rule / route-table dumps from both hosts can be provided on request.
Logs
Supporter
- I am a sponsor
Integrity requirements
- I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
- I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
- I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.
- Lingua principale
- Go
- Stelle
- 40.4k
- Fork
- 5k
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di SagerNet/sing-box
-
`check` and startup are quadratic in outbound group size since 1.14.4 (duplicate tag check)Forse già presa @Tidehyc l’ha presa 5 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
database file removal errorsAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
Tutte le issue di SagerNet/sing-box
Issue simili
-
bug effort:s impact:med raised-by:worker risk:low to:worker
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
medici-finance/assay#8120 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
factory:subtask
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
agent-substrate/substrate#4308 ·
I maintainer di solito rispondono entro 2 giorni
-
ci good first issue severity: low
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
TMHSDigital/Spackle#206 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
celestiaorg/celestia-app#8877 ·
I maintainer di solito rispondono entro 1 giorno