Router setup

From BeeeOn
Jump to: navigation, search


Router setup

This page contains a quick guide on how to turn your router into a gateway.

Prerequisites

  • You will need the USB gateway dongle. Ask for one on Google+ and Facebook
  • A device running on OpenWrt-based firmware (it might be possible to get other devices to work but you will have to port the packages yourself)
  • You can either compile the necessary software yourself or use the pre-copmiled binary packages from our package feeds. We currently only have package feeds for the Turris and Omnia routers from CZ.NIC (https://www.turris.cz/en/), but are planning to add package feeds for more devices soon.
  • You will need a root shell on your router, preferably via SSH

Installing beeeon-gateway from the package feed

You will need to install the beeeon-gateway application in order to be able to use your router as a gateway.

Importing certificates

Packages from our package feed are retrieved via HTTPS, but the Turris and Omnia routers do not come pre-installed with the root certificate of the CA (Let's Encrypt) we use on our site. It is therefore necessary to import the root certificates before setting up the package feed. This can be achieved with the following command:

cd /etc/ssl/certs && \
echo "-----BEGIN CERTIFICATE-----
MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
DkRTVCBSb290IENBIFgzMB4XDTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVow
PzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1cmUgVHJ1c3QgQ28uMRcwFQYDVQQD
Ew5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmTrE4O
rz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEq
OLl5CjH9UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9b
xiqKqy69cK3FCxolkHRyxXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw
7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40dutolucbY38EVAjqr2m7xPi71XAicPNaD
aeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
HQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQMA0GCSqG
SIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69
ikugdB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXr
AvHRAosZy5Q6XkjEGB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZz
R8srzJmwN0jP41ZL9c8PDHIyh8bwRLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5
JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubSfZGL+T0yjWW06XyxV3bqxbYo
Ob8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
-----END CERTIFICATE-----" \
> dstrootx3.pem && \
chmod 644 dstrootx3.pem && \
ln -s dstrootx3.pem $(openssl x509 -hash -noout -in dstrootx3.pem).0 && \
cp dstrootx3.pem ../ && \
cd - && \
echo "Certificate import OK!"

Setting up the package feed

In order to be able to install the beeeon-gateway app, you will need to add our package feed. Use the following command for Turris:

echo "src/gz beeeon https://download.beeeon.org/gateway/packages/turris/" >> /etc/opkg/opkg.conf && opkg update

and the following command for Omnia:

echo "src/gz beeeon https://download.beeeon.org/gateway/packages/omnia/" >> /etc/opkg/opkg.conf && opkg update

Installing the application

You may now install the gateway application using the following command:

opkg install beeeon-gateway

The application will automatically start running as a service once the install is complete. You can use the procd script to control the application:

/etc/init.d/beeeon-gateway {start|stop|restart|enable|disable}

Compiling beeeon-gateway using the OpenWrt SDK

If you can't or don't want to use any of the official binary package feeds, you will have to compile all the necessary software yourself. If you want to use our source package feeds, you will need a working OpenWrt build system. You can also try to find a fork of the official OpenWrt build system for your device (a fork for Turris and Omnia is available here). This will likely be much easier to set up than the official bleeding edge version.

Importing source package feeds

You should now have a copy of the OpenWrt build system which is correctly set up to compile software for your device. Please note that all commands and examples in this section assume that your working directory is the root of the OpenWrt build system. Proceed to import our OpenWrt package feed by adding the following line to the top of the feeds.conf.default file:

src-git beeeon https://github.com/BeeeOn/openwrt-packages.git^$commit_hash

Most people will probably want to replace $commit_hash with the hash of the latest commit in the repository.

Updating the feeds

It is now necessary to update the package feeds and retrieve the newly added package sources. You need to clean the existing feeds and fetch all the feeds including the BeeeOn feed again.

scripts/feeds clean
scripts/feeds update -a
scripts/feeds install -a

Compiling beeeon-gateway

The recommended way to compile the gateway application is via

make menuconfig

Navigate to Extra packages and select beeeon-gateway as a modular feature (press M). You can then run make to start the build. If the build fails, try running make with V=99 to see a verbose output. If everything is successful, you should be able to find the binary .ipk packages in bin/your_architecture/packages/beeeon. You should then be able to copy those packages over to your device and install them with opkg. Please note that you will probably need to install some additional dependencies which are part of the standard OpenWrt repositories as well (opkg will display an error if you attempt to install a package without satisfying its dependencies first).