Hi,
I’m trying to set my FQDN so that when I do hostname -f, it gives me my FQDN (like mx.example.com) instead of my hostname which I used to create my Droplet.
I would appreciate any help.
Thanks.
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!
Accepted Answer
Hello, @amirehmarwan
I believe that there are 3 things that you need to do:
1 Use the following command:
sudo hostnamectl set-hostname hostname
2 Update your hostname in your hosts file:
vim /etc/hosts
3 Find the references to the old FQDN and update them to the new one.
Update the 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, Alex
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.