Files
tailscale/OPERATIONS.md
Timmy 2ffa06ac80 Initial commit: Tailscale Docker deployment with Headscale
Docker Compose 部署 Tailscale 連線至自架 Headscale 控制伺服器,
包含子網路由、出口節點、iptables NAT 設定及完整中文文件。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 09:17:12 +08:00

94 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Operations Guide
## 日常操作
### 啟動服務
```bash
./run.sh
```
啟動 Tailscale Docker 容器(背景執行)。
### 停止服務
```bash
./stop.sh
```
停止並移除容器。
### 連線至 Headscale
```bash
./docker_exec_tailscale_up.sh
```
使用預設的 Auth Key 連線至 `https://headscale.lotimmy.com`,並:
- 廣播子網路 `192.168.88.0/24`
- 啟用出口節點Exit Node
- 接受其他節點的路由
### 檢查狀態
```bash
./docker_exec_tailscale_status.sh # 查看連線狀態
./docker_exec_tailscale_ip.sh # 查詢 Tailscale IP
```
### 執行任意 Tailscale 指令
```bash
./tailscale status
./tailscale ping <peer>
./tailscale netcheck
```
`./tailscale``docker exec -i tailscale tailscale` 的包裝腳本。
## 防火牆與路由設定
在主機上執行:
```bash
sudo ./iptables_reset_and_configure.sh
```
此腳本會:
1. 清除所有現有 iptables 規則
2. 允許 SSH (22)、HTTP (80)、HTTPS (443)、ICMP
3. 設定 Tailscale CGNAT 範圍 (100.64.0.0/10) 的 NAT MASQUERADE
4. 啟用 `tailscale0``eth0` 之間的封包轉送
5. 將規則儲存至 `/etc/iptables/rules.v4`
## 環境變數
| 變數 | 說明 | 位置 |
|------|------|------|
| `TS_AUTHKEY` | Headscale 預認證金鑰 | `.env` |
## 持久化資料
- Tailscale 狀態檔案:主機的 `/opt/tailscale` 掛載至容器的 `/var/lib/tailscale`
- iptables 規則:`/etc/iptables/rules.v4`
## 故障排除
```bash
# 確認容器正在執行
docker ps | grep tailscale
# 查看容器日誌
docker logs tailscale
# 確認 TUN 裝置存在
ls -la /dev/net/tun
# 確認 IP 轉送已啟用
cat /proc/sys/net/ipv4/ip_forward
# 登出並重新連線
./tailscale logout
./docker_exec_tailscale_up.sh
```