IPFS for file distribution in local network

I have a big local network, where i need to distribute some file. Right now scp is used to upload files from server to destination node. The problem is, that some devices in local network have very poor connection, so scp fails with some timeout with a very big chance.
The common idea is to replace it with a some p2p mechanism, when there is some node in local network, that has source file and this node became some kind of seeder.
This node provide hash of seeding file, which is sent to other devices in local network. Other devices start downloading and distribute this file over whole local network. Important note: every time i need to distribute file, different node could be selected as source one.
Problems to solve:

  1. Avoid wan overhead in terms of frame size;
  2. Avoid failing on timeout.

Questions:

  1. Is that possible with IPFS? If not, is there any p2p alternatives?
  2. It seems that i don’t need bootstrap lists, because all peers i’m interested in are behind firewall in my local network. Will IPFS work properly without bootstrap list? Is that possible to somehow discover peers in local network?
  3. Is there a way to tell IPFS search for peers only in local network?

Seems like it would work for transferring files reliably, but you will another way to start the download on each node. I gather you have ssh access to the nodes, so that should be sufficient. Do the following after setting up your private IPFS swarm.

on the source node:
$ ipfs add filename.ext
QmSomehashNr3MHLhNbyXSdebCXCfVd6UbNr3MHLhNbyXs  # This is $HASH below. Each file is different

on each destination node:
$ ipfs pin /ipfs/$HASH
$ ipfs cat /ipfs/$HASH > filename.ext

When finished, you may go back around and unpin the file from all the nodes.

$ ipfs pin rm /ipfs/$HASH

You will need to provide your own list of bootstrap peers instead of the default list that ships with IPFS. On each node you want to be a bootstrap node, select one or more of the lines listed under “Addresses” in the output of the following command. The nodes will need to have network connectivity to the address you chose.

$ ipfs id

Then on each node, remove the existing bootstrap set.

$ ipfs bootstrap rm --all

Then for each of the bootstrap addresses do this:

$ ipfs bootstrap add $ADDRESS

When you are done, check that you have all the addresses you want and nothing else.

$ ipfs bootstrap list

Configuring your own set of bootstrap peers does most of that. I think you will also need to disable MDNS discovery to keep IPFS nodes not setup by you on the local network from polluting your peer table.

$ ipfs config Discovery.MDNS.Enable --bool false
1 Like

I think @teknomunk’s suggestions are mostly right, but I’d add in a couple caveats.

If you don’t want to deal with the hassle of setting up your own bootstrap nodes, your network supports MDNS, and the number of peers on your network isn’t huge (e.g. it’s a few hundred) I don’t see why you couldn’t just use MDNS. If you actually setup a private swarm your node will not be able to successfully talk to any public IPFS nodes even if you learn about them through MDNS, they directly connect to you, etc.

If your local network is actually segregated from the public internet you probably don’t need to worry about private swarms since your network is already segregated. However, especially if the information in your network is sensitive, it’d be good practice to setup a private swarm.

An additional note is that you could utilize the libp2p pubsub layer available via IPFS to let your nodes send out when they get a new file so that the other nodes on the network can start requesting it. There are also some other tools built on top of IPFS and libp2p such as Textile’s Threads that could help you out with mutability/updating concerns.

2 Likes

Everyone Thanks for response!

Is there some way to use Local Peer Discovery instead of DHT to work only inside local network?

I’m doing a similar thing where I’m planning to use MFS (Mutable File System) as the backbone for a “federated” platform where each instance on the network will maintain it’s own complete set of certain MFS file structures (directory trees),

I’m hoping that using the MFS Copy command (like below) will have similar behavior to “rsync” insofar as the ability to only copy mostly just changed data when ‘re-syncing’ a across two nodes that are already nearly up to date (as a result of how chunking works). My assumption is that any files that didn’t change at all, for example, would result in zero transfer/storage during the copy operations. I’m hoping to issue just one copy command on the root of the folder structure, and let the ‘recursive’ copy completely to the equivalent of an rsync.

I’m posting here since it is directly related to the above, and may help the OP, but also because I had this question of “am I crazy or not”. to try that. lol. :slight_smile:

curl -X POST "http://127.0.0.1:5001/api/v0/files/cp?arg=<source>&arg=<dest>"

You can turn off the DHT if you want by setting the routing type to none https://github.com/ipfs/go-ipfs/blob/master/docs/config.md#routingtype. This will mean relying on MDNS to do all the connection work for you (depends on how big your big network is as I mentioned above).

Also note that if you use a private swarm the DHT will only operate within your swarm and so the DHT will be local network only.

@adin, thank you! I’ve succeed to install ipfs over my local network. But what i don’t really like is that i should add bootstrap nodes to a new device in that network so it was able to find peers. Is there any automatic discovery mechanism supported by IPFS?

@MetalRex101 as was mentioned above the two main peer discovery systems in go-ipfs are MDNS and the DHT. The DHT requires some bootstrap peers from which to join the network and MDNS uses local discovery (e.g. think of how your computer can locate a smart tv or wireless printer https://en.wikipedia.org/wiki/Multicast_DNS).

If you have MDNS enabled in your config file (it’s enabled by default) and your network supports MDNS (sometimes place like university networks, hotels, or VPN networks block it) then local discovery will work just fine. For example, on my home network I can create a new node on my laptop and remove all the bootstrappers and it’ll find the node on my desktop. If you’re having issues with MDNS you may need to look into how your network is setup.

Note, as mentioned above if you do not segregate the networks by using a private swarm key then you could end up joining the rest of the world unless your network is totally isolated. For example, in the above scenario because my desktop is running the default go-ipfs what happens is my laptop actually discovers not just my desktop peer but the rest of the network too because the DHT ends up bootstrapping from my desktop automatically.

1 Like