• Where to specify a domain name?

    From Daniel James@2:250/1 to All on Sunday, February 08, 2026 17:01:55
    I want to put some local machines with fixed IP addresses into /etc/hosts.

    This is on a Raspberry Pi running Raspbian (Debian) Trixie.

    In the default /etc/hosts I find a message suggesting that I should make
    my changes in /etc/cloud/templates/hosts.debian.tmpl instead, or to
    disable the management of /etc/hosts by cloud-config.

    Now, I'm not doing anything that requires cloud-config, so disabling it
    would be fine -- but it seems a little drastic -- so bear with me.

    In /etc/cloud/templates/hosts.debian.templ there is a line that reads

    127.0.0.1 {{fqdn}} {{hostname}}

    The idea is that {{fqdn}} will get replaced by myhostname.mydomain and {{hostname}} will be replaced by myhostname (from /etc/hostname, I guess).

    The trouble is, at boot time when /etc/hosts is generated from this
    template the system doesn't know my domain name, so the resultin line in /etc/hosts reads:

    127.0.0.1 myhostname myhostname

    which is not what I want to see!

    The suggestion I get from extensive searching online is that the domain
    name should come from /etc/resolv.conf ... but when I look into /etc/resolv.conf I see

    # Generated by NetworkManager

    which is a fair warning that NetworkManager may rewrite that file
    without warning, and without preserving any changes I may have made.

    More extensive reading with $SEARCH_ENGINE leads me to understand that NetworkManager gets the domain name that it uses from .... (you guessed
    it) /etc/hosts

    The whole thing runs round in circles ...

    There is some suggestion that one can put a FQDN instead of a simple
    server name into /etc/hostname, but this suggestion is roundly condemned
    by almost everyone.

    So ... how do I tell cloud-config (or whatever it is that is rewriting
    my /etc/hosts at every boot) what my domain name is?

    As I said: This is not a dynamically-generated VM or a cloud server
    instance, it's a Raspberry Pi sitting on my desk. It's configuration
    isn't going to change with the direction of the wind. It's not the sort
    of installation for which cloud-config was conceived, and I'm slightly surprised that package is part of the installation (it isn't on my x64
    desktop machine running Debian Trixie). For my own purposes disabling
    the update of /etc/hosts or hard-coding the domain in the template will suffice ... but what's the *right* answer.


    --
    Cheers,
    Daniel.


    --- MBSE BBS v1.1.7 (Linux-x86_64)
    * Origin: Daniel James (2:250/1@fidonet)
  • From Richard Kettlewell@2:250/1 to All on Sunday, February 08, 2026 17:47:04
    Daniel James <daniel@me.invalid> writes:
    I want to put some local machines with fixed IP addresses into /etc/hosts.
    [...]
    As I said: This is not a dynamically-generated VM or a cloud server
    instance, it's a Raspberry Pi sitting on my desk. It's configuration
    isn't going to change with the direction of the wind. It's not the
    sort of installation for which cloud-config was conceived, and I'm
    slightly surprised that package is part of the installation (it isn't
    on my x64 desktop machine running Debian Trixie). For my own purposes disabling the update of /etc/hosts or hard-coding the domain in the
    template will suffice ... but what's the *right* answer.

    AFAICT the right answer in your use case is to remove cloud-init.

    --
    https://www.greenend.org.uk/rjk/

    --- MBSE BBS v1.1.7 (Linux-x86_64)
    * Origin: terraraq NNTP server (2:250/1@fidonet)
  • From Daniel James@2:250/1 to All on Wednesday, February 11, 2026 18:43:05
    On 08/02/2026 17:47, Richard Kettlewell wrote:
    AFAICT the right answer in your use case is to remove cloud-init.

    Yes, that would seem about right. I'm not quite sure what /else/ might
    be removed if I apt remove it, but I'm sure I'll find out.

    Thanks.

    --
    Cheers,
    Daniel.

    --- MBSE BBS v1.1.7 (Linux-x86_64)
    * Origin: Daniel James (2:250/1@fidonet)