IPFS> IPNS Even if I publish different folders, I always get the same peerID

I don’t understand where I’m wrong. If I understand correctly, by publishing different folders through ipfs add -r, ipfs name publish CID, ipfs name resolve, I should get an ID that allows me to always access my data even when it changes. But in practice this is not the case. Even if I publish different folders I always get the same peerID!

The exact sequence:

$ ls testIpns testIpns2



~$ ipfs add -r testIpns

added QmcDrrDZPkNZh.........iTfnot8XjVMmDYZp2 testIpns/datatestIpns.txt
added QmTSzYQdqKf...............vgY9TD9prcYJy2XC testIpns
 10 B / 10 B [=============================================================]

~$ ipfs name publish QmTSzYQdqKfwi............prcYJy2XC

Published to k51qzi5uqu5di...........nqjyf03xzdd659kovr8: /ipfs/QmTSzYQ......cYJy2XC

~$ ipfs name resolve k51qzi..................dd659kovr8  /ipfs/QmTSzY...........YJy2XC

~$ ipfs add -r testIpns2
added QmP6yNSCqbDNda......vbYtXkFistb8XM testIpns2/datatestIpns2.txt
added QmbaJucZkWxbUDSggXWFSSrUmUBJzKZuis6DYLqTvVdT4e testIpns2
 10 B / 10 B [=============.=================================.======]

~$ ipfs name publish QmbaJucZkWxbUDSggXWFSSrUmUBJzKZuis6DYLqTvVdT4e
Published to k51qzi5uqu5di...........nqjyf03xzdd659kovr8: /ipfs/QmbaJ..........vVdT4e

~$ ipfs name resolve k51qzi5uqu5diig..........d659kovr8  /ipfs/QmbaJuc..........TvVdT4e

As you can see I get the same peerID for two different folders. Am I doing something wrong?

it’s how it’s supposed to work.
IPNS use the peerid as the key.
So you do /ipns/k51qzi5uqu5di...........nqjyf03xzdd659kovr8 to fetch the data.

Ok, thanks for answering me. In fact, I did the same operations on another server and got different peerIDs for different folders.

But here, where is the problem? For the sake of completeness, I must say that in another server trying the same sequence of commands I got different peerIDs but, as soon as I tried using the ipfs add -w command, I was no longer able to get different peerIDs as before! I’ve been going crazy since last night. Where is the problem ???

I hope someone can help me because after setting up 5 servers this is very disappointing.

Are you running this command on different servers ?

Yes, right now. On another server, I always get the same peerID for different folders

Sounds like there’s a bit of a terminology problem. The peerId is the immutable part that’s published so if you publish different contents that’s the part that will remain the same. It doesn’t have to be the peerID but that’s just the default. The peerId should resolve to different CIDs as you publish a new record which is the mutable part.

There are lifetime and ttl values associated with the record so they may be cached which might be why you might not be seeing a new CID even though you’ve published a new record. There is a —nocache option on ‘IPFS name resolve’. It’s not totally clear of that’s “don’t use a cached value” or “don’t cache the value you resole”. I’d be interested in knowing which that is.

The peerId is the immutable part that’s published so if you publish different contents that’s the part that will remain the same

But if I publish 2 different folders, should I get two different peerIDs or not?

If you publish it using the same key ( the peerId in this case ) the peerId won’t change. The CID that the peerId resolves to will change.

It’s a bit like DNS where the peerId is the domain name and the CID is the IP address it resolves to. When you publish a new record the domain name ( peerId ) doesn’t change but the IP address ( CID ) changes.

I’m not sure if the problem is how you’re thinking about it or if you’re just referring to the wrong thing as the peerId.

Forgive me for bad English.
What I understood from reading the documentation is that:

ipfs add -r folder1 >ipfs name publish CID_folder1 >ipfs name resolve peerID_folder1
ipfs add -r folder2 >ipfs name publish CID_folder2 >ipfs name resolve peerID_folder2

should peerID_folder2 be different from peerID_folder1 or not?

After that if for example I try to publish the folder again because the “content” of a file has changed, or because I added a file, this works.

peerID_folder2 == peerID_folder2

You need to specify a key to use with --key if you want them to be different.

A key? Can you explain it better?

it’s just which private is used to sign the record, each private key has a different corresponding peer id.

Thank you!
Thank you. How stupid, I didn’t understand. The problem was the key. Without a key you will always get the same peerID even with different sites!

ipfs key gen --type=rsa --size=2048 myfolder
ipfs add -r myfolder
ipfs name publish --key=datafolder CID_folder

Solved, thanks!

Can someone clarify the use of the term PeerId ( I understand what it is)

Would you refer to secondary keys created as peerID’s even though they’re not being used to identify a node? The term is just a little confusing because the default peerid is being used for two different things

I personally wouldn’t call the generated keys PeerIDs. Even though it is possible to swap out the default key in kubo. I would just call them keys


I agree. I had some issues by running Kubo AND Brave Browser Beta. There were two .ipfs directories the second one was in %app data% for Brave… they had the same “PeerID” … I think of the peerID as like a fingerprint or session token.

That’s a bit strange because the private key and peerID are stored in .ipfs/config, which means if you have two unique .ipfs folders, you should have two unique peerIDs.

Unless they created the second one by just copying the first one.

1 Like

I believe that there are(were) two IPFS nodes created on my R340. Kubo was installed I believe after Brave Beta on Server 2022. Only one peerID. Same for a desktop in my homelab that had Kubo and Brave beta. The server was connected through a VLAN switch to the AP. The two desktops were connected through an AR750 router downstream of the AP. After many trials and tribulations I could expect only two could “see” each other and the public remote IPFS peers. The third PC would either only see remote or only local. All of them would only have one peerID.