less than 1 minute read

How to have Fedora-cloud use the DHCP-provided hostname


Testing Fedora cloud image on KVM while using NoCloud cloud-init. I like to have my “trusted” home devices (and virts) publish their hostname via their DHCP client request towards my router.

My router has a script that generates static DNS entries based on the hostname value of a client’s DHCP request.


I’ve noticed that a few “cloud” images that I’ve been trying out don’t usually propagate the “hostname” value from the meta-data of NoCloud to the DHCP settings.

So far, Alpine which uses dhclient via openRC and Fedora-cloud which uses systemd + NetworkManager for its DHCP client.

I guess this is the standard. More stealthy this way, but I don’t need this stealth.

Solution (Fedora-Cloud)

Notice the runcmd. This is the current naming scheme for Fedora-cloud in 2024/01


  - sudo

  - name: myuser
    primary_group: myuser
      - ssh-rsa YOUR_PUBKEY comment
    sudo: "ALL=(ALL) NOPASSWD:ALL"
    groups: wheel
    shell: /bin/bash

  - 'nmcli con modify "cloud-init eth0" ipv4.dhcp-hostname myhostname'