Running cjdns on Raspbian Jessie

If you’re like me, you have a few Raspberry Pis kicking around, waiting for a job to do. I adopted early and purchased (at least one) original Model B with 256MB of RAM. This was a nifty little box four years ago, but has since been overshadowed by its older brother, the revised Model B with 512MB of RAM, and its cousins: the B+ and RPi 2. These originals still have life left in them, and can often be found below the original $35 price tag. When it comes to running cjdns, they do a fantastic job!

This post assumes you have a Raspberry Pi, power adapter, sd card, and enough smarts to hook the Pi up to your network and feed it a Raspbian image. This should work for any Model B Raspberry Pi, from the original up to the Raspberry Pi 2.

Installation

The Hyperboria documentation offers a guide on installing for Debian Jessie, but it fails on the Raspberry Pi out of the box. Prior to this, I was running Raspbian Wheezy with few issues in relation to cjdns, but other work I wanted to do had me yearning for a more up-to-date distribution. I grabbed Raspbian Jessie from the official download site (Release date 2015-11-21), loaded it onto my SD card, and booted up.

On an original Raspberry Pi, this process takes a while. At this point, start yourself a pot of coffee and then log on to your pi using the default username and password, pi/raspberry. I run headless, so everything will be done from the console over ssh, but that shouldn’t matter too much.

We are going to install cjdns as a service, so let’s change over into root to make this a little more comfortable.

su -

If you have a fresh installation, be sure to run config and expand to fit the full size of your SD card, overclock if you want, and restart the pi when done. After restarting, log in again and change back to root.

raspi-config

I also cannot express how important it is to change the default user and root passwords.

passwd pi
passwd root

Now, we want to update, upgrade, and install some dependencies.

apt-get update
apt-get upgrade
apt-get install nodejs build-essential git

Somewhere during these commands, your coffee should have finished. Go pour a cup and come back to watch the console until everything is tidied up.

Afterwards, we are going to start building cjdns by pulling down the latest code and building.

cd /opt
git clone https://github.com/cjdelisle/cjdns.git
cd cjdns
NO_TEST=1 Seccomp_NO=1 ./do

Pay close attention to this last line. We need to execute ./do in this fashion because of a current issue with the kernel on Raspbian Jessie.

After a little wait, the build should finish successfully. Now we want to configure cjdns to run as a daemon, so let’s create a link to the binary, generate a configuration file, and copy over the service file.

ln -s /opt/cjdns/cjdroute /usr/bin
(umask 077 && ./cjdroute --genconf > /etc/cjdroute.conf)
cp contrib/systemd/cjdns.service /etc/systemd/system/

All that’s left is to enable the service and start it up. Afterwards, it should start on every boot-up automatically.

systemctl enable cjdns
systemctl start cjdns

If you want to edit your cjdroute.conf for adding peers or… well… anything else, simply edit the file in /etc/cjdroute.conf and restart the service.

nano /etc/cjdroute.conf
systemctl restart cjdns

At any point, you can check the status of the service:

systemctl

In the output, you should see the following:

cjdns.service    loaded    active running    cjdns: routing engine designed for sec...

Troubleshooting & Debugging

If at any point you want to check the output generated by starting cjdns, stop the service and run cjdroute manually.

systemctl stop cjdns
/opt/cjdns/cjdroute < /etc/cjdroute.conf

Ocasionally, you may get a Configurator error like this below:

1454470218 CRITICAL Configurator.c:97 Failed to make function call [Timed out waiting for a response], error: [UDPInterface_beginConnection]

If this happens, run the following before starting cjdroute again to ensure that the ipv6 kernel module is loaded:

modprobe ipv6

Conclusion

That’s all it takes, you now have a node capable of connecting to Hyperboria! Now, all you need to do is find some peers, add them to your configuration file, and join the network!

 

One thought on “Running cjdns on Raspbian Jessie

  1. Original Comments:

    khag
    February 18, 2016 at 9:06 pm

    You may want to consider changing the default SSH port as well. I can’t paste the code here because of security on this blog (getting a Mod Security error) but you can find the instructions here:
    http://linuxlookup.com/howto/change_default_ssh_port

    I’d recommend using nano to edit the file instead of vi.
    Reply ↓

    Famicoman Post author
    February 23, 2016 at 3:57 pm

    Agreed, I actually disabled SSH logins on IPv6 altogether.

    Benedict
    March 23, 2016 at 2:39 am

    Thanks for posting this! Helped me get cjdns running on Jessie. I have cjdns running on both an OpenWrt and Raspbian image, but the crypto performance is quite poor, resulting in 2 Mbps and 14 Mbps bandwidth, respectively. I wonder if you have done some benchmarking and how are your results? Thanks!

    Full results here: https://github.com/tomeshnet/prototype-cjdns-pi2/blob/master/docs/phase-1-connect.md
    Reply ↓

    Benedict
    April 6, 2016 at 7:17 pm

    These CFLAGS gave a huge crypto performance boost on Raspbian Jessie:

    ./clean && NO_TEST=1 Seccomp_NO=1 CFLAGS=”-march=armv7-a -mfpu=neon-vfpv4 -mfloat-abi=hard” ./do

    Benchmark results: https://github.com/tomeshnet/prototype-cjdns-pi2/blob/master/docs/phase-1-connect.md#cjdns-benchmark-1

Leave a Reply

Your email address will not be published. Required fields are marked *