Skip to content

Darkrove/Building-Private-IPFS-Network

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Building a Private IPFS Network.

There are two types of IPFS networks: public and private. All files in the public IPFS network are accessible to everyone. Since most business applications, especially enterprise solutions, require full control over their data, making their networks publicly available is not an option. This is where IPFS privacy features could help close the network for certain entities.

In this IPFS tutorial, we will go through the process of creating a private IPFS network.

IPFS: A protocol and network designed to create a content-addressable, peer-to-peer method of storing and sharing hypermedia in a distributed file system. Read more

Private IPFS: Allows IPFS to only connect to other peers who have a shared secret key. With IPFS private networks, each node specifies which other nodes it will connect to. Nodes in that network don’t respond to communications from nodes outside that network. Read more

A step-by-step IPFS tutorial for creating a private network

By default, IPFS use the following ports:

IPFS

4001 – Communication with other nodes

5001 – API server

8080 – Gateway server

  1. First we have to create 3 virtual machines, so for this we can use 3 different machines or DIgitalocean.

  2. In my case I am using Digitalocean, so for this go to https://www.digitalocean.com/ and register your self.

    Untitled

  3. Once registered new project will be created automatically.

    Untitled

  4. Now for creating virtual machines we have to click on create and select droplet.

    Untitled

  5. In this tutorial we are using Ubuntu machine with version 22.10 x64.

    Untitled

  6. Choose type and CPU as per need.

    Untitled

  7. For authentication click on password and create a new password.

    Untitled

  8. Now we need three nodes node-00 which will be our bootstrap node, node-01 and node-02. So click on + icon to increase the number of droplets and name it accordingly as per your preference.

    Untitled

  9. Click on create droplet.

    Untitled

  10. All the droplet will be created.

    Untitled

  11. Now we have to access VM via CMD (command line) so for this, click on node-00 and statistics about node 00 will be displayed, make sure node-00 is turn on and it’s running if in your case it is off then toggle the button to turn on. Now click on console.

    Untitled

  12. In the same way open console for all the nodes.

    Untitled

  13. Now perform the following steps.

  14. Download the Linux binary from (https://dist.ipfs.tech/#kubo).

    wget https://dist.ipfs.tech/kubo/v0.16.0/kubo_v0.16.0_linux-amd64.tar.gz

  15. Unzip the file:

    tar -xvzf kubo_v0.16.0_linux-amd64.tar.gz

  16. Move into the kubo folder and run the install script:

    cd kubo

    sudo bash install.sh

  17. Test that IPFS has installed correctly:

    ipfs --version

  18. Now type:

    nano /usr/lib/systemd/system/ipfsd.service

  19. Now paste following code inside ipfsd.service:

    [Unit]
    Description=ipfs daemon
    
    [Service]
    ExecStart=/usr/local/bin/ipfs daemon
    Restart=always
    User=root
    Group=root
    
    [Install]
    WantedBy=multi-user.target
  20. Now press ctrl+x to exit

  21. Once done initialize IPFS in all node by:

    ipfs init

  22. Remove bootstrap from all nodes:

    ipfs bootstrap rm --all

  23. Now change IPFS configuration as follows:

    ipfs config Addresses.Gateway /ip4/0.0.0.0/tcp/8080
    ipfs config Addresses.API /ip4/0.0.0.0/tcp/5001
    ipfs config show
  24. Force to private network:

    export LIBP2P_FORCE_PNET=1

  25. Restart IPFS daemon:

    systemctl restart ipfsd

  26. Check status:

    systemctl status ipfsd

  27. Perform step 14 to 26 in all three node.

  28. Done, now check id of bootstrap node (node-00):

    ipfs id

  29. Copy id of path of bootstrap node (node-00) followed by IP address. In my case id is,

    /ip4/164.92.65.166/udp/4001/quic/p2p/12D3KooWCkbu1irMu5651hvDEMQuwK6kLfiJCqpRTnD2az7DjtSz

  30. Now execute below command in other nodes:

    ipfs bootstrap add /ip4/ipaddress/udp/4001/quic/p2p/peerid

  31. Now run following script in bootstrap node (node-00) to see list of all peers:

    ipfs swarm peers

  32. Now our IPFS private network has created, for test let’s add a txt file from node-01 and will try to access it inside node-02 and node-00.

  33. For creating file run following script in node-01:

    echo "IPFS P2P NETWORL (node-01)" > info.txt

    Untitled

  34. Add info.txt in IPFS network by using following command:

    ipfs add info.txt

    Untitled

  35. Copy the generated hash for accessing file in node-02 uploaded from node-01.

    Untitled

  36. Now in node-02 run the following command:

    ipfs cat QmeHE2NBWN4N33uW1Ncsc5TDqy4kuK1YuEwMpXcZq37SHr

    Untitled

  37. We can successfully see the contents of file which was uploaded from node-01.

  38. Same way can see the content in node-00 also.

    Untitled

About

A step-by-step IPFS tutorial for creating a private network

Topics

Resources

Stars

Watchers

Forks