How to connect a peer with an external IP address

Well, the node should be up 24/7, or no one can download the file(s) from it. The DHT records time out after 24 hours, so your node reprovides them every 22 hours (that’s the default, but can be changed). This is why having more than one node with the file(s) helps, not all of them have to be up all the time, as long as some are always up.

Well, let’s say I want to publish a file from my personal computer, which I cannot keep online 24/7. Is it enough for my computer (node) to appear on the network once (say every day at 8 am) to re-provide the cid of the file in DHT? The file will be stored on the computers of friends, at least one of whom will be online 24/7 on average.

Another thing you are misunderstanding. The reprovide only stores the CID and the peer ID in the DHT, the file itself only exists in your node, so, if your node isn’t up, another node has nowhere to go to download it. Which is why you’d want to use a pinning service, they have nodes that never go down. That way, if a node wants to download the file, and your node isn’t up, theirs is and the file can be downloaded.

The key misunderstanding is that IPFS isn’t a storage system, it’s a communications protocol. You provide the storage with your own node, and you’re the only one the file can be downloaded from, until you add other nodes that also have the file, such as those in a pinning service.

P.S. Now, of course, if you can get your friends to pin your file(s) in their nodes, they become your pinning service and it will work as you want it to (as long as you are not all down at the same time).

1 Like

Fine. This means that in order not to keep my node constantly online, you just need to pin the file to other nodes using the pin command, or using a cluster. And for example, out of 10 nodes, only one node needs to be online for the file to be accessible. Right?

Correct.

However, if you are just trying to share a folder of files between you and your friends, I can recommend another software more tailored to that specific use case that uses a very similar technology as IPFS.

One more point… When a file is added to the public ipfs network, is it not pinned to other people’s nodes and after the garbage collector is activated, the file’s entries are deleted?

When you pin the file to your node, it only exists in your node. If someone retrieves your file with their node to look at it, it gets put in their node’s cache and is available to other nodes from there, but, since it isn’t pinned there, it will eventually get GC’d out of the cache (the amount of time varies based on the size of the cache and the amount of data that node retrieves day to day). So, you can’t rely on that being “your pinning service”, as it is temporary at best, but will help if your file “goes viral” for a while. Long term, it’ll return to you having the only copy.

1 Like

I understand. To ensure that the file is always accessible, needs follow two rules:

  • pin the file to the nodes;
  • keep at least one node online until another node replaces it;
1 Like

Question about bandwidth. If say, only one node stores a file with a size of 1 GB, then if 1000 users simultaneously request the file, then the node that stores the file (the only one) will consume 1000 GB of traffic?

It depends on how fast your node can give that out. If it’s slow at it, those that were first to get it will start providing it, and they will start responding to requests. The more nodes start to have it, the more divided the traffic becomes. By the time all 1,000 nodes have received it, you might only have handed out a quarter of the bandwidth (or even less).

1 Like

Please explain more about the initial nodes, which are generated by default when kubo is initialized (bootstrap). Are these nodes powerful servers that serve for communication? And if these nodes stop working, will the connection with the files be lost?

Those are nodes that Protocol Labs runs and are certified to always be up and reachable. They are just a starting point that your node will use to discover other nodes and will quickly move away from them. Over time, your node tends to rove over the network, not really staying in one place for very long.

If you have friend nodes that are reachable and up often, you can add them to that list, so that even if all the Protocol Labs nodes disappeared, you’d still have a starting point for the network.

Do you mean using the ipfs bootstrap add /ip4/… command?

Yes, or edit the config file directly with a text editor (if you know what you’re doing).

Is it not necessary to configure a port for nodes that are behind NAT if they are on a public ipfs network?

For the bootstrap nodes, absolutely. For other nodes, it’s best if you do, but if you don’t, they will connect to the network using the bootstrap nodes that are provided, find relay nodes on the network, and register with one, then publish that as their address. Other nodes trying to connect to them will connect to the relay node, and communicate that way for small amounts of data. If they want to exchange files, they will then use the relay node to initiate a “hole punching” connection, which is a method to get a direct connection by punching through NAT. If they fail to establish such a connection, then they cannot exchange files and port mapping would be the only solution.

1 Like

Is it possible to restore the previous node ID in case of loss (for example, the Windows/Linux OS is broken)?

If you have a backup of your .ipfs folder, I believe so (I’ve never had to try). If you don’t, no.

1 Like

This is relevant when a broken node is in the bootstrap of many other nodes and so that in each node in the bootstrap it is not necessary to specify a new node ID, it is easier to restore the node with the same ID.

Do you mean just copy, for example to a flash drive?