Fundamentally the issue you’re trying to address is how can your nodes find each other.
The reason that your nodes can find each other on you local network is that there is a protocol (mDNS) that allows you to broadcast to everyone in your local network a message like “I’m a libp2p node, do you want to talk to me?” However, with public IPs there is no such global broadcast that would enable you to find other nodes.
The solution is to use your own form of network discovery, the easiest of which would be to setup your own “bootstrap” nodes. By just adding the addresses of a few of the nodes that you expect to be consistently available your nodes will discover each other (https://docs.ipfs.io/guides/examples/bootstrap/).
Additionally, if you really want your network to be private then you should also create a swarm key. This swarm key protects all of the traffic in your network and also prevents nodes external to your network from joining.
Overall, there’s a pretty good looking tutorial on simply setting up a private network at
https://medium.com/@s_van_laar/deploy-a-private-ipfs-network-on-ubuntu-in-5-steps-5aad95f7261b.