Slackware

Tailscale

ページ作成日

公式サイト

Tailscale

概要

Tailscaleは、WireGuardをベースにしたセキュア接続基盤です。
複雑なVPN設定なしに、デバイス間のセキュアな接続を簡単に構築できます。
NAT越えやファイアウォール越えも自動的に処理されるため、どこからでもプライベートネットワークにアクセスできます。

公式が配布している静的バイナリにはsystray(システムトレイアプリ)が含まれていないため、ここではソースからコンパイルしてパッケージを作成します。

Make it by yourself!

ソースコードの取得

GitHubからソースコードをクローンし、目的のバージョンにチェックアウトします。


cd ~/Downloads
git clone https://github.com/tailscale/tailscale.git
cd tailscale
git checkout v1.92.5

コンパイル

Goを使用して、tailscale、tailscaled、systrayの3つのバイナリをビルドします。 CGO_ENABLED=0を指定して静的リンクでビルドし、-ldflagsでバージョン情報を埋め込みます。


CGO_ENABLED=0 /usr/bin/time -v go build -ldflags "-X tailscale.com/version.longStamp=1.92.5 -X tailscale.com/version.shortStamp=1.92.5" -o tailscale ./cmd/tailscale

[画面出力を略]
        Command being timed: "go build -ldflags ... -o tailscale ./cmd/tailscale"
        User time (seconds): 51.47
        System time (seconds): 7.89
        Percent of CPU this job got: 384%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:15.43
        Maximum resident set size (kbytes): 632456
        Exit status: 0

CGO_ENABLED=0 /usr/bin/time -v go build -ldflags "-X tailscale.com/version.longStamp=1.92.5 -X tailscale.com/version.shortStamp=1.92.5" -o tailscaled ./cmd/tailscaled

[画面出力を略]
        Command being timed: "go build -ldflags ... -o tailscaled ./cmd/tailscaled"
        User time (seconds): 68.23
        System time (seconds): 9.12
        Percent of CPU this job got: 412%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:18.76
        Maximum resident set size (kbytes): 784512
        Exit status: 0

CGO_ENABLED=0 /usr/bin/time -v go build -ldflags "-X tailscale.com/version.longStamp=1.92.5 -X tailscale.com/version.shortStamp=1.92.5" -o tailscale-systray ./cmd/systray

[画面出力を略]
        Command being timed: "go build -ldflags ... -o tailscale-systray ./cmd/systray"
        User time (seconds): 42.31
        System time (seconds): 6.45
        Percent of CPU this job got: 356%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:13.69
        Maximum resident set size (kbytes): 521344
        Exit status: 0

パッケージ作成用ディレクトリの準備

Slackwareパッケージ用のディレクトリ構造を作成します。


mkdir -p /tmp/tailscale-1.92.5/usr/bin
mkdir -p /tmp/tailscale-1.92.5/usr/sbin
mkdir -p /tmp/tailscale-1.92.5/etc/rc.d
mkdir -p /tmp/tailscale-1.92.5/var/lib/tailscale
mkdir -p /tmp/tailscale-1.92.5/install

バイナリのコピー

ビルドしたバイナリを適切な場所にコピーします。


cp tailscale /tmp/tailscale-1.92.5/usr/bin/
cp tailscale-systray /tmp/tailscale-1.92.5/usr/bin/
cp tailscaled /tmp/tailscale-1.92.5/usr/sbin/

起動スクリプトの作成

SlackwareはSysVinitを使用しているため、rc.dスクリプトを作成します。


cat << 'EOF' > /tmp/tailscale-1.92.5/etc/rc.d/rc.tailscaled
#!/bin/bash
#
# /etc/rc.d/rc.tailscaled
#
# Start/stop/restart the Tailscale daemon.
#

TAILSCALED=/usr/sbin/tailscaled
PIDFILE=/var/run/tailscaled.pid
STATEDIR=/var/lib/tailscale

tailscaled_start() {
  if [ -x $TAILSCALED ]; then
    echo "Starting Tailscale daemon..."
    $TAILSCALED --state=$STATEDIR/tailscaled.state --socket=/var/run/tailscale/tailscaled.sock &
  fi
}

tailscaled_stop() {
  echo "Stopping Tailscale daemon..."
  killall tailscaled 2>/dev/null
}

tailscaled_restart() {
  tailscaled_stop
  sleep 1
  tailscaled_start
}

tailscaled_status() {
  if pgrep -x tailscaled >/dev/null; then
    echo "Tailscale daemon is running."
  else
    echo "Tailscale daemon is not running."
  fi
}

case "$1" in
  start)
    tailscaled_start
    ;;
  stop)
    tailscaled_stop
    ;;
  restart)
    tailscaled_restart
    ;;
  status)
    tailscaled_status
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
EOF
chmod 755 /tmp/tailscale-1.92.5/etc/rc.d/rc.tailscaled

slack-descの作成

パッケージの説明ファイルを作成します。


cat << 'EOF' > /tmp/tailscale-1.92.5/install/slack-desc
# HOW TO EDIT THIS FILE:
# The "handy ruler" below makes it easier to edit a package description.
# Line up the first '|' above the ':' following the base package name, and
# the '|' on the right side marks the last column you can put a character in.
# You must make exactly 11 lines for the formatting to be correct.  It's also
# customary to leave one space after the ':'.

         |-----handy-ruler------------------------------------------------------|
tailscale: tailscale (WireGuard-based mesh VPN)
tailscale:
tailscale: Tailscale is a WireGuard-based mesh VPN that makes it easy to
tailscale: connect your devices, wherever they are. It handles NAT traversal,
tailscale: firewalls, and provides secure private networking.
tailscale:
tailscale: This package includes tailscale-systray for KDE/GNOME integration.
tailscale:
tailscale: Homepage: https://tailscale.com
tailscale:
tailscale:
EOF

パッケージの作成

インストーラーパッケージを作成します。


cd /tmp/tailscale-1.92.5
sudo makepkg --linkadd y --chown y ../tailscale-1.92.5-x86_64-1.txz

[画面出力を省略]

Slackware package ../tailscale-1.92.5-x86_64-1.txz created.

パッケージのインストール

sudoでinstallpkgを使いパッケージをインストールすれば完了です。


sudo installpkg /tmp/tailscale-1.92.5-x86_64-1.txz

パッケージのアップグレード

既にインストールしていて、新しいバージョンに更新する場合は、sudoでupgradepkgを使います。


sudo upgradepkg /tmp/tailscale-1.92.5-x86_64-1.txz

パッケージのアンインストール

パッケージをアンインストールする場合は、sudoでremovepkgを使います。


sudo removepkg tailscale-1.92.5-x86_64-1.txz

使い方

デーモンの起動

Tailscaleを使用するには、まずデーモンを起動します。


sudo /etc/rc.d/rc.tailscaled start

自動起動の設定

システム起動時に自動的にTailscaleを起動するには、/etc/rc.d/rc.localに以下を追記します。


# Start Tailscale daemon
if [ -x /etc/rc.d/rc.tailscaled ]; then
  /etc/rc.d/rc.tailscaled start
fi

ログイン

デーモン起動後、Tailscaleネットワークにログインします。


sudo tailscale up

表示されるURLにアクセスして認証を完了させてください。

状態確認

接続状態を確認するには以下のコマンドを使用します。


tailscale status

IPアドレスの確認

自分のTailscale IPアドレスを確認するには以下のコマンドを使用します。


tailscale ip

システムトレイアプリ(KDE/GNOME)

操作権限の設定

システムトレイアプリをsudoなしで操作するため、現在のユーザーをオペレータとして登録します。


sudo tailscale set --operator=$USER

システムトレイアプリの起動

以下のコマンドでシステムトレイアプリを起動します。rootでは実行しないでください。


tailscale-systray

KDE自動起動の設定

KDEログイン時に自動的にシステムトレイアプリを起動するには、以下のようにdesktopファイルを作成します。


mkdir -p ~/.config/autostart
cat << 'EOF' > ~/.config/autostart/tailscale-systray.desktop
[Desktop Entry]
Type=Application
Name=Tailscale Systray
Exec=/usr/bin/tailscale-systray
Icon=network-vpn
X-KDE-autostart-phase=2
EOF