Skip to content

Commit f191de7

Browse files
committed
Start documenting Anonymized DNSCrypt
1 parent fc12b9f commit f191de7

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

draft-denis-dprive-dnscrypt.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,5 +467,71 @@ The Box-XChaChaPoly algorithm combines the key exchange mechanism X25519 defined
467467
- `<sk'>`: `HChaCha20(X25519(<pk>, <sk>))`
468468
- `Box-XChaChaPoly(pk, sk, m)`: `XChaCha20_DJB-Poly1305(<sk'>, <m>)`
469469

470+
# Anonymized DNSCrypt
471+
472+
While DNSCrypt encrypts DNS traffic, DNS server operators can still observe client IP addresses. Anonymized DNSCrypt is an extension to the DNSCrypt protocol that allows queries and responses to be relayed by an intermediate server, hiding the client's IP address from the resolver.
473+
474+
## Protocol Overview
475+
476+
Anonymized DNSCrypt works by having the client send encrypted queries to a relay server, which then forwards them to the actual DNSCrypt resolver. The relay server cannot decrypt the queries or responses, and the resolver only sees the relay's IP address.
477+
478+
```
479+
[Client]----(encrypted query)--->[Relay]----(encrypted query)--->[Server]
480+
[Client]<--(encrypted response)--[Relay]<--(encrypted response)--[Server]
481+
```
482+
483+
Key properties of Anonymized DNSCrypt:
484+
485+
- The relay cannot decrypt or modify queries and responses
486+
- The resolver only sees the relay's IP address, not the client's
487+
- A DNSCrypt server can simultaneously act as a relay
488+
- The protocol works over both UDP and TCP
489+
490+
## Client Queries
491+
492+
An Anonymized DNSCrypt query is a standard DNSCrypt query prefixed with information about the target server:
493+
494+
```
495+
<anondnscrypt-query> ::= <anon-magic> <server-ip> <server-port> <dnscrypt-query>
496+
```
497+
498+
Where:
499+
- `<anon-magic>`: `0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00`
500+
- `<server-ip>`: 16 bytes encoded IPv6 address (IPv4 addresses are mapped to IPv6 using `::ffff:<ipv4 address>`)
501+
- `<server-port>`: 2 bytes in big-endian format
502+
- `<dnscrypt-query>`: standard DNSCrypt query
503+
504+
For example, a query for a server at 192.0.2.1:443 would be prefixed with:
505+
```
506+
0xff 0xff 0xff 0xff 0xff 0xff 0xff 0xff 0x00 0x00
507+
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0xff 0xff 0xc0 0x00 0x02 0x01
508+
0x01 0xbb
509+
```
510+
511+
## Relay Behavior
512+
513+
Relays MUST:
514+
1. Accept queries over both TCP and UDP
515+
2. Communicate with upstream servers over UDP, even if client queries were sent over TCP
516+
3. Validate incoming packets:
517+
- Check that the target IP is not in a private range
518+
- Verify the port number is in an allowed range
519+
- Ensure the DNSCrypt query doesn't start with `<anon-magic>`
520+
- Verify the query doesn't start with 7 zero bytes (to avoid confusion with QUIC)
521+
4. Forward valid queries unmodified to the server
522+
5. Verify server responses:
523+
- Check that the response is smaller than the query
524+
- Validate the response format (either starts with resolver magic or is a certificate response)
525+
- Forward valid responses unmodified to the client
526+
527+
## Operational Considerations
528+
529+
When using Anonymized DNSCrypt:
530+
1. Clients should choose relays and servers operated by different entities
531+
2. Having relays and servers on different networks is recommended
532+
3. Relay operators should:
533+
- Refuse forwarding to reserved IP ranges
534+
- Restrict allowed server ports (typically only allowing port 443)
535+
- Monitor for abuse
470536

471537
--- back

0 commit comments

Comments
 (0)