When configured as a private network, "ipfs files ls" does not return anything (although many files are loaded and visible through the webui for that particular peer. It does work fine when the network is public. The nodejs client ipfs.files.ls does not return anything either. Is this due to some mis-configuration of my node? Any way around this? Thanks.
-
curl -X POST 127.0.0.1:5001/api/v0/files/ls returns {"Entries":null}– Pat CappelaereMar 24, 2021 at 15:11
1 Answer
Interesting. I cannot seem to reproduce that behaviour on my end, what version of IPFS are you running?
Here's what I did to setup a private network, with a working MFS (fresh install):
Init IPFS repo
ipfs init
Generate swarm key
go get github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen
cd ~/go/bin/
./ipfs-swarm-key-gen > ~/.ipfs/swarm.key
Remove default bootstrap
ipfs bootstrap rm --all
Add new bootstrap (if needed)
ipfs bootstrap add <multiaddr>
Edit systemd service to enforce private network (path may vary)
Add Environment="LIBP2P_FORCE_PNET=1" underneath [Service]
sudo vim /usr/lib/systemd/user/ipfs.service
Start IPFS daemon
systemctl --user start ipfs
Check MFS
ipfs files ls /
No output, because we just initialised
Add file to MFS
echo "Hello world" > hello
ipfs add hello
ipfs files cp /ipfs/QmePw8gVcBMb8x6kAep6aMBAX23hCSk6iZW3i9VKkiFhu1 /hello
Check MFS again
ipfs files ls /
Correctly reports hello
Verify private network is indeed being used
systemctl --user stop ipfs
mv ~/.ipfs/swarm.key ~/.ipfs/swarm.key.bk
systemctl --user start ipfs
systemctl --user status ipfs
You should see the daemon has failed to start, if private network is being enforced.
Move private key back
mv ~/.ipfs/swarm.key.bk ~/.ipfs/swarm.key