IPFS Node and vpn providers

Hi, I would like to run an IPFS node, while my machine is connected through a vpn provider. So the public/external IP is the one provided by the VPN provider, and there is port forwarding,: Locally I have the standard port for the swarm which is 4001, but the port forwarding means that “externally” there is a different port which is forwarded to my internal port 4001. Is there anything I have to change in my node configuration in such a situation?

If your VPN provider gives you a forwarded port, you can change the swarm port in your IPFS config (.ipfs/config) to the forwarded port before you start your daemon.

Change 4001 in this part of your config to the port your VPN provider forwards for you:

  "Addresses": {
    "Swarm": [
      "/ip4/0.0.0.0/tcp/4001",

I added the port in the “Swarm” list, but kept the original entry with 4001. What confuses me a bit: If a call “ipfs id” now it shows me that the node is “swarming” on the new port, but the IP it uses is not the public id that I got from my VPN provider.

Which IP is ipfs id showing? And what IP did you specify in the config?

So your VPN is using a NAT? If your VPN supports UPnP (or something like that), IPFS will automatically try to set up port forwarding for you.

If you’ve explicitly configured port-forwarding, your node should eventually (after connecting to a few external nodes) discover your external address. However, you can manually configure it by setting Addresses.Announce: