Rename a host
Change the name of a workstation, server or gateway, without touching the hardware. The host name acts as a key everywhere : it designates the deployment node, the machine folder and the supervision label.
For a machine replacement, see Migrating a gateway’s hardware.
What happens on its own
Section titled “What happens on its own”Regenerated, then propagated at deployment, without intervention.
| Taken care of automatically | Why |
|---|---|
| Zone DNS and DHCP | Derived from the declared name |
| Service registry, portal, reverse proxy | Derived from the declared name |
| Supervision targets, deployment tags | Derived from the declared name |
| sops secrets | Linked to the host’s SSH key, not its name |
| Deployment SSH keys | Never pinned to the deployment account |
Procedure
Section titled “Procedure”-
Rename in the configuration
etc/config.yaml - hostname: "srv-maison" # ancien nom : "srv"zone: "maison:1.2"profile: "server" -
Move the machine folder
Fenêtre de terminal git mv usr/machines/srv usr/machines/srv-maison -
Regenerate
Fenêtre de terminal just clean -
Create the backup account
Fenêtre de terminal just passwd-restic -
Validate
Fenêtre de terminal just commit "refactor(maison): rename srv to srv-maison" -
Deploy
The node is addressed by its name, which must resolve from the administration machine. The safest option is to redirect ssh to its address during the first deployment.
Fenêtre de terminal just roaming srv-maison 10.0.1.2just apply srv-maisonjust roaming-clear srv-maisonWithout a redirect, first deploy the gateway of the zone from which you administer : it then publishes the new name in its DNS.
-
Make the new name effective
The deployment writes the static name, but the kernel one only changes at boot :
hostnamestill returns the old name until the machine has rebooted.Fenêtre de terminal just reboot srv-maisonTo avoid the outage, set the name on the fly, then restart the services that read it at startup (the VPN client first).
Fenêtre de terminal sudo hostname srv-maisonsudo systemctl restart tailscaled
Keeping the old name
Section titled “Keeping the old name”The aliases field adds extra DNS names,
useful for devices that keep the old name in a bookmark.
- hostname: "srv-maison" aliases: ["srv"]Gateway case
Section titled “Gateway case”A gateway carries the DNS and binary cache of its zone, hence two ordering rules :
- Deploy the gateway before its clients (their binary cache points to its name).
- Then deploy the gateways of the other zones, which publish the new name.
The VPN node keeps its key, its address and its approved routes. Only the displayed name stays frozen, to fix on the coordination server.
sudo headscale nodes listsudo headscale nodes rename <nouveau-nom> -i <identifiant>After the rename
Section titled “After the rename”- Supervision : the host label changes, the graph history is cut.
- Silences : those carrying the old name must be recreated.
- Backups : if the host backs up, rename its repository on the server, otherwise an empty repository is created.
- Tooling : the old node leaves the hive, any script that references it fails loudly.