IPFS Peer Discovery (Subnet)

I have IPFS nodes set up in a Private network. Suppose Node A has IP which belongs to one subnet and node B belongs to another subnet. Both the nodes can be seen as peers on the bootstrap node. Node A and Node B cannot discover each other directly via bootstrap. Other nodes present in same subnet or not in the local network having common bootstraps can discover directly via bootstrap without executing ipfs swarm connect. But the nodes in different subnet connect only when I do a swarm connect on node a or b via bootstrap for discovery. This sometimes works and sometimes doesn’t work. How can they discover without swarm connect?

Does ipfs id show the correct IPs where the nodes are dialable from the other subnets?

Does ipfs ping <peerID> from A to B work and manages to produce the connection? If not, you should try to find why…

Local ping works but IPFS ping does not work.
Yes, IPFS id shows correct IP’s

If I do swarm connect to other peer via bootstrap it works and then PING also works but it does not work without that.

How many peers do you have in total?

IPFS now runs a dual DHT. In order for the peer to make themselves discoverable through it they need to verify that they are diallable from the outside of the LAN on their “external” IP (AutoNAT). If you’re bootstrappers are in the same subnet, I am not sure that will be happening (there may be other issues too). If that does not happen, they will not join the WAN-DHT in full mode and publish their records to be found there.

So I am thinking the problem is along those lines. I am not sure also if your other subnet is correctly identified as WAN, might depend on cidr blocks being used…

A node is has IP and other node has Bootstrap is in other network and both of them can reach. Externally I (Another network) can connect to both the nodes via bootstrap automatically without swarm connect. They can ping themselves locally and IP’s are correct but cannot ping through ipfs without swarm connect.

This issue is within the two nodes in diff subnets. Other than that everything else works.