8

Add tailscale to an EdgeRouter and surviving system upgrade

 2 years ago
source link: https://gist.github.com/arbourd/c440e4ee57e96887c838ea2274c43134
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Adding tailscale to a USG (and surviving system upgrades)

I suggest you run sudo su on all of these so you're the root user.

Installing

  1. Download tailscale and put the files in /config/. Find the latest stable or unstable version for your USG.
$ sudo su    # if you havent already
# export TAILSCALE_VERSION=1.18.1
# curl https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_mips.tgz | tar xvz -C /tmp
# cp /tmp/tailscale_*/* /tmp/tailscale_*/systemd/* /config/
  1. Create the /config/scripts/post-config.d/tailscale.sh file which gets run once every system upgrade. Reminder that /config survives upgrades. Don't forget to set the execute flag on the script inside post-config.d
cat << EOF > /config/scripts/post-config.d/tailscale.sh
#!/bin/sh
ln -s /config/tailscale /usr/bin/tailscale
ln -s /config/tailscaled /usr/sbin/tailscaled
mkdir -p /var/lib/tailscale/
touch /config/auth/tailscaled.state
chmod 0400 /config/auth/tailscaled.state
ln -s /config/auth/tailscaled.state /var/lib/tailscale/tailscaled.state
sudo tailscaled > /dev/null 2>&1 &
disown
sudo tailscale up --advertise-routes=192.168.0.0/16 --accept-routes 
EOF
chmod +x /config/scripts/post-config.d/tailscale.sh
  1. And run this script now to get things going (or manually run the commands if you'd like), and then run tailscale up to login. Feel free to use other parameters like tailscale up --advertise-routes=192.168.1.0/16
# /config/scripts/post-config.d/tailscale.sh
# tailscale up

Upgrading to a new version

  1. Download the version you want into a folder like /tmp and then copy the binaries over. Perhaps in future versions there may be more/less files or config changes, so make sure you take a look at what's now.
$ sudo su    # if you havent already
# export TAILSCALE_VERSION=1.18.1
# curl https://pkgs.tailscale.com/stable/tailscale_${TAILSCALE_VERSION}_mips.tgz | tar xvz -C /tmp
# for pid in $(ps -ef | awk '/tailscale/ {print $2}'); do kill -2 $pid; done
# cp /tmp/tailscale_*/{tailscale,tailscaled} /config/
# /config/scripts/post-config.d/tailscale.sh

Removing

  1. Stop the service if its still running
# sudo su    # if you havent already
# for pid in $(ps -ef | awk '/tailscale/ {print $2}'); do kill -2 $pid; done
  1. Delete all the files tailscale uses
# rm /etc/default/tailscaled
# rm /usr/bin/tailscale
# rm /usr/sbin/tailscaled
# rm -rf /var/lib/tailscale
  1. Remove your configs and persistent files (this includes your tailscaled.state which has your private key)
# rm /config/tailscale*
# rm /config/auth/tailscaled.state
# rm /config/scripts/firstboot.d/tailscale.sh

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK