I'll be using my Raspberry Pi 3 running Raspbian Linux for the purpose of this tutorial.
It may or may not work with other Linux distributions.
Set up Dynamic DNS Hostname
Dynamic DNS (DynDNS) is a method of automatically updating DNS records.
Using a DynDNS hostname we can always access our machine regardless of its IP address.
Create an account at NoIP.com and choose your hostname and domain name.
You can view and edit your active hostnames here.
You don't have to change anything as long as you set up the hostname from the same network.
Update the DynDNS Records Automatically
Every time our dynamic IP address changes we need to update our DNS record.
NoIP.com provides a Dynamic Update Client (DUC) that will do it automatically for us.
Before you proceed with the installation connect to your Raspberry Pi 3 via SSH first:
ssh pi@<your IP addres>
Set Up Dynamic Update Client
There aren't any binaries for Linux that I know, so we'll have to install DUC from source:
tar xf noip-duc-linux.tar.gz
sudo make install
After the installation is done, you will be prompted to sign in to your existing account.
Then, run the following command to create the default config file:
sudo /usr/local/bin/noip2 -C
You will be prompted to sign in again. Follow the instructions.
Start DUC Automatically
In order for DUC to start automatically after a system restart, we have to install it as a startup service.
I've written a simple Systemd script that will take care of it.
chmod 664 noip2.service
Feel free to edit the script according to your environment. You don't have to change anything if you followed my RPi3 installation procedure, though.
Enable the service:
systemctl enable noip2.service
If it doesn't output any error start the service and exit the root environment:
service noip2 start
The hostname should be updated automatically now.
Connect to OB Server via Hostname
Open your OpenBazaar Client and log in to your server.
Click on your profile picture in the top-right corner, open Settings and go to Advanced tab. Find Server Settings and click Change.
In the Server Configurations window click New and enter your new hostname and login credentials to your server.
Click Save Changes and you should be connected to your OpenBazaar server via a hostname instead of IP.
Restart OB Server on IP Address Change
Every time our IP address changes we need to restart the server so it notifies the network of the change.
I wrote a little script for it:
chmod u+x ipaddr-ob.sh
If it gives you a "No such file or directory" error create the bin folder first:
We have to make sure the script runs periodically. Open Crontab:
add the following line:
*/5 * * * * sh /home/pi/bin/ipaddr-ob.sh >/dev/null 2>&1
and hit Ctrl+x followed by typing
Y and hitting the Enter to save the change.
Make sure the record was added to crontab:
If your store has lots of traffic and sales you want to make it as reachable as possible.
In that case, I'd recommend you run the above script every minute instead:
*/1 * * * * sh /home/pi/bin/ipaddr-ob.sh >/dev/null 2>&1
That's all! Hope you find this fix useful.
Please let me know in the comments below how this workaround works for you. Also feel free to contact me if you run into any issues.