Tailscale software is available for Keenetic routers as an OpenWRT package (OPKG). OPKG support is optional and needs to be enabled (See the documentation). It is available for routers with USB ports that support USB flash drives (the supported routers are listed in the documentation).
External USB storage is preferred, as internal router memory is limited to a few hundred MB and Tailscale binaries are about 50 MB.
Prepare USB drive
The first step is to prepare a USB drive with an ext4 file system. It can be a partition or the entire USB can be formatted as an ext4 file system. It needs to be done on a separate Linux system. (See the documentation on how to format a USB drive on different systems)
1 2 3 4 5 6 | |
The next step is to download the Entware installer and save it to the USB drive. The installer should match the router architecture (mipsel, mips or aarch64). See the documentation section 3 to identify which router model requires a specific architecture. The example below uses mipsel architecture.
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
Install Tailscale on the router
After umount /mnt/usb, it is safe to remove the USB drive and plug it into the router USB port.
The drive should appear on the router System Dashboard section USB Drives and printers and in the Applications page under the USB Devices section. Make sure that it shows the correct label set before, in our example, USB128GB. See the documentation for example screenshots.
Go to the OPKG page and select appropriate device in the Drive dropdown. Click the Save button.
Go to the Diagnostics page and check System Log for the "Entware" installed! message and the default ssh login and password.
1 2 | |
Add a section to .ssh/config
1 2 3 4 5 6 7 | |
Optionally, put your ssh public keys into /opt/etc/dropbear/authorized_keys for passwordless login.
1
| |
Log in with ssh using the default password (see the System log above):
1
| |
Change the default password:
1
| |
Update the OPKG packages:
1
| |
Install Tailscale packages:
1
| |
Bring the Tailscale node up
- The tailscaled won’t be able to modify the system
resolv.conf, so use--accept-dns=false. - The system
iptablesrules are periodically reset by the router software, so we can’t rely on tailscaled to maintain them and need to turn them off:--netfilter-mode=off. - We want to be able to
sshinto the router through the Tailnet, so use--ssh(it works only through the Tailscale web admin panel). - We want to access the subnet connected to the router through the Tailnet, so use
--advertise-routes 192.168.1.0/24(replace with your own subnet address). - We want to use the route as an exit node, so use
--advertise-exit-node.
1 2 | |
Configure netfilter rules
Without netfilter rules, the exit node and advertised routes won’t work. We need to set up custom hooks for Keentic to configure netfilter rules. We need to create two files in the hook subdirectory /opt/etc/ndm/netfilter.d (See the documentation).
/opt/etc/ndm/netfilter.d/tailscale-filter.sh to configure the default filter table:
Set the variable ROUTER_TAILSCALE_IP to the IP returned by the tailscale ip -4 command on the router or look up in tailscale status output on another Tailscale host.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
/opt/etc/ndm/netfilter.d/tailscale-nat.sh to configure nat table:
1 2 3 4 5 6 7 8 9 | |
The router software resets iptables rules frequently, and it can do this even while these hooks are running, so it is normal to see iptables errors in the router logs. Verify that the rules are applied properly with ssh keenetic iptables-save |grep ts-.
The rules are created by running tailscale with --netfilter-mode=on and saving the rules with iptables-save.