Re: Persisting a one-off hostname change



Jason Heeris wrote:
Bob Proulx wrote:
You could still set the hostname randomly. Then later come back and
write the current hostname to the /etc/hostname file when it is
writable.

Later in the rcS sequence, or in rc[2-5]?

I would do it later in runlevel 2 (same as 2-5). Even at the very end
would be fine. You could use "Required-Start: $all" if you like. It
just needs to happen once and at the very end of the boot should be
fine. Then the filesystem is mounted read-write and the file can be
updated with the current hostname. Should work fine.

Alternatively instead of a random name have you considered using the
name it gets from reverse dns lookup of the ip address? Still
wondering about the whole random hostname thing. But feel free to
ignore my questions here. If you know that is what you want then that
is fine with me.

Be sure to understand The Birthday Paradox if you go down the path of
random hostnames. It surprises people who are not aware of it.

If you are generating random hostnames then does it actually matter
what name the current host uses? Would "localhost" be as good as any
randomly generated one?

The randomness is needed to avoid name collisions when multiple
devices are running. They offer SSH/SFTP and Samba services over the
network, and need to be available by hostname rather than IP address
(via Avahi and whatever Samba uses, NetBIOS I think).

Of course I am sitting here thinking that other hosts use dns to look
up the name and to get an ip address. That is independent of the
hostname that actually exists on the host at that address. And so the
hostname is rather irrelevant.

But I see now you mentioning avahi and netbios and some other scruffy
protocols that I have never taken the time to understand. So I will
stop while I am behind. :-)

Bob

Attachment: signature.asc
Description: Digital signature



Relevant Pages

  • Re: domain name
    ... I never had a problem with the hostname. ... troubles when the host is a server on the 'Net with a static IP and ... Seems to me it should return "localhost" in that case, ... configuration internally consistent with a private configuration in ...
    (Debian-User)
  • Re: hostnames and interfaces
    ... Apache documentation on doing virtual hosts and maybe do some ... A fully Qualified Host Name consists of two main parts. ... During installation, when it asks for hostname, it wants a Fully ... service what DNS server will be providing DNS service for that domain. ...
    (freebsd-questions)
  • Re: /bin/hostname
    ... Find a real news server. ... in /etc/hosts that maps the host and the FQDN to the static IP ... Linux distributions are supposed to follow Linux Standard Base standards, ... hostname -- show or set the system's host name ...
    (comp.os.linux.networking)
  • Re: Renaming machine and /etc/hosts
    ... Note that "localhost" is as has been described, ... machine's actual hostname - so this machine can /only/ find itself as ... qualified hostname for the loopback IP numbers. ... Ethernet and send traffic to it from this host it will be looped too. ...
    (comp.os.linux.misc)
  • RE: apache not starting: FreeBSd 5.4
    ... Assigning a Host name to your FBSD system. ... statement hostname= to /etc/rc.conf. ... registered domain name on the public Internet (unless of course it's ...
    (freebsd-questions)