English
Fakeip and DNS listeners
Fakeip
Fakeip gives the client an address from its own pool instead of the real one and remembers which domain it was given for. When the client connects to such an address, the proxy restores the domain even before the route rules: domain conditions work without sniffing, and the name, not the address, reaches the proxy server.
yaml
dns:
upstreams:
remote:
https: 1.1.1.1
fakeip:
inet4: 198.18.0.0/15
inet6: fc00::/18
rules:
- match:
query_type: [A, AAAA]
do: fakeip
final:
upstream: remote
route:
rules:
- match:
protocol: dns
to: hijack-dns
final:
outbound: proxydns.fakeip sets the pool: inet4 and/or inet6 are the subnets addresses are given from. Fakeip is not an upstream: it is the mark do: fakeip in the rules. do: fakeip without dns.fakeip is an error.
How a marked query is answered
The mark does not stop processing: the query goes further through the rules to a to (or final) and is resolved as usual. Then the answer is transformed:
- an A/AAAA answer that has addresses of the right family gets an address from the pool (one per domain), TTL 600 s;
- NXDOMAIN and an answer without addresses are passed as is: a domain that does not exist gets no fake address, and a domain without IPv6 gets no fake IPv6;
- HTTPS and SVCB get the upstream's answer without the
ipv4hint/ipv6hinthints and without A/AAAA next to them, so that the client does not connect bypassing the pool; ALPN, port, ECH and the other parameters stay; - other types (MX, TXT, SRV, …) get the upstream's answer unchanged;
to: blockafter the mark refuses as usual.
The client waits for the real answer of the upstream even for a domain that will get a fake address; the optimistic cache (dns.cache.optimistic) smooths out the delay.
A PTR query for an address from the pool (*.in-addr.arpa, *.ip6.arpa) is answered from the table, without an upstream and before the rules: an issued address gets a PTR with the domain, TTL 600 s; an address not issued gets NXDOMAIN. A fake address never goes outside.
The proxy's own internal queries skip the mark and get the real address, so a fakeip cannot reach the proxy wherever the rule stands.
Pool exhaustion
Addresses are given out in a circle: when the pool runs out, issuing starts from the beginning and takes the address away from the domain that got it earliest. An address with a live connection to it (TCP, UDP, QUIC) is skipped: a long session does not lose its domain until it ends. If all addresses of the pool are busy, the next one in the circle is taken.
Keeping across restarts
Issued addresses are kept in memory. So that clients with cached fake addresses do not lose them after a restart, enable cache.store: [fakeip], see cache.
Fakeip and auto_nft
This applies with auto_nft on a tproxy inbound and fakeip_for_direct: false.
- If every route of the domain in
route.rulesbypasses the process (a plaindirectorbypass), the client gets the real address with a TTL of at most 60 seconds, and the kernel carries the traffic. - If every route is a refusal,
blockanswers REFUSED andblock: dropdoes not answer.
More in tproxy.
Listeners: listen
dns.listen opens own DNS servers on the given addresses: UDP and TCP. Queries to them are handled by dns.rules, like those intercepted by hijack-dns.
yaml
dns:
upstreams:
router:
udp: 192.168.1.1
listen:
- 127.0.0.1:5353
- "[::1]:5353"
final:
upstream: router- The value is a
host:portaddress or a list of addresses; the port is required.":53"is all addresses. - For each address a
directinbound nameddns,dns-1, … (the first free one) is created, and before allrouterules a rule that sends connections from these inbounds tohijack-dns. These inbounds are visible inexplain, the dashboard and theinboundcondition of DNS rules.