|
1 | 1 | # BOLT #10: DNS Bootstrap and Assisted Node Location
|
2 | 2 |
|
| 3 | +## Overview |
| 4 | + |
3 | 5 | This specification describes a node discovery mechanism based on the Domain Name System (DNS).
|
4 | 6 | Its purpose is twofold:
|
5 | 7 |
|
6 | 8 | - Bootstrap: providing the initial node discovery for nodes that have no known contacts in the network
|
7 | 9 | - Assisted Node Location: supporting nodes in discovery of the current network address of previously known peers
|
8 | 10 |
|
9 |
| -A domain name server implementing this specification is called a _DNS Seed_, and answers incoming DNS queries of type `A`, `AAAA`, or `SRV` as specified in RFCs 1035<sup>[1](#ref-1)</sup>, 3596<sup>[2](#ref-2)</sup> and 2782<sup>[3](#ref-3)</sup> respectively. |
10 |
| -The DNS server is authoritative for a subdomain, called a _seed root domain_, and clients may query it for subdomains. |
| 11 | +A domain name server implementing this specification is referred to as a |
| 12 | +_DNS Seed_ and answers incoming DNS queries of type `A`, `AAAA`, or `SRV`, as |
| 13 | +specified in RFCs 1035<sup>[1](#ref-1)</sup>, 3596<sup>[2](#ref-2)</sup>, and |
| 14 | +2782<sup>[3](#ref-3)</sup>, respectively. |
| 15 | +The DNS server is authoritative for a subdomain, referred to as a |
| 16 | +_seed root domain_, and clients may query it for subdomains. |
11 | 17 |
|
12 | 18 | The subdomains consist of a number of dot-separated _conditions_ that further narrow the desired results.
|
13 | 19 |
|
| 20 | +## Table of Contents |
| 21 | + |
| 22 | + * [DNS Seed Queries](#dns-seed-queries) |
| 23 | + * [Query Semantics](#query-semantics) |
| 24 | + * [Reply Construction](#reply-construction) |
| 25 | + * [Policies](#policies) |
| 26 | + * [Examples](#examples) |
| 27 | + * [References](#references) |
| 28 | + * [Authors](#authors) |
| 29 | + |
14 | 30 | ## DNS Seed Queries
|
15 | 31 |
|
16 |
| -A client MAY issue queries using the `A`, `AAAA`, or `SRV` query types, specifying conditions for the desired results that the seed should return. |
| 32 | +A client MAY issue queries using the `A`, `AAAA`, or `SRV` query types, |
| 33 | +specifying conditions for the desired results the seed should return. |
| 34 | + |
| 35 | +Queries distinguish between _wildcard_ queries and _node_ queries, depending on |
| 36 | +whether the `l`-key is set or not. |
17 | 37 |
|
18 | 38 | ### Query Semantics
|
19 | 39 |
|
20 |
| -The conditions are key-value pairs with a single-letter key; the remainder of the key-value pair is the value. |
| 40 | +The conditions are key-value pairs: the key is a single-letter, while the |
| 41 | +remainder of the key-value pair is the value. |
21 | 42 | The following key-value pairs MUST be supported by a DNS seed:
|
22 | 43 |
|
23 |
| - - `r`: realm byte, used to specify what realm the returned nodes must support (default value: 0, Bitcoin) |
24 |
| - - `a`: address types, used to specify what address types should be returned for `SRV` queries. This is a bitfield that uses the types from [BOLT #7](07-routing-gossip.md) as bit index. This condition MAY only be used for `SRV` queries. (default value: 6, i.e. `2 || 4`, since bit 1 and bit 2 are set for IPv4 and IPv6, respectively) |
25 |
| - - `l`: `node_id`, the bech32-encoded `node_id` of a specific node, used to ask for a single node instead of a random selection. (default: null) |
26 |
| - - `n`: the number of desired reply records (default: 25) |
| 44 | + - `r`: realm byte |
| 45 | + - used to specify what realm the returned nodes must support |
| 46 | + - default value: 0 (Bitcoin) |
| 47 | + - `a`: address types |
| 48 | + - a bitfield that uses the types from [BOLT #7](07-routing-gossip.md) as bit |
| 49 | + index |
| 50 | + - used to specify what address types should be returned for `SRV` queries |
| 51 | + - MAY only be used for `SRV` queries |
| 52 | + - default value: 6 (i.e. `2 || 4`, since bit 1 and bit 2 are set for IPv4 and |
| 53 | + IPv6, respectively) |
| 54 | + - `l`: `node_id` |
| 55 | + - a bech32-encoded `node_id` of a specific node |
| 56 | + - used to ask for a single node instead of a random selection |
| 57 | + - default value: null |
| 58 | + - `n`: number of desired reply records |
| 59 | + - default value: 25 |
27 | 60 |
|
28 | 61 | Conditions are passed in the DNS seed query as individual, dot-separated subdomain components.
|
29 | 62 |
|
30 |
| -A query for `r0.a2.n10.lseed.bitcoinstats.com` would mean: Return 10 (`n10`) IPv4 (`a2`) records for nodes supporting Bitcoin (`r0`). |
31 |
| - |
32 |
| -The DNS seed MUST evaluate the conditions from the _seed root domain_ and going up-the-tree, meaning right-to-left in a fully qualified domain name. In the example above, that would be: `n10`, then `a2`, then `r0`. |
33 |
| -If a condition (key) is specified more than once, the DNS seed MUST discard any earlier value for that condition and use the new value instead. For `n5.r0.a2.n10.lseed.bitcoinstats.com`, the result is then: ~~`n10`~~, `a2`, `r0`, `n5`. |
34 |
| -Results returned by the DNS seed SHOULD match all conditions. |
35 |
| -If the DNS seed does not implement filtering by a given condition it MAY ignore the condition altogether (i.e. the seed filtering is best effort only). |
36 |
| -Clients MUST NOT rely on any given condition being met by the results. |
37 |
| - |
38 |
| -Queries distinguish between _wildcard_ queries and _node_ queries, depending on whether the `l`-key is set or not. |
39 |
| - |
40 |
| -Upon receiving a wildcard query, the DNS seed MUST select a random subset of up to `n` IPv4 or IPv6 addresses of nodes that are listening for incoming connections. |
41 |
| -For `A` and `AAAA` queries, only nodes listening on the default port 9735, as defined in [BOLT #1](01-messaging.md), MUST be returned. |
42 |
| -Since `SRV` records return a _(hostname,port)_-tuple, nodes that are listening on non-default ports MAY be returned. |
43 |
| - |
44 |
| -Upon receiving a node query, the seed MUST select the record matching the `node_id`, if any, and return all addresses associated with that node. |
| 63 | +For example, a query for `r0.a2.n10.lseed.bitcoinstats.com` would imply: return |
| 64 | +10 (`n10`) IPv4 (`a2`) records for nodes supporting Bitcoin (`r0`). |
| 65 | + |
| 66 | +### Requirements |
| 67 | + |
| 68 | +The DNS seed: |
| 69 | + - MUST evaluate the conditions from the _seed root domain_ by |
| 70 | + 'going up-the-tree', i.e. evaluating right-to-left in a fully qualified domain |
| 71 | +name. |
| 72 | + - E.g. to evaluate the above case: first evaluate `n10`, then `a2`, and finally `r0`. |
| 73 | + - if a condition (key) is specified more than once: |
| 74 | + - MUST discard any earlier value for that condition AND use the new value |
| 75 | + instead. |
| 76 | + - E.g. for `n5.r0.a2.n10.lseed.bitcoinstats.com`, the result is: |
| 77 | + ~~`n10`~~, `a2`, `r0`, `n5`. |
| 78 | + - SHOULD return results that match all conditions. |
| 79 | + - if it does NOT implement filtering by a given condition: |
| 80 | + - MAY ignore the condition altogether (i.e. the seed filtering is best effort only). |
| 81 | + - for `A` and `AAAA` queries: |
| 82 | + - MUST return only nodes listening on the default port 9735, as defined in |
| 83 | + [BOLT #1](01-messaging.md). |
| 84 | + - for `SRV` queries: |
| 85 | + - MAY return nodes that are listening on non-default ports, since `SRV` |
| 86 | + records return a _(hostname,port)_-tuple. |
| 87 | + - upon receiving a _wildcard_ query: |
| 88 | + - MUST select a random subset of up to `n` IPv4 or IPv6 addresses of nodes |
| 89 | + that are listening for incoming connections. |
| 90 | + - upon receiving a _node_ query: |
| 91 | + - MUST select the record matching the `node_id`, if any, AND return all |
| 92 | + addresses associated with that node. |
| 93 | + |
| 94 | +Querying clients: |
| 95 | + - MUST NOT rely on any given condition being met by the results. |
45 | 96 |
|
46 | 97 | ### Reply Construction
|
47 | 98 |
|
48 |
| -The results are serialized in a reply with a query type matching the client's query type, i.e. `A` queries result in `A` replies, `AAAA` queries result in `AAAA` replies, and `SRV` queries result in `SRV` replies, but they may be augmented with additional records (e.g. to add `A` or `AAAA` records matching the returned `SRV` records). |
| 99 | +The results are serialized in a reply with a query type matching the client's |
| 100 | +query type. For example, `A`, `AAAA`, and `SRV` queries respectively result in |
| 101 | +`A`, `AAAA`, and `SRV` replies. Additionally, replies may be augmented with |
| 102 | +additional records (e.g. to add `A` or `AAAA` records matching the returned |
| 103 | +`SRV` records). |
| 104 | + |
| 105 | +For `A` and `AAAA` queries, the reply contains the domain name and the IP |
| 106 | +address of the results. |
49 | 107 |
|
50 |
| -For `A` and `AAAA` queries, the reply contains the domain name and the IP address of the results. |
51 |
| -The domain name MUST match the domain in the query in order not to be filtered by intermediate resolvers. |
| 108 | +The domain name MUST match the domain in the query, in order not to be filtered |
| 109 | +by intermediate resolvers. |
52 | 110 |
|
53 | 111 | For `SRV` queries, the reply consists of (_virtual hostnames_, port)-tuples.
|
54 |
| -A virtual hostname is a subdomain of the seed root domain that uniquely identifies a node in the network. |
| 112 | +A virtual hostname is a subdomain of the seed root domain that uniquely |
| 113 | +identifies a node in the network. |
55 | 114 | It is constructed by prepending the `node_id` condition to the seed root domain.
|
56 |
| -The DNS seed MAY additionally return the corresponding `A` and `AAAA` records that indicate the IP address for the `SRV` entries in the Extra section of the reply. |
57 |
| -Due to the large size of the resulting reply, the reply may be dropped by intermediate resolvers, hence the DNS seed MAY omit these additional records upon detecting a repeated query. |
58 | 115 |
|
59 |
| -Should no entries match all the conditions then an empty reply MUST be returned. |
| 116 | +The DNS seed: |
| 117 | + - MAY additionally return the corresponding `A` and `AAAA` records that |
| 118 | + indicate the IP address for the `SRV` entries in the additional section of the |
| 119 | + reply. |
| 120 | +- MAY omit these additional records upon detecting a repeated query. |
| 121 | + - Reason: due to the large size of the resulting reply, the reply may be |
| 122 | + dropped by intermediate resolvers. |
| 123 | +- if no entries match all the conditions: |
| 124 | + - MUST return an empty reply. |
60 | 125 |
|
61 | 126 | ## Policies
|
62 | 127 |
|
63 |
| -The DNS seed MUST NOT return replies with a TTL lower than 60 seconds. |
64 |
| -The DNS seed MAY filter nodes from its local views for various reasons, including faulty nodes, flaky nodes, or spam prevention. |
65 |
| -In accordance with the Bitcoin DNS Seed policy<sup>[4](#ref-4)</sup>, replies to random queries (i.e. queries to the seed root domain and to the `_nodes._tcp.` alias for `SRV` queries) MUST be random samples from the set of all known good nodes and MUST NOT be biased. |
| 128 | +The DNS seed: |
| 129 | + - MUST NOT return replies with a TTL less than 60 seconds. |
| 130 | + - MAY filter nodes from its local views for various reasons, including faulty |
| 131 | + nodes, flaky nodes, or spam prevention. |
| 132 | + - MUST reply to random queries (i.e. queries to the seed root domain and to |
| 133 | + the `_nodes._tcp.` alias for `SRV` queries) with _random and unbiased_ |
| 134 | + samples from the set of all known good nodes, in accordance with the Bitcoin DNS Seed policy<sup>[4](#ref-4)</sup>. |
66 | 135 |
|
67 | 136 | ## Examples
|
68 | 137 |
|
@@ -102,3 +171,11 @@ Querying for only IPv6 nodes (`a4`) supporting Bitcoin (`r0`) via seed filtering
|
102 | 171 | - <a id="ref-2">[RFC 3596 - DNS Extensions to Support IP Version 6](https://tools.ietf.org/html/rfc3596)</a>
|
103 | 172 | - <a id="ref-3">[RFC 2782 - A DNS RR for specifying the location of services (DNS SRV)](https://www.ietf.org/rfc/rfc2782.txt)</a>
|
104 | 173 | - <a id="ref-4">[Expectations for DNS Seed operators](https://github.com/bitcoin/bitcoin/blob/master/doc/dnsseed-policy.md)</a>
|
| 174 | + |
| 175 | +## Authors |
| 176 | + |
| 177 | +[ FIXME: Insert Author List ] |
| 178 | + |
| 179 | + |
| 180 | +<br> |
| 181 | +This work is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). |
0 commit comments