configure-discovery.md
1 --- 2 title: Configure Peer Discovery 3 hide_table_of_contents: true 4 displayed_sidebar: runNode 5 --- 6 7 This guide provides detailed steps to configure a `nwaku` node to discover and connect with peers in the Waku Network. 8 9 :::info 10 You can configure a `nwaku` node to use multiple peer discovery mechanisms simultaneously. 11 ::: 12 13 ## Configure static peers 14 15 You can provide [static peers](/learn/concepts/static-peers) to a `nwaku` node during startup using the `staticnode` configuration option. To connect to multiple peers on startup, repeat the `staticnode` option: 16 17 ```shell 18 ./build/wakunode2 \ 19 --staticnode=[PEER MULTIADDR 1] \ 20 --staticnode=[PEER MULTIADDR 2] 21 ``` 22 23 For example, consider a `nwaku` node that connects to two static peers on the same local host (IP: `0.0.0.0`) using TCP ports `60002` and `60003`: 24 25 ```shell 26 ./build/wakunode2 \ 27 --staticnode=/ip4/0.0.0.0/tcp/60002/p2p/16Uiu2HAkzjwwgEAXfeGNMKFPSpc6vGBRqCdTLG5q3Gmk2v4pQw7H \ 28 --staticnode=/ip4/0.0.0.0/tcp/60003/p2p/16Uiu2HAmFBA7LGtwY5WVVikdmXVo3cKLqkmvVtuDu63fe8safeQJ 29 ``` 30 31 ## Configure DNS discovery 32 33 To enable [DNS Discovery](/learn/concepts/dns-discovery) in a `nwaku` node, use the following configuration options: 34 35 - `dns-discovery`: Enables `DNS Discovery` on the node (disabled by default). 36 - `dns-discovery-url`: URL for DNS node list in the format `enrtree://<key>@<fqdn>` where `<fqdn>` is the fully qualified domain name and `<key>` is the base32 encoding of the compressed 32-byte public key that signed the list at that location. 37 - `dns-discovery-name-server` (optional): DNS name server IPs to query. You can repeat this option to provide multiple DNS name servers. 38 39 ```shell 40 ./build/wakunode2 \ 41 --dns-discovery=true \ 42 --dns-discovery-url=enrtree://[PUBLIC KEY]@[DOMAIN NAME] \ 43 --dns-discovery-name-server=[DNS NAME SERVER IP] 44 ``` 45 46 :::info 47 If you omit the `dns-discovery-name-server` option, `nwaku` will attempt to use the CloudFlare servers `1.1.1.1` and `1.0.0.1`. 48 ::: 49 50 For example, consider a `nwaku` node that enables `DNS Discovery`, connects to a DNS node list, and queries the IPs `8.8.8.8` and `8.8.4.4`: 51 52 ```shell 53 ./build/wakunode2 \ 54 --dns-discovery=true \ 55 --dns-discovery-url=enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im \ 56 --dns-discovery-name-server=8.8.8.8 \ 57 --dns-discovery-name-server=8.8.4.4 58 ``` 59 60 ## Configure Discv5 61 62 To enable [Discv5](/learn/concepts/discv5) in a `nwaku` node, use the following configuration options: 63 64 - `discv5-discovery`: Enables `Discv5` on the node (disabled by default). 65 - `discv5-bootstrap-node`: ENR for `Discv5` routing table bootstrap node. You can repeat this option to provide multiple bootstrap entries. 66 67 ```shell 68 ./build/wakunode2 \ 69 --discv5-discovery=true \ 70 --discv5-bootstrap-node=[DISCV5 ENR BOOTSTRAP ENTRY 1] \ 71 --discv5-bootstrap-node=[DISCV5 ENR BOOTSTRAP ENTRY 2] 72 ``` 73 74 For example, consider a `nwaku` node that enables `Discv5` and bootstraps its routing table using a static `ENR`: 75 76 ```shell 77 ./build/wakunode2 \ 78 --discv5-discovery=true \ 79 --discv5-bootstrap-node=enr:-IO4QDxToTg86pPCK2KvMeVCXC2ADVZWrxXSvNZeaoa0JhShbM5qed69RQz1s1mWEEqJ3aoklo_7EU9iIBcPMVeKlCQBgmlkgnY0iXNlY3AyNTZrMaEDdBHK1Gx6y_zv5DVw5Qb3DtSOMmVHTZO1WSORrF2loL2DdWRwgiMohXdha3UyAw 80 ``` 81 82 :::info 83 When Discv5 is enabled and used with [DNS Discovery](#configure-dns-discovery), the `nwaku` node will attempt to bootstrap the Discv5 routing table by extracting `ENRs` from peers discovered through DNS. 84 ::: 85 86 ## Configure peer exchange 87 88 To enable [Peer Exchange](/learn/concepts/peer-exchange) in a `nwaku` node, use the following configuration options: 89 90 - `peer-exchange`: Enables `Peer Exchange` on the node as a responder (disabled by default). 91 - `peer-exchange-node` (optional): Multiaddr for bootstrap node with the peer exchange protocol enabled. 92 93 ```shell 94 ./build/wakunode2 \ 95 --peer-exchange=true \ 96 --peer-exchange-node=[PEER MULTIADDR WITH EXCHANGE ENABLED] 97 ``` 98 99 For example, consider two `nwaku` nodes configured as a `server` (peer exchange responder node) and `client` (node using peer exchange) on the same local host (IP: `0.0.0.0`): 100 101 ```shell title="Server: Nwaku Node with Peer Exchange Enabled" 102 ./build/wakunode2 --peer-exchange=true 103 ``` 104 105 ```shell title="Client: Nwaku Node Bootstrapping with Peer Exchange" 106 ./build/wakunode2 \ 107 --tcp-port=30305 \ 108 --ports-shift=1 \ 109 --peer-exchange-node=/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmLCe6zVqCS6KMqqRbbhyoJjfYZGr1Q3thTSbyKzibQkFR 110 ``` 111 112 :::info 113 `nwaku` provides a [`relay-peer-exchange`](/run-node/config-options#relay-config) option via `libp2p` for peer exchange, allowing network growth through neighbouring nodes. However, this feature can compromise security and network robustness, so we recommend only using it in high-trust environments. 114 :::