How do I get a public IP address?

With IPFS JS when I run this:

const ipfsNode = await IPFS.create();
const addresses = await ipfsNode.swarm.localAddrs();

I get this:

Swarm listening on /ip4/
Swarm listening on /ip4/
Swarm listening on /ip4/

But all of these are local/LAN addresses. How do I get a public ID so that from another node I can connect to this node over the internet like so: jsipfs swarm connect PUBLIC ADDRESS HERE?


I think you don’t need the public ip, the private ip should be enough, the part that really matters is the peer id

Hello @int

You can configure your public IP via libp2p config. Via js-ipfs, you can check this [example]( on how to provide a custom config to libp2p. The goal here is to add your public IP to the announce` addresses of libp2p, so that other nodes know how to reach your node’s public address. After this, you setup nginx to forward from the public IP to the internal private IP of your node.