WireGuard® is an extremely simple yet fast and modern VPN that utilizes state-of-the-art cryptography. It aims to be faster, simpler, leaner.
Assuming you have a local node (i.e. block producer / validator client / local laptop) and remote node (i.e. relay node / beacon-chain node / VPS), this guide helps you secure and encrypt your network traffic between the two machines with WireGuard.
This greatly minimizes the chances that your local node is attacked and minimizes the attack surface of the remote node by not requiring you to open ports for services such as Grafana.
Only the remote node is public internet facing online and the local machine can access the remote node's internal services, such as Grafana.
🐣 Installing WireGuard
Linux Headers needs to be installed before WireGuard. Below you see the generic headers being installed.
In case of linux header problems, use the following instead.
sudo apt install linux-headers-$(uname -r)
Be aware this will require installing the headers again. Not restarting with the new linux-headers will prevent Wireguard network interface from functioning.
🗝️ Setting Up Public/Private Key Pairs
On each node, to generate a public/private key type the following commands:
sudo su
cd /etc/wireguard
umask 077
wg genkey | tee wireguard-privatekey | wg pubkey > wireguard-publickey
🤖 Configuring WireGuard
Create a wg0.conf configuration file in /etc/wireguard directory.
Update your Private and Public Keys accordingly.
Change the Endpoint to your remote node public IP or DNS address.
Two Node Setup ( i.e. 1 block producer, 1 relay node)
# local node WireGuard Configuration
[Interface]
# local node address
Address = 10.0.0.1/32
# local node private key
PrivateKey = <i.e. SJ6ygM3csa36...+pO4XW1QU0B2M=>
# local node wireguard listening port
ListenPort = 51820
# remote node
[Peer]
# remote node's publickey
PublicKey = <i.e. Rq7QEe2g3qIjDftMu...knBGS9mvJDCa4WQg=>
# remote node's public ip address or dns address
Endpoint = remotenode.mydomainname.com:51820
# remote node's interface address
AllowedIPs = 10.0.0.2/32
PersistentKeepalive = 21
# remote node WireGuard Configuration
[Interface]
Address = 10.0.0.2/32
PrivateKey = <i.e. cF3OjVhtKJAY/rQ...LFi7ASWg=>
ListenPort = 51820
# local node
[Peer]
# local node's public key
PublicKey = <i.e. rZLBzslvFtEJ...JdfX4XSwk=>
# local node's public ip address or dns address
Endpoint = localnodesIP-or-domain.com:51820
# local node's interface address
AllowedIPs = 10.0.0.1/32
PersistentKeepalive = 21
sudo wg
## Example Output
# interface: wg0
# public key: rZLBzslvFtEJ...JdfX4XSwk=
# private key: (hidden)
# listening port: 51820
#peer:
# endpoint: 12.34.56.78:51820
# allowed ips: 10.0.0.2/32
# latest handshake: 15 seconds ago
# transfer: 500 KiB received, 900 KiB sent
# persistent keepalive: every 21 seconds
Verify ping works between nodes.
ping 10.0.0.2
# if triple node configuration
ping 10.0.0.3
ping 10.0.0.1
# if triple node configuration
ping 10.0.0.3
# if triple node configuration
ping 10.0.0.1
ping 10.0.0.2
Cardano-specific Configuration
Update and/or review your topology.json file(s) and/or relay-topology_pull.sh script to ensure the "addr" matches this new tunneled IP address, and not the usual public node IP address.
Update and/or review your validator's configuration and ensure it connects to the beacon-chain's new tunneled IP address, and not the usual public node IP address.
In this example, the beacon-chain is the remote node with IP address 10.0.0.2
To access Grafana from your local machine, enter into the browser http://10.0.0.2:3000