Skip to main content
microsandbox handles DNS queries on the host instead of letting the guest contact a resolver directly. This makes domain rules and DNS rebinding protection possible.

DNS as egress

Every DNS query must pass the sandbox’s egress policy. The public, private, and host profiles already allow DNS through the gateway. With a custom deny-by-default policy, add the equivalent of allow_dns() or use allow@dns in the CLI. Otherwise, every lookup will be denied. DNS over TLS uses TCP port 853 and needs its own allow rule. It also requires TLS inspection. DNS rebinding protection is separate from query access. microsandbox rejects private or reserved answers unless an explicit address rule allows them. An allow-by-default policy does not disable this protection. See Network defenses for the full policy behavior.

Blocking domains

microsandbox returns a local NXDOMAIN response for denied domains and never forwards them to the upstream resolver. The same rules also protect connections that use TLS SNI or a recently resolved IP address.

Pinning nameservers

By default, microsandbox uses the host’s resolver list. Set nameservers when you need specific resolvers. Nameservers can be IP addresses, hostnames, or either form with a port. microsandbox resolves hostnames once when the sandbox starts. microsandbox tries resolvers in order. A timeout or connection failure moves to the next resolver. DNS responses such as SERVFAIL and REFUSED do not. Each unreachable resolver can delay the query by up to query_timeout_ms.
An application can request a specific resolver, such as with dig @1.1.1.1. That request skips the configured default list, but it still has to pass the network policy.

DNS over alternative transports

Domain blocking and rebinding protection apply only to DNS traffic that microsandbox can identify. Use network rules to control DNS over HTTPS or to restrict which resolvers the guest can reach.

Domain-based policy rules

microsandbox records the IP addresses returned for each domain. A domain rule matches a later connection only when that sandbox resolved the domain to that IP. microsandbox uses the lowest TTL across the relevant addresses and alias chain in each DNS answer, with a one-second minimum, for all addresses in that answer. For example, addresses with TTLs of 30 and 120 seconds both get a 30-second lifetime. Later answers retain earlier addresses until they expire and extend only the addresses they contain, so rotating CDN answers do not invalidate connections using an earlier answer. Each sandbox retains up to 16,384 hostname/address bindings in total, with at most 1,024 per hostname shared across IPv4 and IPv6. An address shared by two domains counts twice. If a DNS answer would exceed either limit, microsandbox returns SERVFAIL without adding any of that answer’s addresses or removing existing bindings. Answers containing only existing bindings can still refresh them; expired bindings free space for new answers. An application that connects directly to a hard-coded IP does not match a domain rule. Use an IP or CIDR rule for that traffic.

Reference

For exact DNS and network APIs, see TypeScript, Rust, Python, or Go. For CLI fields and flags, see Sandbox configuration and Sandbox commands.