claw-relay
You are helping a human set up claw-relay — a method for routing AI agent traffic through a residential IP address using Tailscale exit nodes. No custom relay, no daemon, no proxy software. Just Tailscale.
Architecture
There are two nodes connected by a Tailscale tunnel:
CODEBLOCK0
- - Cloud node: A VPS running the AI agent. Tailscale routes its traffic through the exit node.
- Residential node: The human's laptop running Tailscale as an exit node. Traffic exits from this IP.
- Tailscale connects the two over an encrypted WireGuard tunnel. No custom code needed.
Which node are you setting up?
Ask the human which side they need to configure. They may need to do both, but walk through one at a time.
Residential Node Setup (human's laptop — do this first)
The human's laptop becomes a Tailscale exit node, allowing the VPS to route traffic through it.
Prerequisites
- - A Tailscale account (free at https://tailscale.com)
1. Install Tailscale
macOS:
CODEBLOCK1
Linux:
CODEBLOCK2
2. Enable as exit node
CODEBLOCK3
3. Approve the exit node
Go to the Tailscale admin console at https://login.tailscale.com/admin/machines — find the laptop and approve it as an exit node by clicking the three-dot menu → "Edit route settings" → enable "Use as exit node".
Alternatively, if you have --accept-routes on your policy, this happens automatically.
Test
CODEBLOCK4
The laptop should show as an exit node in the tailnet.
Cloud Node Setup (VPS)
This is the server running your AI agent. It joins the same tailnet and routes all traffic through the residential exit node.
Prerequisites
- - A VPS or cloud server (any provider — DigitalOcean, Hetzner, AWS, etc.)
- The residential node must already be set up as an exit node
1. Install Tailscale
CODEBLOCK5
2. Join the tailnet and set exit node
Find the residential node's Tailscale hostname or IP:
CODEBLOCK6
Then set it as the exit node:
CODEBLOCK7
Replace <laptop-hostname-or-ip> with the Tailscale IP (e.g., 100.64.x.x) or hostname of the laptop.
3. Verify
CODEBLOCK8
The response should show the residential IP (the laptop's public IP), not the VPS IP.
Agent Configuration
Once the exit node is set, all traffic from the VPS routes through the laptop automatically. No proxy configuration needed in your agent code — it's transparent at the network level.
Your agent code doesn't change at all:
CODEBLOCK9
CODEBLOCK10
CODEBLOCK11
Per-process control (optional)
If you want only specific processes to use the exit node instead of all VPS traffic, you can use Tailscale's --exit-node with app-specific routing or configure HTTPS_PROXY with a local proxy that routes through Tailscale.
Advanced: Isolation with Tailscale ACLs
For production setups, use Tailscale ACLs to control which machines can use which exit nodes:
CODEBLOCK12
Tag your VPS as tag:agent and your laptop as tag:exitnode to restrict access.
Advanced: Headscale (fully self-hosted)
If you want zero dependency on Tailscale's coordination server, use Headscale — an open-source, self-hosted implementation of the Tailscale control server.
- 1. Deploy Headscale on a server you control
- Point both nodes to your Headscale instance instead of Tailscale's servers
- Everything else works the same — WireGuard tunnels, exit nodes, ACLs
This gives you a fully self-hosted solution with no third-party dependencies.
Troubleshooting
- - Exit node not showing: Make sure you approved it in the admin console
- VPS still shows datacenter IP: Run
tailscale status to verify the exit node is connected, then sudo tailscale up --exit-node=<laptop> again - Connection drops: Check that the laptop has internet access and Tailscale is running
- Laptop went to sleep: Tailscale reconnects automatically when the laptop wakes up, but the VPS will lose internet access while the laptop is offline
claw-relay
你正在帮助用户设置 claw-relay —— 一种通过 Tailscale 出口节点将 AI 代理流量路由至住宅 IP 地址的方法。无需自定义中继、守护进程或代理软件,仅需 Tailscale。
架构
两个节点通过 Tailscale 隧道连接:
┌──────────────────────┐ ┌──────────────────────┐
│ 云端节点 │ │ 住宅节点 │
│ (数据中心 IP) │ │ (家庭 IP) │
│ │ │ │
│ AI 代理 │ │ Tailscale │
│ ↓ │ │ (出口节点) │
│ Tailscale ─────────┼── WG ───▶│ ↓ │
│ (使用出口节点) │ │ 互联网 │
│ │ │ (从家庭网络出口) │
└──────────────────────┘ └──────────────────────┘
- - 云端节点:运行 AI 代理的 VPS。Tailscale 将其流量通过出口节点路由。
- 住宅节点:用户运行 Tailscale 作为出口节点的笔记本电脑。流量从此 IP 出口。
- Tailscale 通过加密的 WireGuard 隧道连接两者。无需自定义代码。
你正在配置哪个节点?
询问用户需要配置哪一侧。他们可能需要同时配置两侧,但请逐一进行。
住宅节点设置(用户的笔记本电脑 —— 先执行此步骤)
用户的笔记本电脑成为 Tailscale 出口节点,允许 VPS 通过它路由流量。
前提条件
- - Tailscale 账户(免费,访问 https://tailscale.com)
1. 安装 Tailscale
macOS:
bash
brew install tailscale
Linux:
bash
curl -fsSL https://tailscale.com/install.sh | sh
2. 启用为出口节点
bash
sudo tailscale up --advertise-exit-node
3. 批准出口节点
访问 Tailscale 管理控制台 https://login.tailscale.com/admin/machines —— 找到笔记本电脑,点击三点菜单 → 编辑路由设置 → 启用用作出口节点以批准其为出口节点。
或者,如果你的策略中设置了 --accept-routes,此操作会自动完成。
测试
bash
tailscale status
笔记本电脑应在 tailnet 中显示为出口节点。
云端节点设置(VPS)
这是运行 AI 代理的服务器。它加入相同的 tailnet,并将所有流量通过住宅出口节点路由。
前提条件
- - VPS 或云服务器(任何提供商 —— DigitalOcean、Hetzner、AWS 等)
- 住宅节点必须已设置为出口节点
1. 安装 Tailscale
bash
curl -fsSL https://tailscale.com/install.sh | sh
2. 加入 tailnet 并设置出口节点
查找住宅节点的 Tailscale 主机名或 IP:
bash
tailscale status
然后将其设置为出口节点:
bash
sudo tailscale up --exit-node=<笔记本电脑主机名或IP>
将 <笔记本电脑主机名或IP> 替换为笔记本电脑的 Tailscale IP(例如 100.64.x.x)或主机名。
3. 验证
bash
curl https://httpbin.org/ip
响应应显示住宅 IP(笔记本电脑的公网 IP),而非 VPS IP。
代理配置
出口节点设置完成后,VPS 的所有流量自动通过笔记本电脑路由。无需在代理代码中进行代理配置 —— 这在网络层面是透明的。
你的代理代码完全无需更改:
python
import requests
r = requests.get(https://httpbin.org/ip)
print(r.json()) # 显示住宅 IP
javascript
const res = await fetch(https://httpbin.org/ip);
console.log(await res.json()); // 显示住宅 IP
bash
curl https://httpbin.org/ip # 显示住宅 IP
按进程控制(可选)
如果你只想让特定进程使用出口节点而非所有 VPS 流量,可以使用 Tailscale 的 --exit-node 配合应用特定路由,或配置 HTTPS_PROXY 指向通过 Tailscale 路由的本地代理。
高级:使用 Tailscale ACL 进行隔离
对于生产环境,使用 Tailscale ACL 控制哪些机器可以使用哪些出口节点:
json
{
tagOwners: {
tag:agent: [autogroup:admin],
tag:exitnode: [autogroup:admin]
},
acls: [
{
action: accept,
src: [tag:agent],
dst: [tag:exitnode:*]
}
]
}
将 VPS 标记为 tag:agent,笔记本电脑标记为 tag:exitnode 以限制访问。
高级:Headscale(完全自托管)
如果你希望完全摆脱对 Tailscale 协调服务器的依赖,可以使用 Headscale —— 一个开源、自托管的 Tailscale 控制服务器实现。
- 1. 在你控制的服务器上部署 Headscale
- 将两个节点指向你的 Headscale 实例而非 Tailscale 的服务器
- 其他一切保持不变 —— WireGuard 隧道、出口节点、ACL
这为你提供了一个完全自托管的解决方案,无需第三方依赖。
故障排除
- - 出口节点未显示:确保已在管理控制台中批准
- VPS 仍显示数据中心 IP:运行 tailscale status 验证出口节点已连接,然后再次运行 sudo tailscale up --exit-node=<笔记本电脑>
- 连接断开:检查笔记本电脑是否有互联网连接且 Tailscale 正在运行
- 笔记本电脑进入睡眠状态:笔记本电脑唤醒时 Tailscale 会自动重新连接,但笔记本电脑离线期间 VPS 将失去互联网访问