Cross-compile and deploy newt to MIPS32 little-endian OpenWrt routers (e.g., Siflower SF19A28).
# Clone
git clone https://github.com/fosrl/newt /tmp/newt
cd /tmp/newt
# Cross-compile for MIPS32 LE soft-float
GOOS=linux GOARCH=mipsle GOMIPS=softfloat CGO_ENABLED=0 \
go build -ldflags="-s -w" -o newt_linux_mipsle .With Nix:
nix develop --command bash -c \
"GOOS=linux GOARCH=mipsle GOMIPS=softfloat CGO_ENABLED=0 go build -ldflags='-s -w' -o newt_linux_mipsle ."OpenWrt uses dropbear (no SFTP). Use legacy SCP:
scp -O newt_linux_mipsle root@openwrt-glinet:/usr/bin/newt
ssh root@openwrt-glinet "chmod +x /usr/bin/newt"Verify:
ssh root@openwrt-glinet "/usr/bin/newt --help"Create config file locally:
cat > /tmp/newt.config << 'EOF'
PANGOLIN_ENDPOINT="https://your-pangolin-server.com"
NEWT_ID="your-newt-id"
NEWT_SECRET="your-newt-secret"
EOFTransfer:
ssh root@openwrt-glinet "mkdir -p /etc/newt"
cat /tmp/newt.config | ssh root@openwrt-glinet "cat > /etc/newt/config && chmod 600 /etc/newt/config"Create locally:
cat > /tmp/newt.init << 'EOF'
#!/bin/sh /etc/rc.common
START=99
STOP=10
USE_PROCD=1
start_service() {
. /etc/newt/config
procd_open_instance
procd_set_param command /usr/bin/newt \
--endpoint "$PANGOLIN_ENDPOINT" \
--id "$NEWT_ID" \
--secret "$NEWT_SECRET" \
--log-level INFO
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
EOFTransfer and enable:
cat /tmp/newt.init | ssh root@openwrt-glinet "cat > /etc/init.d/newt && chmod +x /etc/init.d/newt"
ssh root@openwrt-glinet "/etc/init.d/newt enable && /etc/init.d/newt start"ssh root@openwrt-glinet "ps | grep newt"
ssh root@openwrt-glinet "logread | grep newt | tail -10"Expected output:
Websocket connected
Tunnel connection to server established successfully!
Client connectivity setup. Ready to accept connections from clients!
/etc/init.d/newt start
/etc/init.d/newt stop
/etc/init.d/newt restart
/etc/init.d/newt enable # start at boot
/etc/init.d/newt disable # disable at bootIf using newt as a subnet gateway with --accept-clients, use native mode to create a kernel interface:
procd_set_param command /usr/bin/newt \
--endpoint "$PANGOLIN_ENDPOINT" \
--id "$NEWT_ID" \
--secret "$NEWT_SECRET" \
--native \
--log-level INFOEnable IP forwarding:
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
echo "net.ipv4.conf.all.rp_filter=0" >> /etc/sysctl.conf
sysctl -pSee fosrl/pangolin#1370 for details on userspace vs native mode limitations.
- Config stored at
/.config/newt-client/config.jsonafter first successful connection