2023-06-16 09:40:22 +01:00
---
title: Configure Peer Discovery
2023-11-23 12:01:32 +01:00
hide_table_of_contents: true
2025-10-03 15:54:25 +10:00
displayed_sidebar: runNode
2023-06-16 09:40:22 +01:00
---
2023-06-20 12:41:55 +01:00
This guide provides detailed steps to configure a `nwaku` node to discover and connect with peers in the Waku Network.
2023-06-16 09:40:22 +01:00
2023-07-11 18:52:38 +01:00
:::info
2023-06-16 09:40:22 +01:00
You can configure a `nwaku` node to use multiple peer discovery mechanisms simultaneously.
:::
2023-11-23 12:01:32 +01:00
## Configure static peers
2023-06-16 09:40:22 +01:00
2023-11-23 12:01:32 +01:00
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:
2023-06-16 09:40:22 +01:00
2023-11-23 12:01:32 +01:00
```shell
2023-06-18 09:34:09 +01:00
./build/wakunode2 \
2023-07-07 02:17:02 +01:00
--staticnode=[PEER MULTIADDR 1] \
--staticnode=[PEER MULTIADDR 2]
2023-06-16 09:40:22 +01:00
```
2023-07-11 18:52:38 +01:00
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` :
2023-06-18 09:34:09 +01:00
2023-11-23 12:01:32 +01:00
```shell
2023-06-18 09:34:09 +01:00
./build/wakunode2 \
2023-07-07 02:17:02 +01:00
--staticnode=/ip4/0.0.0.0/tcp/60002/p2p/16Uiu2HAkzjwwgEAXfeGNMKFPSpc6vGBRqCdTLG5q3Gmk2v4pQw7H \
--staticnode=/ip4/0.0.0.0/tcp/60003/p2p/16Uiu2HAmFBA7LGtwY5WVVikdmXVo3cKLqkmvVtuDu63fe8safeQJ
2023-06-18 09:34:09 +01:00
```
2023-11-23 12:01:32 +01:00
## Configure DNS discovery
2023-06-16 09:40:22 +01:00
2023-11-23 12:01:32 +01:00
To enable [DNS Discovery ](/learn/concepts/dns-discovery ) in a `nwaku` node, use the following configuration options:
2023-06-16 09:40:22 +01:00
2023-07-07 02:17:02 +01:00
- `dns-discovery` : Enables `DNS Discovery` on the node (disabled by default).
2023-06-16 09:40:22 +01:00
- `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.
- `dns-discovery-name-server` (optional): DNS name server IPs to query. You can repeat this option to provide multiple DNS name servers.
2023-11-23 12:01:32 +01:00
```shell
2023-06-18 09:34:09 +01:00
./build/wakunode2 \
2023-07-07 02:17:02 +01:00
--dns-discovery=true \
2023-08-03 06:40:57 +01:00
--dns-discovery-url=enrtree://[PUBLIC KEY]@[DOMAIN NAME] \
2023-07-07 02:17:02 +01:00
--dns-discovery-name-server=[DNS NAME SERVER IP]
2023-06-16 09:40:22 +01:00
```
2023-06-18 09:34:09 +01:00
2023-06-22 11:46:26 +01:00
:::info
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` .
:::
2023-07-11 18:52:38 +01:00
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` :
2023-06-18 09:34:09 +01:00
2023-11-23 12:01:32 +01:00
```shell
2023-06-18 09:34:09 +01:00
./build/wakunode2 \
2023-07-07 02:17:02 +01:00
--dns-discovery=true \
2024-03-17 20:29:48 +01:00
--dns-discovery-url=enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox .waku.nodes.status.im \
2023-07-07 02:17:02 +01:00
--dns-discovery-name-server=8.8.8.8 \
--dns-discovery-name-server=8.8.4.4
2023-06-16 09:40:22 +01:00
```
## Configure Discv5
2023-11-23 12:01:32 +01:00
To enable [Discv5 ](/learn/concepts/discv5 ) in a `nwaku` node, use the following configuration options:
2023-06-18 09:34:09 +01:00
2023-07-07 02:17:02 +01:00
- `discv5-discovery` : Enables `Discv5` on the node (disabled by default).
- `discv5-bootstrap-node` : ENR for `Discv5` routing table bootstrap node. You can repeat this option to provide multiple bootstrap entries.
2023-06-16 09:40:22 +01:00
2023-11-23 12:01:32 +01:00
```shell
2023-06-18 09:34:09 +01:00
./build/wakunode2 \
2023-07-07 02:17:02 +01:00
--discv5-discovery=true \
--discv5-bootstrap-node=[DISCV5 ENR BOOTSTRAP ENTRY 1] \
--discv5-bootstrap-node=[DISCV5 ENR BOOTSTRAP ENTRY 2]
2023-06-16 09:40:22 +01:00
```
2023-07-11 18:52:38 +01:00
For example, consider a `nwaku` node that enables `Discv5` and bootstraps its routing table using a static `ENR` :
2023-06-18 09:34:09 +01:00
2023-11-23 12:01:32 +01:00
```shell
2023-06-18 09:34:09 +01:00
./build/wakunode2 \
2023-07-07 02:17:02 +01:00
--discv5-discovery=true \
--discv5-bootstrap-node=enr:-IO4QDxToTg86pPCK2KvMeVCXC2ADVZWrxXSvNZeaoa0JhShbM5qed69RQz1s1mWEEqJ3aoklo_7EU9iIBcPMVeKlCQBgmlkgnY0iXNlY3AyNTZrMaEDdBHK1Gx6y_zv5DVw5Qb3DtSOMmVHTZO1WSORrF2loL2DdWRwgiMohXdha3UyAw
2023-06-18 09:34:09 +01:00
```
2023-06-16 09:40:22 +01:00
:::info
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.
2023-07-07 02:17:02 +01:00
:::
2023-11-23 12:01:32 +01:00
## Configure peer exchange
2023-07-07 02:17:02 +01:00
2023-11-23 12:01:32 +01:00
To enable [Peer Exchange ](/learn/concepts/peer-exchange ) in a `nwaku` node, use the following configuration options:
2023-07-07 02:17:02 +01:00
- `peer-exchange` : Enables `Peer Exchange` on the node as a responder (disabled by default).
2023-08-01 20:39:04 +01:00
- `peer-exchange-node` (optional): Multiaddr for bootstrap node with the peer exchange protocol enabled.
2023-07-07 02:17:02 +01:00
2023-11-23 12:01:32 +01:00
```shell
2023-07-07 02:17:02 +01:00
./build/wakunode2 \
--peer-exchange=true \
--peer-exchange-node=[PEER MULTIADDR WITH EXCHANGE ENABLED]
```
2023-07-11 18:52:38 +01:00
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` ):
2023-07-07 02:17:02 +01:00
2023-11-23 12:01:32 +01:00
```shell title="Server: Nwaku Node with Peer Exchange Enabled"
2023-07-07 02:17:02 +01:00
./build/wakunode2 --peer-exchange=true
```
2023-11-23 12:01:32 +01:00
```shell title="Client: Nwaku Node Bootstrapping with Peer Exchange"
2023-07-07 02:17:02 +01:00
./build/wakunode2 \
--tcp-port=30305 \
--ports-shift=1 \
--peer-exchange-node=/ip4/0.0.0.0/tcp/60000/p2p/16Uiu2HAmLCe6zVqCS6KMqqRbbhyoJjfYZGr1Q3thTSbyKzibQkFR
```
:::info
2025-10-03 15:54:25 +10:00
`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.
2023-09-26 12:27:54 +02:00
:::