sing-box is the edge between tailscale network and home LAN network
- In tailscale client app (mobile / PC), you can connect to sing-box gateway exit node to chat with AI, unlock Pixel phone full features in some special places (haha), access home network, etc
- In home network, you can use sing-box as gateway by any means to chat with AI, access devices in tailscale networks that is visible by sing-box-gateway
- Every public DNS query in route -> be resolved by VPN DNS server via tunnel
- AI / IDE traffic -> route via VPN tunnel (haha)
- home network domain/traffic -> route to home router
- tailscale MagicDNS domain/ tailscale traffic -> tailscale
- The rest of traffic -> eth0
From offical doc, endpoints can be used as inbound and outbound, but only ts as outbound works in 12.x version, while ts as inbound only works after 1.13.x beta version (forgot).
- Repalce tailscale auth. token
YOUR_TAILSCALE_AUTH_KEYto your tailscale auth key - Replace exit node IP addresses
100.x.x.xto exit node you want to use it as outbound. It can be tailscale IP address of your own exit node or tailscale mullvad VPN add-on's exit node (May check with commandtailscale exit-node list), or you can also switch to Wireguard - Replace
yourdomain.comwith your own domain if you want sing-box to resolve your home LAN domains, or you can remove the entire block - Replace advertise_routes
192.168.x.0/24with your subnet if you want to connect to your home LAN netork. Just keep it in awaiting for approval but it is required - Change network interface
eth0if required (use ifconfig cmd to check) - Delete route
{ "ip_version": 6, "outbound": "ts-ep-mullvad-hk" }and switch allipv4_onlyin DNS module toprefer_ipv4if your ISP & local network support to reach site with IPv6 address - You can enable cache and change log.level to "warn" in production prefer_ipv4
Set IP forward
# Debian
echo 'net.ipv4.ip_forward = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
echo 'net.ipv6.conf.all.forwarding = 1' | sudo tee -a /etc/sysctl.d/99-tailscale.conf
sudo sysctl -p /etc/sysctl.d/99-tailscale.conf
(Optional) set dns-ts-mullvads-xx to Mullvad VPN Setting if you use tailscale mullvad VPN add-on as VPN servers
Setting -> Mullvad VPN -> add dns-ts-mullvads-xx to list
Tagging:
- sing-box-gateway: tag:network
- devices wants to back home: tag:home
"grants": [
//.......
// MagicDNS, All users and devices can access tag:dns for DNS query. Mark sing-box-gateway with network tag
{
"src": ["*"],
"dst": ["tag:network"],
"ip": ["udp:53"],
}
//.......
],
"grants": [
//.......
// All tag:home can access 192.168.x.0/24 via exit node with tag:home
{
"src": ["tag:home"],
"dst": ["192.168.x.0/24"],
"via": ["tag:home", "tag:network"],
"ip": ["*"],
},
//.......
],