Expand on DNS resolution

This commit is contained in:
Max Inden
2023-07-14 16:33:36 +09:00
parent 4c674602a6
commit ec8cda7a76
@@ -24,18 +24,20 @@ _What is an IPFS bootstrap node?_
https://docs.ipfs.tech/concepts/glossary/#bootstrap-node
- What are IPFS bootstrap nodes?
- Allows new nodes to join the IPFS network
More specifically a new node trying to join the IPFS network, i.e. trying to bootstrap, will:
- How does bootstrapping on IPFS work
- connect to the bootstrap node
- Run the Kademlia bootstrap procedure https://github.com/libp2p/specs/tree/master/kad-dht#bootstrap-process
- also known as kademlia random walk
- generate random peer id
- look it up on the DHT
- all the bootstrap nodes need to do is to respond to Kademlia find node requests and maintain a healthy routing table.
1. Connect to its (pre-) configured bootstrap nodes.
2. Run some variation of the [Kademlia bootstrap process](https://github.com/libp2p/specs/tree/master/kad-dht#bootstrap-process) which boils down to iteratively:
1. Generating random IDs.
2. Asking already discovered nodes whether they know anyone closer to those IDs.
- The addresses of bootstrap nodes are shipped within the Kubo release binary.
Thus the only thing that an IPFS bootstrap node needs to do is:
- Allow incoming connections.
- Maintain a healthy Kademlia routing table.
- Reply to Kademlia `FIND_NODE` requests based on nodes in its routing table.
Let's dive a bit deeper. In the case of Kubo the addresses of the IPFS bootstrap nodes are shipped within the release binary.
``` go
// DefaultBootstrapAddresses are the hardcoded bootstrap addresses
@@ -50,9 +52,9 @@ var DefaultBootstrapAddresses = []string{
}
```
https://github.com/ipfs/kubo/blob/4a5e99d7eaeada5596a0686fe93d4fa2da212452/config/bootstrap_peers.go#L11C1-L24C2
See [`bootstrap_peers.go` on github.com/ipfs/kubo](https://github.com/ipfs/kubo/blob/4a5e99d7eaeada5596a0686fe93d4fa2da212452/config/bootstrap_peers.go#L11C1-L24C2).
- How to discover them via `dig`?
One can translate those `/dnsaddr/...` through iterative DNS queries. For example below for the node with the peer ID `QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb`. This IPFS bootstrap node is running Kubo.
```
dig +short -t txt _dnsaddr.bootstrap.libp2p.io
@@ -74,43 +76,25 @@ dig +short -t txt _dnsaddr.am6.bootstrap.libp2p.io
"dnsaddr=/dns6/am6.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
```
Finally connecting to the bootrap node shows us the protocols it supports.
```
libp2p-lookup direct --address /dnsaddr/am6.bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
libp2p-lookup direct --address /ip6/2604:1380:4602:5c00::3/udp/4001/quic-v1/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb
Lookup for peer with id PeerId("QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb") succeeded.
Protocol version: "ipfs/0.1.0"
Agent version: "kubo/0.20.0/b8c4725"
Observed address: "/ip6/2001:ac8:40:b6::a06e/udp/35415/quic-v1"
Listen addresses:
- "/ip4/147.75.87.27/tcp/4001"
- "/ip4/147.75.87.27/udp/4001/quic"
- "/ip4/147.75.87.27/udp/4001/quic-v1"
- "/ip4/147.75.87.27/udp/4001/quic-v1/webtransport/certhash/uEiAklfaHBsO67_R1ytORipaz_4s7TlmAYmNFTi7LZeLPJQ/certhash/uEiAZgVX1dsfgsPDmKkbIO1__8wzC4RypPYAJrab5YB6F_Q"
- "/ip6/2604:1380:4602:5c00::3/tcp/4001"
- "/ip6/2604:1380:4602:5c00::3/udp/4001/quic"
- "/ip6/2604:1380:4602:5c00::3/udp/4001/quic-v1"
- "/ip6/2604:1380:4602:5c00::3/udp/4001/quic-v1/webtransport/certhash/uEiAklfaHBsO67_R1ytORipaz_4s7TlmAYmNFTi7LZeLPJQ/certhash/uEiAZgVX1dsfgsPDmKkbIO1__8wzC4RypPYAJrab5YB6F_Q"
- "/dns4/am6.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
- "/dns6/am6.bootstrap.libp2p.io/tcp/443/wss/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb"
- [...]
Protocols:
- /ipfs/ping/1.0.0
- /libp2p/circuit/relay/0.2.0/stop
- /ipfs/kad/1.0.0
- /ipfs/lan/kad/1.0.0
- /libp2p/autonat/1.0.0
- /ipfs/id/1.0.0
- /ipfs/id/push/1.0.0
- /ipfs/bitswap/1.2.0
- /ipfs/bitswap/1.1.0
- /ipfs/bitswap/1.0.0
- /ipfs/bitswap
- /x/
- /libp2p/circuit/relay/0.2.0/hop
- /libp2p/dcutr
- [...]
```
Note the `Agent version: "kubo/0.20.0/b8c4725"`.
Note the `Agent version: "kubo/0.20.0/b8c4725"` and the supported protocols `Protocols: - /ipfs/kad/1.0.0`.
# Motivation
@@ -139,35 +123,16 @@ Now deployed on IPFS bootstrap node `ny5`.
```
libp2p-lookup direct --address /dnsaddr/ny5.bootstrap.libp2p.io
Local peer id: 12D3KooWDqFbqh5PcCRAQpS8AuvpQvYqyVwtCA7PRfDjPTa1VXfx
Lookup for peer with id PeerId("QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa") succeeded.
Protocol version: "ipfs/0.1.0"
Agent version: "rust-libp2p-server/0.12.0"
Observed address: "/ip4/217.138.252.235/udp/42170/quic"
Listen addresses:
- "/ip4/10.66.201.1/tcp/4001"
- "/ip6/2604:1380:45d2:8100::1/tcp/4001"
- "/ip6/fe80::f45f:43ff:fefb:7655/tcp/4001"
- "/ip4/10.66.201.1/udp/4001/quic"
- "/ip4/172.17.0.1/tcp/4001"
- "/ip4/147.75.198.209/tcp/4001"
- "/ip4/127.0.0.1/tcp/4001"
- "/ip4/127.0.0.1/udp/4001/quic"
- "/ip6/fe80::42:2dff:fec6:72a4/tcp/4001"
- "/dns4/ny5.bootstrap.libp2p.io/tcp/443/wss/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
- "/ip4/147.75.198.209/udp/4001/quic"
- "/ip4/172.17.0.1/udp/4001/quic"
- "/dns6/ny5.bootstrap.libp2p.io/tcp/443/wss/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa"
- "/ip6/fe80::434:95ff:fe46:9d5d/tcp/4001"
- "/ip6/fe80::b696:91ff:fe6f:3248/tcp/4001"
- "/ip6/::1/tcp/4001"
- [...]
Protocols:
- /ipfs/kad/1.0.0
- /ipfs/id/push/1.0.0
- /ipfs/ping/1.0.0
- /ipfs/id/1.0.0
- /libp2p/circuit/relay/0.2.0/hop
- [...]
```
Note the `Agent version: "rust-libp2p-server/0.12.0"`.