This guide provides installation instructions to install an InterPlanetary File System (IPFS) node on a Raspberry Pi.
IPFS is a distributed peer-to-peer system for storing and accessing data files. The data is addressed based on a cryptographic hash of its content and not by its location.
This guide is written for installation on Raspberry Pi 4 running Ubuntu Server 21.10 64-bit. This guide assumes that you have some familiarity in using a Raspberry Pi and accessing it via SSH. The Pi will be run in headless operation(no monitor,keyboard, mouse).
The guide also assumes you are familiar with configuring port forwarding on your router to enable your IPFS node to communicate with other public notes outside of your local network. Some internet service providers may not allow you to port forward.
1. Install Ubuntu Server 21.10 64-bit
See this guide for a secure basic installation of Ubuntu 21.10. This guide also provides guidance for installation on external USB SSD instead of an SD card.
2. Download IPFS
Go to IPFS’s distribution page and download the latest ARM-64 Linux Versions of go-ipfs. Currently the latest version is: v0.12.2. Modify the version number in the path and file name below:wget https://dist.ipfs.io/go-ipfs/v0.12.2/go-ipfs_v0.12.2_linux-arm64.tar.gz
3. Extract
tar -xvzf go-ipfs_v0.12.2_linux-arm64.tar.gz
4. Run Install Script and confirm version that is installed.
cd go-ipfs
sudo bash install.sh
ipfs --version
5. Initialize the repository
You will get an introduction message showing your peer identity and link to a help file.ipfs init
6. Create a service for the IPFS daemon
The following link was used as reference for creating this service file. https://github.com/ipfs/go-ipfs/issues/1430
Create service file.sudo nano /etc/systemd/system/ipfs.service
Edit and Copy the following to the file.
Replace friends with your username
[Unit]
Description=IPFS Daemon
After=network.target
[Service]
User=friends
Environment=IPFS_PATH=/home/friends/.ipfs
ExecStart=/usr/local/bin/ipfs daemon --init --migrate
StandardOutput=journal
Restart=on-failure
KillSignal=SIGINT
[Install]
WantedBy=multi-user.target
7. Configure Ports.
The following default ports are used by IPFS:
- 4001 – default libp2p swarm port – must be open to sync to all other public nodes.
- 5001 – API port and webui– provides write/admin access to the node – should be locked down or configured to only be accessible by your local IP.
- 8080 – Gateway
If the default ports conflict with other devices on your network you can change them
See the following link for more information: https://github.com/ipfs/go-ipfs/issues/7053
Open configuration file:nano ~/.ipfs/config
Update the swarm port number(4001) in this section
"Addresses": {
"Swarm": [
"/ip4/0.0.0.0/tcp/4001",
"/ip6/::/tcp/4001",
"/ip4/0.0.0.0/udp/4001/quic",
"/ip6/::/udp/4001/quic"
The API/webui and Gateway ports are restricted to local host access by default.
To allow access by another ip address you need to change the ip addresses in this section from 127.0.0.1 to 0.0.0.0.
"API": "/ip4/127.0.0.1/tcp/5001"
"Gateway": "/ip4/127.0.0.1/tcp/8080",
8. Configure Cross-origin Resource Sharing for api/webui access
Replace 192.168.1.81 with ip address of your Pi.
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["http://192.168.1.81:5001", "http://localhost:3000", "http://127.0.0.1:5001", "https://webui.ipfs.io"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "POST"]'
9. Start IPFS
sudo systemctl daemon-reload
sudo systemctl start ipfs
10. Enable auto-start on Reboot
sudo systemctl enable ipfs
11. Configure Firewall
We need to open up the following ports on the local firewall running on the Pi. It is assumed that UFW is already started.
- 4001 must be open to sync to all other public nodes.
- 5001 API port and webui. Keep closed if you do not use
- 8080 – Gateway. Keep closed if you do not use
Open up ports:sudo ufw allow 4001
sudo ufw allow 5001
sudo ufw allow 8080
12. Configure Port Forwarding on your router.
The libp2p swarm port(4001) is the only port that you need to forward in your router. You should not open up port 5001(api/webui) to access outside of your local network unless you have additional security.
13. Reboot Pi
sudo reboot
14. Check to see if IPFS is running
You can view the list of the current peers that are connected to your node. If you see peers in this list then your node should be operating correctly.ipfs swarm peers
Accessing webui
webui is a graphical dashboard showing the status and activity of your node. To access the webui application replace the following with the IP address of your Pi:
http://192.168.1.81:5001/webui
IPFS Gateway
To access your local gateway replace the following with the IP address of your Pi:
http://192.168.1.81:8080/ipfs
Using IPFS
For detailed information on using IPFS I recommend:
https://docs.ipfs.io/how-to/