brandonllocke The blog of Brandon L. Locke.

Tutorials category

Using ddclient on the Raspberry Pi.

The Raspberry Pi is anything but a powerhouse, but it excels in a lot of lightweight applications that rely on 24/7 uptime. Its power-sipping processor makes it amazing for simple things like acting as an ssh gateway for your home network or hosting any number of network applications from inside your home network. Today, I’ll go over my process to set up ddclient on the Raspberry Pi to automatically update a domain that I have purchased with the external ip of my network.

Note: This assumes you have a working Raspberry Pi already on your network. Mine is running Raspbian Jessie. The domain is registered at NameCheap. This tutorial should work with almost any domain registrar or distribution, with some minor changes you’ll have to make yourself.

First, install ddclient on your Raspberry Pi:

sudo apt install ddclient

Second, create a config file on your Raspberry Pi:

sudo touch /etc/ddclient.conf

Third, open the file in your favorite editor (mine is vim):

sudo vim /etc/ddclient.conf

Fourth, plug in the relevant information according to this template:

# Configuration file for ddclient
#
# /etc/ddclient.conf

use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=*your_domain*
password=*the password you get from the dyndns section of the namecheap website*
*subdomain*

To clarify, if I wanted to make raspberrypi.brandonllocke.com resolve to my RPi, my config would look like this:

# Configuration file for ddclient
#
# /etc/ddclient.conf

use=web, web=dynamicdns.park-your-domain.com/getip
protocol=namecheap
server=dynamicdns.park-your-domain.com
login=brandonllocke.com
password=*the password you get from the dyndns section of the namecheap website*
raspberrypi

This will allow you to update the ip address manually, however, I use Linux because it allows me to automate things easily. Therefore, lets daemonize this whole thing and let it run every so often to auto update the ip address whenever my ISP decides to change it.

First, create a file in /etc/default

sudo touch /etc/default/ddclient

Second, plug in the relevant information according to this template:

# Configuration for ddclient scripts 
#
# /etc/default/ddclient

# Set to "true" if ddclient should be run every time DHCP client ('dhclient'
# from package isc-dhcp-client) updates the systems IP address.
run_dhclient="false"

# Set to "true" if ddclient should be run every time a new ppp connection is 
# established. This might be useful, if you are using dial-on-demand.
run_ipup="true"

# Set to "true" if ddclient should run in daemon mode
# If this is changed to true, run_ipup and run_dhclient must be set to false.
run_daemon="true"

# Set the time interval between the updates of the dynamic DNS name in seconds.
# This option only takes effect if the ddclient runs in daemon mode.
daemon_interval="300"

You can set the interval to anything you might want. I would recommend not setting it super low, as this can hammer online resources and that’s a really good way to upset people and push resources offline.

You can start ddclient’s daemon with the following command:

sudo service ddclient start

It should start up automatically on reboot, but after you reboot you can check on the status of the service by running:

sudo service ddlclient status

You should be set! I hope this helped!

Install Syncthing on Debian Jessie or Stretch.

Syncthing is a great tool for liberating your data from cloud storage providers. While Dropbox, SpiderOak, and Google Drive are great services, the trade-off for such a great and simple product is privacy and loss of control. As an example, Copy.com was a great service that had an excellent Linux client and even a headless client for server installs, unfortunately, it was just shut down a few days ago when Baracuda decided to abandon that service. I had it installed on my parent’s computer as an alternative backup and completely forgot until my mother sent me a message saying the computer was telling her her data would be deleted. I had long since removed it from my workflow and since I was often just using my laptop, it wasn’t necessary. I’ve reintroduced my desktop to my workflow and soon the need for such software arose again.

Installing Syncthing

While Syncthing isn’t available in the repos, there is a repo officially run by Syncthing. Add it to your apt sources like this:

# Add the release PGP keys:
curl -s https://syncthing.net/release-key.txt | sudo apt-key add -

# Add the "release" channel to your APT sources:
echo "deb http://apt.syncthing.net/ syncthing release" | sudo tee /etc/apt/sources.list.d/syncthing.list

Then update your repos and install syncthing:

sudo apt-get update
sudo apt-get install syncthing

Note: doing this on one machine only won’t do much of anything. There is nothing to sync with,so you’ll want to do this on each computer you want to sync.

Now that the application is installed, let’s run it!

syncthing

Open up your browser and go to:

https://localhost:8384

You’ll be greeted with a nice web interface where you can find your ID and add other “devices” using their IDs. Once you do that, you can add folders and share them with your devices. The web interface is very intuative and easy to use.

Take away

I’ve been using it for a few days now and it works very well! It really only works if you have a machine that will remain on all the time. I use my htpc/server as a main hub and then it populates my laptop and desktop with changes made from each other. At first, I thought I was missing the web interface that allows me to grab a single file from anywhere. The truth is, there are still a ton of ways to do that. I could use ftp, scp, or even http, if I wanted to set it up and secure it. I just don’t really need it right now. I can just pull it down with my phone over ssh.

Installing EW-7711ulc on Debian Jessie.

A few months ago, I was having issues with my home network. Moving more than 10 feet away from the router would drop my connection percentage down to under 50%, which means I was connecting at less than half of the already slow 56Mb connection. I’ve grown used to Gb ethernet from when I only had desktop boxes, so I can only stand wireless data transfers with small files in small numbers. Anyone with even a small understanding of wireless networking can problem guess what the issue was…. interference from nearby networks. I live in a small town and the houses are very close together, in addition to that, a lot of the nearby houses have been converted to multiple apartment units in each house, therefore, the spectrum is just overrun with everyone’s own personal routers. From my apartment, I can easily scan close to 35 different SSIDs!

THE SOLUTION

The solution was pretty obvious, find a way to make my wifi network a little more “unique”. I was already utilizing a good channel, switching to the less occupied channel 1 (those poor souls on channel 6 were all stuck messing with each other), but it still was crowded. So I decided to join the rest of the modern tech world and invest in some dual band equipment. The only thing I hate more than slow and inconsistent wifi are giant dongles hanging off of my tiny 11” laptop. I bought this thing small for a reason, I don’t want to have to struggle with a usb interface that is nearly the same height as my keyboard. I found the Edimax EW-7711ulc. As far as I can tell, its the only “nano” sized device capable of the 5ghz band. I have not found a single dual band nano adapter in my research. I figured I already had 2.4ghz built in to the laptop, so I really just needed an interface for 5ghz. So I picked one up.

THE SECOND PROBLEM

Unfortunately, Debian (and as far as I can tell, no version of Linux) currently supports the EW-7711ulc out of the box. I can build things from source, that’s not an issue and something you actually get pretty used to when running Debian Stable. Anyways, Edimax does provide the driver on their website for Linux. Downloaded it, went to compile it, and….. no dice. It kept giving me this very vague error that I couldn’t make heads or tails of. This doesn’t appear to be a very popular chipset either, so I couldn’t get much info on fixing the issue.

THE SECOND SOLUTION

I did however, come across a bitbucket repo that sported a different driver for the same chipset (the MediaTek mt7610u). I gave it a shot and it worked immediately!

After solving that issue, I just updated my wireless interface in wicd-curses to reflect the new wireless adapter and was able to find my 5ghz SSID immediately. Now my home wifi network flies and I do not have to worry about interference from my neighbors at all!