Skip to content

Instantly share code, notes, and snippets.

@liamcottle
Created January 8, 2025 08:16
Show Gist options
  • Save liamcottle/f42d01570108ec71706fb9c109fc5408 to your computer and use it in GitHub Desktop.
Save liamcottle/f42d01570108ec71706fb9c109fc5408 to your computer and use it in GitHub Desktop.
TNCAttach + RNode TNC = LoRa IP

TNCAttach + RNode TNC = LoRa IP

Pi 4B <-> USB RNode TNC <-> LoRa 917.875MHz BW500kHz SF7 CR5 TXP17 <-> USB RNode TNC <-> Pi 4B <-> WiFi 2.4GHz (Internet)

Install System Dependencies

sudo apt install build-essential
sudo apt install python3-pip

Build and install tncattach

git clone https://github.com/markqvist/tncattach.git
cd tncattach
make
sudo make install

Install rnodeconf

pip install rns --break-system-packages

Configure RNode and tncattach on device 1

rnodeconf --tnc --freq 917875000 --bw 500000 --sf 7 --cr 5 --txp 17 /dev/ttyUSB0
sudo tncattach /dev/ttyUSB0 115200 -d -e --noipv6 --mtu 500 --ipv4 10.200.0.1/24

Configure RNode and tncattach on device 2

rnodeconf --tnc --freq 917875000 --bw 500000 --sf 7 --cr 5 --txp 17 /dev/ttyACM0
sudo tncattach /dev/ttyACM0 115200 -d -e --noipv6 --mtu 500 --ipv4 10.200.0.2/24

Add default route to internet for device 2 via device 1 available on tnc0

sudo route add default gw 10.200.0.1 tnc0

Enable masquerade on device 1 that is serving the internet connection

sudo nano /etc/nftables.conf
sudo systemctl enable nftables
sudo systemctl start nftables
# masquerade wlan0 to allow other devices to reach internet through us
# this has been added to allow tnc0 clients to route to 0.0.0.0 via our wlan0
table ip nat {
    chain postrouting {
        type nat hook postrouting priority 100; policy accept;
        oifname "wlan0" masquerade
    }
}

Systemd Service

sudo nano /etc/systemd/system/tncattach.service
sudo systemctl enable tncattach
sudo systemctl start tncattach
sudo systemctl status tncattach
[Unit]
Description=tncattach
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/usr/bin/env tncattach /dev/ttyUSB0 115200 -e --noipv6 --ipv4 10.200.0.1/24

[Install]
WantedBy=multi-user.target

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment