By johnbo
Hi,
I created a new droplet today. Named it ‘fred’. If I query the hostname, it returns ‘fred’. If I ask for the FQDN via hostname --fqdn, I get ‘fred’.
My DNS (external provider) is pointing at ‘fred.example.org’.
Reading various articles here, I’ve tried changing the name of the droplet via the control panel (no change after a reboot), using the hostname command (lasts until the next reboot), using the hostnamectl command, which seems to change the hostname and the FQDN to ‘fred.example.org’.
Normally, I’d change the hostname file and the resolv.conf file. But, both files have comments that they should be changed elsewhere in part of the cloud init system. Which seems to be tied into systemd.
This will be a mail server, eventually, and its really important to get the names set up properly.
I keep looking for a tutorial that would address this with the specifics of the Digital Ocean setup, but I’m not finding it.
What am I missing?
Thanks,
johnbo
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
I believe that there are 3 things that you need to do:
hostnamectl command:sudo hostnamectl set-hostname fred.example.org
hosts file:vim /etc/hosts
Find the references to the old FQDN and update them to the new one.
cloud.cfg file. Edit the following file:vim /etc/cloud/cloud.cfg
Find the reference for preserve_hostname and change it from false to true.
That is pretty much it, you can try to reboot your server and then test the change by running only the hostnamectl command.
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.