iqbal
By:
iqbal

I cannot change hostname on FreeBSD

September 5, 2015 1.6k views
DigitalOcean Miscellaneous FreeBSD

Hello Dear Community

I'm not able to change the hostname on my FreeBSD droplet from the one I was to create it.

I added this line hostname="new.host.name" to my /etc/rc.conf, rebooted many time
but my droplet still keeps my original hostname I've chosen when creating it.

Is It a DigitalOcean issue ?

Regards

3 comments
  • I found the solution.

    This file /etc/rc.digitalocean.d/droplet.conf must be edited because it overwrites the hostname="new.host.name" entry in /etc/rc.conf

    Regards

  • Although this will work, is this really the correct way to do it? Considering that load_rc_config() in rc.subr in fact will try /etc/rc.digitalocean.d/ before trying /etc/rc.conf, I'm under the impression the intended behavior was to override hostname in /etc/rc.conf.

    Feel free to correct me; I only took a quick glance at the rc scripts.

  • The problem appears to be in the /etc/rc.d/hostname script

    ...
    elif [ -n "`/bin/hostname -s`" ]; then
            return
    ...
    

    if the hostname is already set, then it aborts, so no overriding. Solution maybe to edit the hostname name from all the rc.digitalocean.d/*.conf -- so that the default action happens as expected, although I am currently unsure as to whether these configuration files will be overridden at a later date by DO automation?

1 Answer

This question was answered by @matthewa:

The problem appears to be in the /etc/rc.d/hostname script

...
elif [ -n "`/bin/hostname -s`" ]; then
      return
...

if the hostname is already set, then it aborts, so no overriding. Solution maybe to edit the hostname name from all the rc.digitalocean.d/*.conf -- so that the default action happens as expected, although I am currently unsure as to whether these configuration files will be overridden at a later date by DO automation?

View the original comment

Have another answer? Share your knowledge.