You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(egress): add nameserver exempt for direct DNS forwarding (#356)
* feat(egress): add nameserver exempt for direct DNS forwarding
* fix(egress): nameserver exempt to IP-only and ensure nft allow set
* chore(egress): add unittest for ParseNameserverExemptList
* fix(egress): cache nameserver exempt addrs and split exempt tests
-`dns`: DNS proxy only, no nftables (IP/CIDR rules have no effect at L2).
44
44
-`dns+nft`: enable nftables; if nft apply fails, fallback to `dns`. IP/CIDR enforcement and DoH/DoT blocking require this mode.
45
+
-**Nameserver exempt**
46
+
Set `OPENSANDBOX_EGRESS_NAMESERVER_EXEMPT` to a comma-separated list of **nameserver IPs** (e.g. `26.26.26.26` or `26.26.26.26,100.100.2.116`). Only single IPs are supported; CIDR entries are ignored. Traffic to these IPs on port 53 is not redirected to the proxy (iptables RETURN). In `dns+nft` mode, these IPs are also merged into the nft allow set so proxy upstream traffic to them (sent without SO_MARK) is accepted. Use when the upstream is reachable only via a specific route (e.g. tunnel) and SO_MARK would send proxy traffic elsewhere.
45
47
-**DNS and nft mode (nameserver whitelist)**
46
48
In `dns+nft` mode, the sidecar automatically allows:
47
49
-**127.0.0.1** — so packets redirected by iptables to the proxy (127.0.0.1:15353) are accepted by nft.
@@ -178,6 +180,5 @@ More details in [docs/benchmark.md](docs/benchmark.md).
178
180
179
181
- **"iptables setup failed"**: Ensure the sidecar container has `--cap-add=NET_ADMIN`.
180
182
- **DNS resolution fails for all domains**:
181
-
- Check if the upstream DNS (from `/etc/resolv.conf`) is reachable.
182
-
- In `dns+nft` mode, the sidecar whitelists nameserver IPs from resolv.conf at startup; check logs for `[dns] whitelisting proxy listen + N nameserver(s)` and ensure `/etc/resolv.conf` is readable and contains valid, reachable nameservers. The proxy prefers the first non-loopback nameserver from resolv.conf; if only loopback exists (e.g. Docker 127.0.0.11), it is used (proxy upstream traffic bypasses the redirect). Fallback to 8.8.8.8 only when resolv.conf is empty or unreadable.
183
+
Check upstream reachability from the sidecar (`ip route`, `dig @<upstream> . NS +timeout=3`). In `dns+nft` mode, check logs for `[dns] whitelisting proxy listen + N nameserver(s)`.
183
184
- **Traffic not blocked**: If nftables apply fails, the sidecar falls back to dns; check logs, `nft list table inet opensandbox`, and `CAP_NET_ADMIN`.
Copy file name to clipboardExpand all lines: components/egress/pkg/iptables/redirect.go
+23-5Lines changed: 23 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@ package iptables
16
16
17
17
import (
18
18
"fmt"
19
+
"net/netip"
19
20
"os/exec"
20
21
"strconv"
21
22
@@ -24,14 +25,30 @@ import (
24
25
)
25
26
26
27
// SetupRedirect installs OUTPUT nat redirect for DNS (udp/tcp 53 -> port).
27
-
// Packets carrying mark bypassMark will RETURN (used by the proxy's own upstream
28
-
// queries to avoid redirect loops). Requires CAP_NET_ADMIN inside the namespace.
29
-
funcSetupRedirect(portint) error {
28
+
//
29
+
// exemptDst: optional list of destination IPs; traffic to these is not redirected. Packets carrying mark are also RETURNed (proxy's own upstream). Requires CAP_NET_ADMIN.
0 commit comments