Home Labs Stories What next after the first run of your gateway?


image story


Posted on Oct. 1, 2017

1 Hour



So, you have succesfully configured your homebrew gateway with poly_pkt_fwd or mp_pkt_fwd - it works, but how to build a stable gateway?

First step would be to ensure the packet forwarder runs at boot and recovers after an error. I depend on systemd - this is used by default on debian jessie and above.

DigitalOcean have some great tutorials online and I used this one for the basis of my implementation:


I know that TTN has halted development on the go version of pkt_fwd, but I find it useful and works well on my homebrew based on RAK831 and the FriendlyArm NanoPi Neo running ubuntu 16.04.3 LTS. The solution described below will work on any Raspberry PI running debian jessie or later with any of the compatible gateway boards, running any of the versions of packet forwarder.

So, systemd requires a script in /lib/systemd/system - here is mine:

Description=manage go version of packet forwarder

ExecStart=/opt/pkt_fwd_go/packet-forwarder-linux-arm-default-native start --config /opt/pkt_fwd_go/.pktfwd.yml


Having created this file, run:
sudo systemctl daemon-reload
Start the packet forwarder with:
sudo systemctl pkt_fwd_go
Go fill your coffee cup, wait a minute, then try:
sudo systemctl status pkt_fwd_go
Then run the following to ensure that the packet forwarder starts at each boot:
sudo systemctl enable application.service

Please read the DigitalOcean howto for an explanation of these commands.

"WantedBy= multi-user.target" ensure the system waits until it reaches the status of mult-user login before attempting to start the packet forwarder.

There is a problem with the go version of packet forwarder where it hangs after some use. The "Restart=always" line in the service script handles this and my gateway has been running for the past week, without my intervention.

Note that I piped the standard and error output of the packet forwarder to syslog. I use rsyslog and logrotate to manage the size of this output. By default, I backup syslog each day and keep the last 7 days logs on the system, so the syslog files in my /var/log folder looks like this:

-rw-r-----  1 syslog adm    1097921 Oct  1 12:09 syslog
-rw-r-----  1 syslog adm    4619057 Oct  1 06:25 syslog.1
-rw-r-----  1 syslog adm     355075 Sep 30 06:25 syslog.2.gz
-rw-r-----  1 syslog adm     652631 Sep 29 06:25 syslog.3.gz
-rw-r-----  1 syslog adm     521922 Sep 28 06:25 syslog.4.gz
-rw-r-----  1 syslog adm     342831 Sep 27 06:25 syslog.5.gz
-rw-r-----  1 syslog adm     432784 Sep 26 06:25 syslog.6.gz
-rw-r-----  1 syslog adm     265346 Sep 25 06:25 syslog.7.gz

I hope this helps some people out there - please add comments if you have any questions.