<p>The answer is simple: it returns as many as fit in a DNS UDP packet (512 bytes).</p>

CC BY-SA 4.0
2023-05-08T18:46:09.700Z
Thank you Peter, that is informative; maar .. can you shed some light on how the addresses are chosen when the packet is filled ?  For example, btc.intersim.com shows 3681/948038 available;  when queried for IPv4 it returns 24 addresses and when queried for IPv6, only 14. (This makes sense, as less IPv6's will fit in a 512 byte UDP packet).  But how does `dnsseed` pick these out from the over 3,600 that it judges "available" ?  (in this example)
dbkeys
CC BY-SA 4.0
2023-05-08T19:00:17.530Z
Note: I have edited the question;  I originally asked how many IP's are returned; but of greater interest IMO is _how_ these are chosen from the set of nodes that `dnseed` has marked as available. Is it random or is there some priority function ?
dbkeys
CC BY-SA 4.0
2023-05-08T17:35:15.437Z
2023-05-08T17:35:15.437Z
Pieter Wuille
<p>I believe there must be a heuristic that determines which IPs are returned to clients by the seeder.</p>
<p>The seeder may have a list of hundreds of available nodes, but it only returns a reduced subset when queried.</p>
<p>Where in the code is the determination made of which IPs to return in response to a DNS query (out of all nodes the seeder is tracking and marks available)?</p>
<p><em>Note: The author of bitcoin-seeder (sipa) has stated that as many IP's as fit in a UDP data packet are returned  (So there is no <code>max_addr_return</code> variable or such similar setting)</em></p>

<peer-discovery><dns>
How does sipa's bitcoin-seeder determine which IPs to return out of all the ones it knows to be available for P2P connection?
dbkeys
# How does sipa's bitcoin-seeder determine which IPs to return out of all the ones it knows to be available for P2P connection?

(Asked by: username_0 on 2023-05-08)

I believe there must be a heuristic that determines which IPs are returned to clients by the seeder.

The seeder may have a list of hundreds of available nodes, but it only returns a reduced subset when queried.

Where in the code is the determination made of which IPs to return in response to a DNS query (out of all nodes the seeder is tracking and marks available)?

*Note: The author of bitcoin-seeder (sipa) has stated that as many IP's as fit in a UDP data packet are returned (So there is no `max_addr_return` variable or such similar setting)*

**Tags:** peer-discovery, dns


---

## 1 answers

### Answer by username_1 on 2023-05-08. Score: 3

The answer is simple: it returns as many as fit in a DNS UDP packet (512 bytes).

> **Comments:**
> **username_0**: Thank you Peter, that is informative; maar .. can you shed some light on how the addresses are chosen when the packet is filled ?  For example, btc.intersim.com shows 3681/948038 available;  when queried for IPv4 it returns 24 addresses and when queried for IPv6, only 14. (This makes sense, as less IPv6's will fit in a 512 byte UDP packet).  But how does `dnsseed` pick these out from the over 3,600 that it judges "available" ?  (in this example)  
> **username_0**: Note: I have edited the question;  I originally asked how many IP's are returned; but of greater interest IMO is _how_ these are chosen from the set of nodes that `dnseed` has marked as available. Is it random or is there some priority function ?  

---

