Question
I cannot change hostname on 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
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
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()
inrc.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
scriptif 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?This problem persists. It seems like it’s coming from cloud-init. If you set
cloudinit_enable="NO"
in /etc/rc.conf after you change the hostname, it will do the trick.Also if you:
You’ll notice the meta-data contains the old hostname. Perhaps cloud-init is picking this up and wiping out rc.conf. This is all speculation at this point, but the above hack is working. Cloud-init only facilitates the early initialization of a droplet. Disabling it won’t hurt anything unless you need it of course.
On a fresh droplet, changing the hostname in the control panel does the trick, but when you launch a droplet from a snapshot it does nothing as the meta-data from the snapshot persists. In this case, disabling cloudinit in /etc/rc.conf with:
$ sudo sysrc cloudinit_enable="NO"
seems to be the only solution.