hehe, so … if you ever change the hostname of a Linux machine, you really really ought to double-check /etc/hosts to make the same hostname change there

it’s surprising just how much will break if a machine’s own hostname isn’t resolvable to a 127.x.x.x address :P

  • alastel@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    5 days ago

    If you have myhostname set for hosts in /etc/nsswitch.conf it shall take care of this for you (should be the default on most systemd distros I believe? not sure)

    • jokeyrhyme@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 days ago

      i’m guessing a few things somehow consume /etc/hosts mappings without going through nss /shrug

  • monovergent@lemmy.ml
    link
    fedilink
    arrow-up
    4
    ·
    5 days ago

    Lost my mind a few years ago over this quirk. Now I always change both files when I want to change the hostname.

    • jokeyrhyme@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      4 days ago

      seems like a pretty common practice across Linux distributions

      /etc/hostname for the actual hostname, and a mapping in /etc/hosts pointing it at a 127.x.x.x address

    • itmosi@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      ·
      3 days ago

      Never, there’s no need for it. I can reach it with localhost or 127.0.0.1, so why would I even put it in?

  • otacon239@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    5 days ago

    Interesting. I’ve changed my hostname on a few machines throughout the past and never ran into this. Good to know if I ever run into this in the future.

    • jokeyrhyme@lemmy.mlOP
      link
      fedilink
      English
      arrow-up
      4
      ·
      4 days ago

      it modifies /etc/hostname for you, but doesn’t seem to touch /etc/hosts

      i still prefer hostnamectl, but i’m now unsure of what benefit it offers over editing /etc/hostname directly

  • limelight79@lemmy.world
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    4 days ago

    This reminds me… My server demands to be known as hostname.local on my network. The other machines just respond to just hostname. I really should figure out why that is.

      • limelight79@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        2 days ago

        I use DHCP for everything, even my server, with a reserved IP address in the router for the server and my desktop and a few other things I don’t want to move around (printers, some IoT things, Home Assistant, etc.).

        I think the issue is the bridge interface I have to set up for Home Assistant.

  • Hawke@lemmy.world
    link
    fedilink
    arrow-up
    4
    arrow-down
    2
    ·
    edit-2
    3 days ago

    It’s always been wild to me how the seemingly-simplest change (“what is the name of this computer”) has so many little gotchas and quirks.