7 Network Working Group R. Bellis
8 Request for Comments: 5625 Nominet UK
10 Category: Best Current Practice
13 DNS Proxy Implementation Guidelines
17 This document provides guidelines for the implementation of DNS
18 proxies, as found in broadband gateways and other similar network
23 This document specifies an Internet Best Current Practices for the
24 Internet Community, and requests discussion and suggestions for
25 improvements. Distribution of this memo is unlimited.
29 Copyright (c) 2009 IETF Trust and the persons identified as the
30 document authors. All rights reserved.
32 This document is subject to BCP 78 and the IETF Trust's Legal
33 Provisions Relating to IETF Documents in effect on the date of
34 publication of this document (http://trustee.ietf.org/license-info).
35 Please review these documents carefully, as they describe your rights
36 and restrictions with respect to this document.
58 Bellis Best Current Practice [Page 1]
60 RFC 5625 DNS Proxy Implementation Guidelines August 2009
65 1. Introduction ....................................................2
66 2. Terminology .....................................................3
67 3. The Transparency Principle ......................................3
68 4. Protocol Conformance ............................................4
69 4.1. Unexpected Flags and Data ..................................4
70 4.2. Label Compression ..........................................4
71 4.3. Unknown Resource Record Types ..............................4
72 4.4. Packet Size Limits .........................................4
73 4.4.1. TCP Transport .......................................5
74 4.4.2. Extension Mechanisms for DNS (EDNS0) ................6
75 4.4.3. IP Fragmentation ....................................6
76 4.5. Secret Key Transaction Authentication for DNS (TSIG) .......7
77 5. DHCP's Interaction with DNS .....................................7
78 5.1. Domain Name Server (DHCP Option 6) .........................7
79 5.2. Domain Name (DHCP Option 15) ...............................8
80 5.3. DHCP Leases ................................................8
81 6. Security Considerations .........................................9
82 6.1. Forgery Resilience .........................................9
83 6.2. Interface Binding .........................................10
84 6.3. Packet Filtering ..........................................10
85 7. Acknowledgements ...............................................10
86 8. References .....................................................11
87 8.1. Normative References ......................................11
88 8.2. Informative References ....................................12
92 Research has found ([SAC035], [DOTSE]) that many commonly used
93 broadband gateways (and similar devices) contain DNS proxies that are
94 incompatible in various ways with current DNS standards.
96 These proxies are usually simple DNS forwarders, but typically do not
97 have any caching capabilities. The proxy serves as a convenient
98 default DNS resolver for clients on the LAN, but relies on an
99 upstream resolver (e.g., at an ISP) to perform recursive DNS lookups.
101 Note that to ensure full DNS protocol interoperability it is
102 preferred that client stub resolvers should communicate directly with
103 full-feature, upstream recursive resolvers wherever possible.
105 That notwithstanding, this document describes the incompatibilities
106 that have been discovered and offers guidelines to implementors on
107 how to provide better interoperability in those cases where the
108 client must use the broadband gateway's DNS proxy.
114 Bellis Best Current Practice [Page 2]
116 RFC 5625 DNS Proxy Implementation Guidelines August 2009
121 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
122 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
123 document are to be interpreted as described in [RFC2119].
125 3. The Transparency Principle
127 It is not considered practical for a simple DNS proxy to implement
128 all current and future DNS features.
130 There are several reasons why this is the case:
132 o Broadband gateways usually have limited hardware resources.
134 o Firmware upgrade cycles are long, and many users do not routinely
135 apply upgrades when they become available.
137 o No one knows what those future DNS features will be or how they
138 might be implemented.
140 o Doing so would substantially complicate the configuration user
141 interface (UI) of the device.
143 Furthermore, some modern DNS protocol extensions (see, e.g., EDNS0
144 below) are intended to be used as "hop-by-hop" mechanisms. If the
145 DNS proxy is considered to be such a "hop" in the resolution chain,
146 then for it to function correctly, it would need to be fully
147 compliant with all such mechanisms.
149 [SAC035] shows that the more actively a proxy participates in the DNS
150 protocol, the more likely it is that it will somehow interfere with
151 the flow of messages between the DNS client and the upstream
154 The role of the proxy should therefore be no more and no less than to
155 receive DNS requests from clients on the LAN side, forward those
156 verbatim to one of the known upstream recursive resolvers on the WAN
157 side, and ensure that the whole response is returned verbatim to the
160 It is RECOMMENDED that proxies should be as transparent as possible,
161 such that any "hop-by-hop" mechanisms or newly introduced protocol
162 extensions operate as if the proxy were not there.
164 Except when required to enforce an active security or network policy
165 (such as maintaining a pre-authentication "walled garden"), end-users
166 SHOULD be able to send their DNS queries to specified upstream
170 Bellis Best Current Practice [Page 3]
172 RFC 5625 DNS Proxy Implementation Guidelines August 2009
175 resolvers, thereby bypassing the proxy altogether. In this case, the
176 gateway SHOULD NOT modify the DNS request or response packets in any
179 4. Protocol Conformance
181 4.1. Unexpected Flags and Data
183 The Transparency Principle above, when combined with Postel's
184 Robustness Principle [RFC0793], suggests that DNS proxies should not
185 arbitrarily reject or otherwise drop requests or responses based on
186 perceived non-compliance with standards.
188 For example, some proxies have been observed to drop any packet
189 containing either the "Authentic Data" (AD) or "Checking Disabled"
190 (CD) bits from DNSSEC [RFC4035]. This may be because [RFC1035]
191 originally specified that these unused "Z" flag bits "MUST" be zero.
192 However, these flag bits were always intended to be reserved for
193 future use, so refusing to proxy any packet containing these flags
194 (now that uses for those flags have indeed been defined) is not
197 Therefore, proxies MUST ignore any unknown DNS flags and proxy those
200 4.2. Label Compression
202 Compression of labels as per Section 4.1.4 of [RFC1035] is optional.
204 Proxies MUST forward packets regardless of the presence or absence of
205 compressed labels therein.
207 4.3. Unknown Resource Record Types
209 [RFC3597] requires that resolvers MUST handle Resource Records (RRs)
210 of unknown type transparently.
212 All requests and responses MUST be proxied regardless of the values
213 of the QTYPE and QCLASS fields.
215 Similarly, all responses MUST be proxied regardless of the values of
216 the TYPE and CLASS fields of any Resource Record therein.
218 4.4. Packet Size Limits
220 [RFC1035] specifies that the maximum size of the DNS payload in a UDP
221 packet is 512 octets. Where the required portions of a response
222 would not fit inside that limit, the DNS server MUST set the
226 Bellis Best Current Practice [Page 4]
228 RFC 5625 DNS Proxy Implementation Guidelines August 2009
231 "TrunCation" (TC) bit in the DNS response header to indicate that
232 truncation has occurred. There are however two standard mechanisms
233 (described in Sections 4.4.1 and 4.4.2) for transporting responses
234 larger than 512 octets.
236 Many proxies have been observed to truncate all responses at 512
237 octets, and others at a packet size related to the WAN MTU, in either
238 case doing so without correctly setting the TC bit.
240 Other proxies have been observed to remove the TC bit in server
241 responses that correctly had the TC bit set by the server.
243 If a DNS response is truncated but the TC bit is not set, then client
244 failures may result. In particular, a naive DNS client library might
245 suffer crashes due to reading beyond the end of the data actually
248 Since UDP packets larger than 512 octets are now expected in normal
249 operation, proxies SHOULD NOT truncate UDP packets that exceed that
250 size. See Section 4.4.3 for recommendations for packet sizes
251 exceeding the WAN MTU.
253 If a proxy must unilaterally truncate a response, then the proxy MUST
254 set the TC bit. Similarly, proxies MUST NOT remove the TC bit from
259 Should a UDP query fail because of truncation, the standard fail-over
260 mechanism is to retry the query using TCP, as described in Section
261 6.1.3.2 of [RFC1123].
263 Whilst TCP transport is not strictly mandatory, it is supported by
264 the vast majority of stub resolvers and recursive servers. Lack of
265 support in the proxy prevents this fail-over mechanism from working.
267 DNS proxies MUST therefore be prepared to receive and forward queries
270 Note that it is unlikely that a client would send a request over TCP
271 unless it had already received a truncated UDP response. Some
272 "smart" proxies have been observed to first forward any request
273 received over TCP to an upstream resolver over UDP, only for the
274 response to be truncated, causing the proxy to retry over TCP. Such
275 behaviour increases network traffic and causes delay in DNS
276 resolution since the initial UDP request is doomed to fail.
282 Bellis Best Current Practice [Page 5]
284 RFC 5625 DNS Proxy Implementation Guidelines August 2009
287 Therefore, whenever a proxy receives a request over TCP, the proxy
288 SHOULD forward the query over TCP and SHOULD NOT attempt the same
289 query over UDP first.
291 4.4.2. Extension Mechanisms for DNS (EDNS0)
293 The "Extension Mechanism for DNS" [RFC2671] was introduced to allow
294 the transport of larger DNS packets over UDP and also to allow for
295 additional request and response flags.
297 A client may send an OPT Resource Record (OPT RR) in the Additional
298 Section of a request to indicate that it supports a specific receive
299 buffer size. The OPT RR also includes the "DNSSEC OK" (DO) flag used
300 by DNSSEC to indicate that DNSSEC-related RRs should be returned to
303 However, some proxies have been observed to either reject (with a
304 FORMERR response code) or black-hole any packet containing an OPT RR.
305 As per Section 4.1, proxies MUST NOT refuse to proxy such packets.
307 4.4.3. IP Fragmentation
309 Support for UDP packet sizes exceeding the WAN MTU depends on the
310 gateway's algorithm for handling fragmented IP packets. Several
311 methods are possible:
313 1. Fragments are dropped.
315 2. Fragments are forwarded individually as they're received.
317 3. Complete packets are reassembled on the gateway and then re-
318 fragmented (if necessary) as they're forwarded to the client.
320 Method 1 above will cause compatibility problems with EDNS0 unless
321 the DNS client is configured to advertise an EDNS0 buffer size
322 limited to the WAN MTU less the size of the IP header. Note that RFC
323 2671 does recommend that the path MTU should be taken into account
326 Also, whilst the EDNS0 specification allows for a buffer size of up
327 to 65535 octets, most common DNS server implementations do not
328 support a buffer size above 4096 octets.
330 Therefore (irrespective of which of the above methods is in use),
331 proxies SHOULD be capable of forwarding UDP packets up to a payload
332 size of at least 4096 octets.
338 Bellis Best Current Practice [Page 6]
340 RFC 5625 DNS Proxy Implementation Guidelines August 2009
343 NB: in theory, IP fragmentation may also occur if the LAN MTU is
344 smaller than the WAN MTU, although the author has not observed such a
345 configuration in use on any residential broadband service.
347 4.5. Secret Key Transaction Authentication for DNS (TSIG)
349 [RFC2845] defines TSIG, which is a mechanism for authenticating DNS
350 requests and responses at the packet level.
352 Any modifications made to the DNS portions of a TSIG-signed query or
353 response packet (with the exception of the Query ID) will cause a
354 TSIG authentication failure.
356 DNS proxies MUST implement Section 4.7 of [RFC2845] and either
357 forward packets unchanged (as recommended above) or fully implement
360 As per Section 4.3, DNS proxies MUST be capable of proxying packets
361 containing TKEY [RFC2930] Resource Records.
363 NB: any DNS proxy (such as those commonly found in WiFi hotspot
364 "walled gardens") that transparently intercepts all DNS queries and
365 that returns unsigned responses to signed queries, will also cause
366 TSIG authentication failures.
368 5. DHCP's Interaction with DNS
370 Whilst this document is primarily about DNS proxies, most consumers
371 rely on DHCP [RFC2131] to obtain network configuration settings.
372 Such settings include the client machine's IP address, subnet mask,
373 and default gateway, but also include DNS-related settings.
375 It is therefore appropriate to examine how DHCP affects client DNS
378 5.1. Domain Name Server (DHCP Option 6)
380 Most gateways default to supplying their own IP address in the DHCP
381 "Domain Name Server" option [RFC2132]. The net result is that
382 without explicit re-configuration many DNS clients will, by default,
383 send queries to the gateway's DNS proxy. This is understandable
384 behaviour given that the correct upstream settings are not usually
394 Bellis Best Current Practice [Page 7]
396 RFC 5625 DNS Proxy Implementation Guidelines August 2009
399 Most gateways learn their own DNS settings via values supplied by an
400 ISP via DHCP or PPP over the WAN interface. However, whilst many
401 gateways do allow the device administrator to override those values,
402 some gateways only use those supplied values to affect the proxy's
403 own forwarding function, and do not offer these values via DHCP.
405 When using such a device, the only way to avoid using the DNS proxy
406 is to hard-code the required values in the client operating system.
407 This may be acceptable for a desktop system but it is inappropriate
408 for mobile devices that are regularly used on many different
411 As per Section 3, end-users SHOULD be able to send their DNS queries
412 directly to specified upstream resolvers, ideally without hard-coding
413 those settings in their stub resolver.
415 It is therefore RECOMMENDED that gateways SHOULD support device-
416 administrator configuration of values for the "Domain Name Server"
419 5.2. Domain Name (DHCP Option 15)
421 A significant amount of traffic to the DNS Root Name Servers is for
422 invalid top-level domain names, and some of that traffic can be
423 attributed to particular equipment vendors whose firmware defaults
424 this DHCP option to specific values.
426 Since no standard exists for a "local" scoped domain name suffix, it
427 is RECOMMENDED that the default value for this option SHOULD be
428 empty, and that this option MUST NOT be sent to clients when no value
433 It is noted that some DHCP servers in broadband gateways offer, by
434 default, their own IP address for the "Domain Name Server" option (as
435 described above) but then automatically start offering the upstream
436 servers' addresses once they've been learnt over the WAN interface.
438 In general, this behaviour is highly desirable, but the effect for
439 the end-user is that the settings used depend on whether the DHCP
440 lease was obtained before or after the WAN link was established.
442 If the DHCP lease is obtained whilst the WAN link is down, then the
443 DHCP client (and hence the DNS client) will not receive the correct
444 values until the DHCP lease is renewed.
450 Bellis Best Current Practice [Page 8]
452 RFC 5625 DNS Proxy Implementation Guidelines August 2009
455 Whilst no specific recommendations are given here, vendors may wish
456 to give consideration to the length of DHCP leases and to whether
457 some mechanism for forcing a DHCP lease renewal might be appropriate.
459 Another possibility is that the learnt upstream values might be
460 persisted in non-volatile memory such that on reboot the same values
461 can be automatically offered via DHCP. However, this does run the
462 risk that incorrect values are initially offered if the device is
463 moved or connected to another ISP.
465 Alternatively, the DHCP server might only issue very short (i.e., 60
466 second) leases while the WAN link is down, only reverting to more
467 typical lease lengths once the WAN link is up and the upstream DNS
468 servers are known. Indeed, with such a configuration it may be
469 possible to avoid the need to implement a DNS proxy function in the
470 broadband gateway at all.
472 6. Security Considerations
474 This document introduces no new protocols. However, there are some
475 security-related recommendations for vendors that are listed here.
477 6.1. Forgery Resilience
479 Whilst DNS proxies are not usually full-feature resolvers, they
480 nevertheless share some characteristics with them.
482 Notwithstanding the recommendations above about transparency, many
483 DNS proxies are observed to pick a new Query ID for outbound requests
484 to ensure that responses are directed to the correct client.
486 NB: changing the Query ID is acceptable and compatible with proxying
487 TSIG-signed packets since the TSIG signature calculation is based on
488 the original message ID, which is carried in the TSIG RR.
490 It has been standard guidance for many years that each DNS query
491 should use a randomly generated Query ID. However, many proxies have
492 been observed picking sequential Query IDs for successive requests.
494 It is strongly RECOMMENDED that DNS proxies follow the relevant
495 recommendations in [RFC5452], particularly those in Section 9.2
496 relating to randomisation of Query IDs and source ports. This also
497 applies to source port selection within any NAT function.
499 If a DNS proxy is running on a broadband gateway with NAT that is
500 compliant with [RFC4787], then it SHOULD also follow the
501 recommendations in Section 10 of [RFC5452] concerning how long DNS
506 Bellis Best Current Practice [Page 9]
508 RFC 5625 DNS Proxy Implementation Guidelines August 2009
511 6.2. Interface Binding
513 Some gateways have been observed to have their DNS proxy listening on
514 both internal (LAN) and external (WAN) interfaces. In this
515 configuration, it is possible for the proxy to be used to mount
516 reflector attacks as described in [RFC5358].
518 The DNS proxy in a gateway SHOULD NOT, by default, be accessible from
519 the WAN interfaces of the device.
521 6.3. Packet Filtering
523 The Transparency and Robustness Principles are not entirely
524 compatible with the deep packet-inspection features of security
525 appliances such as firewalls, which are intended to protect systems
526 on the inside of a network from rogue traffic.
528 However, a clear distinction may be made between traffic that is
529 intrinsically malformed and that which merely contains unexpected
532 Examples of malformed packets that MAY be dropped include:
534 o invalid compression pointers (i.e., those that point outside of
535 the current packet or that might cause a parsing loop)
537 o incorrect counts for the Question, Answer, Authority, and
538 Additional Sections (although care should be taken where
539 truncation is a possibility)
541 Dropped packets will cause the client to repeatedly retransmit the
542 original request, with the client only detecting the error after
543 several retransmit intervals.
545 In these circumstances, proxies SHOULD synthesise a suitable DNS
546 error response to the client (i.e., SERVFAIL) instead of dropping the
547 packet completely. This will allow the client to detect the error
552 The author would particularly like to acknowledge the assistance of
553 Lisa Phifer of Core Competence. In addition, the author is grateful
554 for the feedback from the members of the DNSEXT Working Group.
562 Bellis Best Current Practice [Page 10]
564 RFC 5625 DNS Proxy Implementation Guidelines August 2009
569 8.1. Normative References
571 [RFC0793] Postel, J., "Transmission Control Protocol", STD 7,
572 RFC 793, September 1981.
574 [RFC1035] Mockapetris, P., "Domain names - implementation and
575 specification", STD 13, RFC 1035, November 1987.
577 [RFC1123] Braden, R., "Requirements for Internet Hosts - Application
578 and Support", STD 3, RFC 1123, October 1989.
580 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
581 Requirement Levels", BCP 14, RFC 2119, March 1997.
583 [RFC2131] Droms, R., "Dynamic Host Configuration Protocol",
584 RFC 2131, March 1997.
586 [RFC2132] Alexander, S. and R. Droms, "DHCP Options and BOOTP Vendor
587 Extensions", RFC 2132, March 1997.
589 [RFC2671] Vixie, P., "Extension Mechanisms for DNS (EDNS0)",
590 RFC 2671, August 1999.
592 [RFC2845] Vixie, P., Gudmundsson, O., Eastlake, D., and B.
593 Wellington, "Secret Key Transaction Authentication for DNS
594 (TSIG)", RFC 2845, May 2000.
596 [RFC2930] Eastlake, D., "Secret Key Establishment for DNS (TKEY
597 RR)", RFC 2930, September 2000.
599 [RFC3597] Gustafsson, A., "Handling of Unknown DNS Resource Record
600 (RR) Types", RFC 3597, September 2003.
602 [RFC4035] Arends, R., Austein, R., Larson, M., Massey, D., and S.
603 Rose, "Protocol Modifications for the DNS Security
604 Extensions", RFC 4035, March 2005.
606 [RFC4787] Audet, F. and C. Jennings, "Network Address Translation
607 (NAT) Behavioral Requirements for Unicast UDP", BCP 127,
608 RFC 4787, January 2007.
610 [RFC5358] Damas, J. and F. Neves, "Preventing Use of Recursive
611 Nameservers in Reflector Attacks", BCP 140, RFC 5358,
618 Bellis Best Current Practice [Page 11]
620 RFC 5625 DNS Proxy Implementation Guidelines August 2009
623 [RFC5452] Hubert, A. and R. van Mook, "Measures for Making DNS More
624 Resilient against Forged Answers", RFC 5452, January 2009.
626 8.2. Informative References
628 [DOTSE] Ahlund and Wallstrom, "DNSSEC Tests of Consumer Broadband
629 Routers", February 2008,
630 <http://www.iis.se/docs/Routertester_en.pdf>.
632 [SAC035] Bellis, R. and L. Phifer, "Test Report: DNSSEC Impact on
633 Broadband Routers and Firewalls", September 2008,
634 <http://www.icann.org/committees/security/sac035.pdf>.
644 Phone: +44 1865 332211
645 EMail: ray.bellis@nominet.org.uk
646 URI: http://www.nominet.org.uk/
674 Bellis Best Current Practice [Page 12]