Comment 2 for bug 1905932

Revision history for this message
eoli3n (eoli3neoli3n) wrote :

As workaround, use a early command to set hostname from DNS.

1. Extract first default interface from "ip route"
2. Get ipv4 of that interface
3. Extract "host $ip" short hostname
4. Write it to /etc/hostname

Which gives

  early-commands:
    # Get hostname from DNS
    - host $(ip a show dev $(ip route | awk '/default/ {print $5; exit; }') | awk '/inet / {s=$2; sub(/\/.*/,"",s); print s}') | awk '{ s=$NF; sub(/\..*/,"",s); print s }' > /etc/hostname