Skip to content

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.

Regenerated, then propagated at deployment, without intervention.

Taken care of automaticallyWhy
Zone DNS and DHCPDerived from the declared name
Service registry, portal, reverse proxyDerived from the declared name
Supervision targets, deployment tagsDerived from the declared name
sops secretsLinked to the host’s SSH key, not its name
Deployment SSH keysNever pinned to the deployment account
  1. Rename in the configuration

    etc/config.yaml
    - hostname: "srv-maison" # ancien nom : "srv"
    zone: "maison:1.2"
    profile: "server"
  2. Move the machine folder

    Fenêtre de terminal
    git mv usr/machines/srv usr/machines/srv-maison
  3. Regenerate

    Fenêtre de terminal
    just clean
  4. Create the backup account

    Fenêtre de terminal
    just configure-admin-host
  5. Validate

    Fenêtre de terminal
    just commit "refactor(maison): rename srv to srv-maison"
  6. Deploy

    The node is addressed by its name, which must resolve from the administration machine. The safest is to redirect ssh to its address for the first deployment.

    Fenêtre de terminal
    just roaming srv-maison 10.0.1.2
    just apply srv-maison
    just roaming-clear srv-maison

    Without redirection, first deploy the gateway of the zone you administer from: it then publishes the new name in its DNS.

  7. Make the new name effective

    The deployment writes the static name, but the kernel one only changes at boot: hostname still returns the old name until the machine has rebooted.

    Fenêtre de terminal
    just reboot srv-maison

    To avoid the interruption, set the name on the fly, then restart the services that read it at their start (the VPN client first).

    Fenêtre de terminal
    sudo hostname srv-maison
    sudo systemctl restart tailscaled

The aliases field adds extra DNS names, useful for devices that keep the old name in a bookmark.

etc/config.yaml
- hostname: "srv-maison"
aliases: ["srv"]

A gateway carries the DNS and the binary cache of its zone, hence two ordering rules:

  • Deploy the gateway before its clients (their binary cache targets its name).
  • Then deploy the gateways of the other zones, which publish the new name.

The VPN node keeps its key, address and routes. Only its name remains the old one: just tailnet-enroll renames it based on the configuration.

Fenêtre de terminal
just tailnet-enroll <nouveau-nom>
  • 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.