Files
tailscale/README.md
2026-04-10 10:27:35 +08:00

88 lines
2.4 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.
# Tailscale Docker 部署Headscale
使用 Docker Compose 部署 Tailscale連線至自架的 Headscale 控制伺服器。
## 功能
- 透過 Docker 容器執行 Tailscale使用 host 網路模式
- 連線至 `https://headscale.lotimmy.com`
- 子網路由廣播192.168.88.0/24
- 出口節點Exit Node支援
- iptables NAT/轉送自動設定
- 透過 Watchtower 自動更新容器映像
## 檔案結構
| 檔案 | 說明 |
|------|------|
| `docker-compose.yml` | Docker 服務定義 |
| `.env` | 環境變數TS_AUTHKEY |
| `run.sh` | 啟動容器 |
| `stop.sh` | 停止容器 |
| `docker_exec_tailscale_up.sh` | 連線至 Headscale含路由與出口節點設定 |
| `docker_exec_tailscale_status.sh` | 查看連線狀態 |
| `docker_exec_tailscale_ip.sh` | 查詢 Tailscale IP |
| `tailscale` | Tailscale CLI 包裝腳本 |
| `iptables_reset_and_configure.sh` | 防火牆與 NAT 設定 |
## 快速開始
```bash
# 1. 設定 .env 中的 TS_AUTHKEY
# 2. 啟動
./run.sh
# 3. 連線至 Headscale
./docker_exec_tailscale_up.sh
# 4. 設定防火牆(如需路由功能)
sudo ./iptables_reset_and_configure.sh
# 5. 驗證
./docker_exec_tailscale_status.sh
```
## 網路架構
```
Tailscale 節點 ──► Headscale (headscale.lotimmy.com)
tailscale0 介面 (100.64.0.0/10)
NAT MASQUERADE
eth0 ──► LAN (192.168.88.0/24)
```
## 主機名稱慣例
使用 `ip-{LAN-IP}` 格式,例如 `ip-192-168-42-126`,對應主機的區域網路 IP。
## 部署後設定
建立 symlink 讓 `tailscale` 指令全域可用:
```bash
ln -sf /opt/tailscale/tailscale /usr/local/bin/tailscale
```
## LXC 容器注意事項
Proxmox LXC 環境無 TUN 裝置,需使用 `tailscaled --tun=userspace-networking`。詳見 [OPERATIONS.md](OPERATIONS.md#proxmox-lxc-部署注意事項)。
## 節點部署對照表
| 主機 | 類型 | Tailscale IP | 主機名稱 | 備註 |
|------|------|-------------|---------|------|
| 192.168.42.100 | Proxmox LXC | 100.64.0.13 | ip-192-168-42-100 | userspace networking |
| 192.168.42.104 | Proxmox LXC | 100.64.0.14 | ip-192-168-42-104 | userspace networking |
| 192.168.42.126 | Proxmox LXC | 100.64.0.8 | ip-192-168-42-126 | userspace networking |
## 相關文件
- [QUICKSTART.md](QUICKSTART.md) — 快速開始指南
- [OPERATIONS.md](OPERATIONS.md) — 維運操作手冊
- [SUMMARY.md](SUMMARY.md) — 專案摘要