Question

How to set FQDN in Ubuntu

  • Posted on June 1, 2013
  • jr5689Asked by jr5689

Hi all,

I want to set my FQDN in the format myhostname.mydomain.com

I thought I only had to edit /etc/hosts:

$ cat /etc/hosts

127.0.0.1 localhost apple

The following lines are desirable for IPv6 capable hosts

::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters $

I added just this line:

12.345.6.78 apple.example.com apple

and then $ reboot

and in Domains added an A record for apple.example.com

but it does not seem to have any effect - I still get:

$ hostname --fqdn localhost $

Any ideas please what I am doing wrong?

Thanks…


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Got it. Providing details for others. <br> <br>I set hostname in web-interface as do.rtcamp.com for new droplet. <br> <br>It added line in /etc/hosts file as: <br> <br>127.0.0.1 localhost do.rtcamp.com do <br> <br>I changed it to <br>127.0.0.1 localhost <br>188.226.169.135 do.rtcamp.com do <br> <br>188.226.169.135 is IP of my new droplet. <br> <br>Now hostname -f work as expected.

Great! :]

@Kamal I am facing same issue but given solution is not working for me. <br> <br># cat /etc/hosts <br>127.0.0.1 localhost do.rtcamp.com do <br> <br># cat /etc/hostname <br>do.rtcamp.com <br> <br># hostname -F /etc/hostname <br> <br># hostname
<br>do.rtcamp.com <br> <br>#hostname --fqdn <br>localhost <br> <br>I am on Ubuntu 12.04 :|