配置 Tailscale 出口节点:处理 IP 转发与 UDP GRO 警告
在 Debian 或 Ubuntu 上执行 tailscale up --advertise-exit-node,常出现两条警告:
Warning: IP forwarding is disabled, subnet routing/exit nodes will not work.
Warning: UDP GRO forwarding is suboptimally configured on eth0, UDP forwarding
throughput capability will increase with a configuration change.
第一条不处理,出口节点无法转发流量;第二条只是性能提示,不修也能用。
两条警告的含义
出口节点要求内核开启 IP 转发,否则数据包到达本机即被丢弃。UDP GRO 是网卡把多个小 UDP 包合并处理的优化,但在转发场景下反而拖慢处理,因此建议在转发网卡上关闭。
第一步:开启 IP 转发(必须)
sudo tee /etc/sysctl.d/99-tailscale.conf <<'EOF'
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
EOF
sudo sysctl --system
验证:
sysctl net.ipv4.ip_forward
期望输出 net.ipv4.ip_forward = 1。若仍为 0,检查文件名是否以 .conf 结尾、是否位于 /etc/sysctl.d/。
第二步:关闭 eth0 的 UDP GRO(建议)
sudo ethtool -K eth0 rx-udp-gro-forwarding off
该命令重启后失效,用 systemd 服务持久化:
sudo tee /etc/systemd/system/tailscale-ethtool.service <<'EOF'
[Unit]
Description=Turn off UDP GRO forwarding on eth0
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/sbin/ethtool -K eth0 rx-udp-gro-forwarding off
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable --now tailscale-ethtool.service
网卡名不一定是 eth0,云主机常见 ens3、eth1,先用 ip link 确认后替换所有命令中的名称。
第三步:重新宣告出口节点
sudo tailscale up --advertise-exit-node
若 IP forwarding 警告仍在,重启守护进程:
sudo systemctl restart tailscaled
第四步:后台批准
--advertise-exit-node 只是宣告,默认不生效。打开 https://login.tailscale.com/admin/machines,进入该机器详情页的 Edit route settings,勾选 Exit node 并保存。
第五步:客户端指定出口节点
sudo tailscale up --exit-node=<服务器的 100.x 地址>
地址用 tailscale ip 或 tailscale status 查看。
验证
在客户端访问查 IP 的网站,应显示出口节点的公网 IP。若仍是本地 IP,回到第四步检查后台勾选,再确认 sysctl net.ipv4.ip_forward 输出为 1。
边界与常见误解
出口节点集中所有流量,带宽和延迟受该机器上行带宽限制。开启 IP 转发后,公网侧不要暴露不必要的服务。UDP GRO 关闭对普通 TCP 业务无影响;若某类 UDP 应用吞吐下降,可临时用 ethtool -K eth0 rx-udp-gro-forwarding on 恢复对比。