Initial commit: Headscale management scripts and configuration
- Add headscale binary and configuration files - Include management scripts for API keys, nodes, and authentication - Add Docker setup with docker-compose - Include backup and restore functionality - Add example scripts for creating API keys and pre-auth keys Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
107
README
Normal file
107
README
Normal file
@@ -0,0 +1,107 @@
|
||||
https://headscale.lotimmy.com
|
||||
|
||||
docker network create shared-net
|
||||
|
||||
# Create a pre-auth key
|
||||
headscale preauthkeys create --user 1 --reusable --ephemeral=false --expiration 24h
|
||||
|
||||
# Create a pre-auth key with long expiration
|
||||
headscale preauthkeys create --user 1 --reusable --ephemeral=false --expiration 87600h
|
||||
|
||||
headscale preauthkeys create \
|
||||
--user 1 \ # 給 ID 是 1 的人用(記得先用 list 查 ID)
|
||||
--reusable \ # 拿到這組 key,你想裝幾台機器都可以,不用換
|
||||
--ephemeral=false \ # 機器離線後名字還是會留著,不會被系統踢掉
|
||||
--expiration 87600h # 有效期開到最滿(10 年),懶人必備,不用每年重弄
|
||||
|
||||
|
||||
HS_十年金鑰
|
||||
2026-01-14T03:31:35Z TRC expiration has been set expiration=315360000000
|
||||
ef127d5251adc78d0250f869d00e5454e40612ba47f4ce80
|
||||
|
||||
|
||||
tailscale up --login-server <你的網址> --auth-key <指令產生的金鑰>
|
||||
tailscale up --login-server https://headscale.lotimmy.com --auth-key ef127d5251adc78d0250f869d00e5454e40612ba47f4ce80
|
||||
tailscale up --login-server https://headscale.lotimmy.com --auth-key ef127d5251adc78d0250f869d00e5454e40612ba47f4ce80 --accept-routes
|
||||
|
||||
# Register a node
|
||||
headscale nodes register --user USERNAME --key 2HdYHEaOQ30UUckHXt_dBYZr
|
||||
headscale nodes register --user mainnet --key tzDlexiDOMMIOlJUlkQUADTy
|
||||
headscale nodes register --user mainnet --key WxG-YH2yUTAz4Vf5bJaiJxG4
|
||||
headscale nodes register --user mainnet --key xi1HU_5AJqJXdKIhLY4E8WiU
|
||||
headscale nodes register --user mainnet --key t1o75XesCYNkVJxUnm-VNIst
|
||||
headscale nodes register --user mainnet --key lvfjwzg2KeISpdJtMtqMNeFN
|
||||
headscale nodes register --user mainnet --key 4L66v9uDIuzJdgeo4dupGLfL
|
||||
headscale nodes register --key 7oLjwdXp0OyIlrRbEZr35Gwv --user mainnet
|
||||
|
||||
# List routes
|
||||
headscale nodes list-routes
|
||||
|
||||
# Approve routes
|
||||
headscale nodes approve-routes --identifier 3 --routes 0.0.0.0/0,::/0
|
||||
headscale nodes approve-routes --identifier 4 --routes 0.0.0.0/0,192.168.42.0/24,::/0
|
||||
headscale nodes approve-routes --identifier 33 --routes 0.0.0.0/0,192.168.42.0/24,::/0
|
||||
headscale nodes approve-routes --identifier 5 --routes 192.168.42.0/24
|
||||
headscale nodes approve-routes --identifier 6 --routes 0.0.0.0/0,192.168.88.0/24,::/0
|
||||
headscale nodes approve-routes --identifier 19 --routes 0.0.0.0/0,192.168.88.0/24,::/0
|
||||
|
||||
# List all nodes
|
||||
headscale nodes list
|
||||
headscale nodes list --output json | jq '.[] | {id, name, tags: .forced_tags}'
|
||||
|
||||
|
||||
# Rename nodes
|
||||
headscale nodes rename --identifier 2 iphone-15-pro-max
|
||||
headscale nodes rename --identifier 4 ip-192-168-42-102
|
||||
headscale nodes rename --identifier 5 apple-tv-bedroom
|
||||
headscale nodes rename --identifier 7 ipad-mini-6
|
||||
headscale nodes rename --identifier 7 iphone-12
|
||||
headscale nodes rename --identifier 38 galaxy-tab-a
|
||||
|
||||
# Delete node 6
|
||||
headscale nodes delete --identifier 6
|
||||
headscale nodes delete --identifier 6 --force
|
||||
|
||||
# List pre-auth keys
|
||||
headscale preauthkeys list --user 1
|
||||
|
||||
|
||||
# List API keys
|
||||
headscale apikeys list
|
||||
|
||||
# Revoke API key
|
||||
headscale apikeys revoke <KEY_ID>
|
||||
|
||||
# 為指定節點加上 server 或 mobile 的 tag
|
||||
headscale nodes tag --identifier 4 --tags tag:server # ct102
|
||||
headscale nodes tag --identifier 9 --tags tag:server # 15-macbook-pro
|
||||
headscale nodes tag --identifier 12 --tags tag:server # ip-192-168-88-82
|
||||
headscale nodes tag --identifier 13 --tags tag:server # ip-141-11-93-252
|
||||
|
||||
headscale nodes tag --identifier 2 --tags tag:mobile # iphone-15-pro-max
|
||||
headscale nodes tag --identifier 5 --tags tag:mobile # apple-tv-bedroom
|
||||
headscale nodes tag --identifier 7 --tags tag:mobile # ipad-mini-6
|
||||
headscale nodes tag --identifier 8 --tags tag:mobile # oppo-a74-5g
|
||||
headscale nodes tag --identifier 11 --tags tag:mobile # iphone-xr
|
||||
|
||||
# 移除指定節點(ID 13)的所有 tags
|
||||
headscale nodes tag --identifier 13 --tags ""
|
||||
|
||||
|
||||
# 查看所有使用者
|
||||
headscale users list
|
||||
|
||||
# 將 ID 1 的使用者(namespace)改名為 mainnet
|
||||
headscale users rename --identifier 1 --new-name mainnet
|
||||
|
||||
|
||||
# ping 內部 tailnet 節點(例:100.64.0.4)
|
||||
tailscale ping 100.64.0.4
|
||||
|
||||
|
||||
|
||||
tailscale up --reset \
|
||||
--login-server https://headscale.lotimmy.com \
|
||||
--advertise-exit-node \
|
||||
--advertise-routes=192.168.42.0/24 \
|
||||
--accept-routes=false
|
||||
Reference in New Issue
Block a user