Skip to content

How to start p2p daemon public node

MaximKsh edited this page Mar 25, 2021 · 1 revision

This page describes how to set up own p2p network and start primary peers. Network must contains at least 4 servers with different public IPs (requires for nat traversal). Peers can be started sequentially, every next should bootstraps to previous peers.

1.a Download p2pdaemon

wget https://github.com/learning-at-home/go-libp2p-daemon/releases/download/{P2PD_VERSION}/p2pd

Latest version at the time of writing is v0.3.1.

2. (Optional) Open 5000 tcp port

apt update
apt install -y ufw
ufw allow 5000/tcp

3.a First node

./p2pd -tls=1 -connManager=1 -natPortMap=1 -autonat=1 -dhtServer=1 -hostAddrs=/ip4/0.0.0.0/tcp/5000 -forceReachabilityPublic

Possible output:

Control socket: /unix/tmp/p2pd.sock
Peer ID: QmeDVi4zkoAR1hkyXxcWxf6QYpD9vFezkkaYF8ysQs7pPy
Peer Addrs:
/ip4/193.167.11.12/tcp/5000
/ip4/127.0.0.1/tcp/5000

Your p2p address is:

{Public peer Addr}/p2p/{Peer ID}

For example:

/ip4/193.167.11.12/tcp/5000/p2p/QmeDVi4zkoAR1hkyXxcWxf6QYpD9vFezkkaYF8ysQs7pPy

Give your p2p public address to next peers!

3.b Second, third, etc ...

./p2pd -tls=1 -connManager=1 -natPortMap=1 -autonat=1 -dhtServer=1 -b -bootstrapPeers={first_node_peer_addr},{second_node_peer_addr},... -hostAddrs=/ip4/0.0.0.0/tcp/5000 -forceReachabilityPublic

Don't forget to give your public address to next peers!

Is my address public? Yes, if it not in ranges:

  • 10.0.0.0 – 10.255.255.255
  • 172.16.0.0 – 172.31.255.255
  • 192.168.0.0 – 192.168.255.255
  • 127.0.0.1 (localhost)