brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: hosts in the Tailscale policy file give IP addresses a name

Network and access
~/tips/tip-tailscale-policy-hosts

"hosts": {

Name subnet addresses in your policy so rules say what they protect.

Rules that point at subnet addresses are hard to read a month later. Which device was 192.0.2.40 again? The hosts section lets you give it a name.

"hosts": {
  "printer": "192.0.2.40",
  "camera-net": "192.0.2.128/26"
}

A name can point at a single address or a whole range. Use it in a rule like any other destination:

"grants": [
  {
    "src": ["group:family"],
    "dst": ["printer"],
    "ip": ["tcp:631", "tcp:9100"]
  }
]

This matters most with subnet routers, where devices on your LAN have no Tailscale name of their own. Without a hosts entry, the rule is just a number.

If the printer ever gets a new address, you change one line and all rules follow, which I think is the whole point.

A few details from the docs: the name cannot contain an @, and these names only exist inside the policy file. They do not create DNS names, so you still cannot type printer in a browser. For that you need a DNS record in your own DNS server or split DNS.

Further reading: Tailnet policy file syntax

More Network and access tips scp -3 alice@server-a:/var/backups/db.sql.gz bob@server-b:/srv/restore/ tailscale exit-node suggest tailscale lock sign nodekey:1abddef1 tlpub:abcdef12 wg genpsk > peer1.psk Table = off All Network and access tips (163) All topics

Link