Report this

What is the reason for this report?

How do I set an FQDN?

Posted on April 2, 2020

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!

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.
0

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

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.