-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
RaspberryPi
Host a GunDB Relay Peer on your Raspberry Pi! Even from home!
This guide assumes the use of a Raspberry Pi running Raspbian, but should be adaptable to any Linux system.
As the pi
user, here is a simple manual example installation:
mkdir -vp ~pi/gun-peer
cd ~pi/gun-peer
npm install "https://github.com/amark/gun.git" --save
cd node_modules/gun
npm start
Reference this gist for automatic setup of GunDB with systemctl service creation.
If you are behind a NAT, follow along below for some options on how to expose the service publicly.
It is important that the device have a static local IP like 192.168.0.50
rather than to be assigned a random address lease with DHCP on boot so the router can consistently forward traffic. To set a static IP either configure the network configuration in the Pi or use the router to specify DHCP Reservation for the Pi's MAC address so the router always gives it the same IP.
Port forwarding is a process of configuring the router to forward inbound traffic to a specific device and port on your local network. Log into your home router as admin and create a port forward for TCP 8765 to TCP 8765 of the IP address of the machine hosting your Gun instance (you can run ip addr
in terminal on the machine to see your IP).
For more specific instruction, reference the noip.com's tutorial article or search for something like "Port Forwarding Router Tutorial"
To port forward with UPnP automatically, we can use miniupnpc
(replace 192.168.0.50
with your Pi address):
sudo apt update
sudo apt install miniupnpc
upnpc -e "GunDB Relay Peer" -a 192.168.0.50 8765 8765
Dynamic DNS provides a convenient domain that is constantly updated to your latest public IP which is very likely to change in a residential ISP setting. Dynamic DNS can be set up in any of several ways. Here are some references:
- https://support.google.com/domains/answer/6147083?hl=en (I think this is actually permanent if you set it up with a purchased Google Domain)
- https://www.noip.com/remote-access (requires infrequent manual renewal for free tier)