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