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.

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.

×
1 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

Submit an Answer