How should I configure my Hostname and FQDN?
Hello, I was going over my server's environment and configuration and something jumped out at me: I think I don't understand the point of the FQDN?
I went back and checked one of the first 'getting started' guides. They recommend editing /etc/hosts and adding lines where we set the localhost IP to localhost, and our public IP to our set hostname and FQDN. Which is simply defined as the hostname joined with a domain. I set mine to my
Next it recommends adding an A and AAAA record of your FQDN to your DNS settings. This now to me looks like I've just made a subdomain? If I now visit my FQDN, i do indeed visit my main, root website. Except I hit a
NET::ERR_CERT_COMMON_NAME_INVALID, which makes sense to me since my Let'sEncrypt setup has no idea about my hostname/subdomain.
Am I missing something here? I don't want my hostname to resolve as a subdomain on my server. Can someone tell me what I'm missing about the point of this configuration?
So, make your A/AAAA records NOT have the hostname part…the DNS name for your Linode is foo.com … not host.foo.com.
DNS records are not immutable once set…you can change them. It’s far easier to take your time & make mistakes with them at the beginning when other services (like LetsEncrypt) aren’t heavily dependent on some mistake you made 5 years ago.
I’m by no means a DNS expert. The Linode support folks can help you a lot with this. They helped me. Just ask them…
Well, sure I can remove it. I just wanted to know why this would be recommended? What is the real purpose of a FQDN then? Do system tools need it for some purpose?
Hey @zacharykane — I'm seeing several questions asked, so I'm going to break them down and tackle them one-by-one.
What is FQDN for?
The Fully Qualified Domain Name (FQDN) is the absolute domain name, including subdomains, top-level domain, and root zone, that will direct queries under the Domain Name System (DNS) to an exact location—in this context, to your Linode. Here's an example visual breakdown of the components of a FQDN:
Root: empty string or . Root zone: com Top-lvl domain: testyboi Subdomain: www ================================= FQDN: www.testyboi.com
If you're looking for a deeper understanding of the DNS and how FQDN applies to it, I recommend reviewing our guide on the
dig command: Use dig to Perform Manual DNS Queries
How does FQDN configured in DNS Manager differ from FQDN configured in the /etc/hosts file?
I've seen a lot of confusion regarding FQDN and hostname (I address this a bit more here, and @tbaka provides a great breakdown here), as they're often conflated in guidance you'll see on the internet when looking for answers.
The short answer is that the FQDN in the DNS sense is important when external sources are trying to reach your Linode, while the FQDN in the /etc/hosts file sense is important for your local system's resolution of domains. Meanwhile, the hostname is simply the name you call your system, used mostly to help you identify and distinguish your systems. Here are some examples to clarify the difference:
Use DNS Manager so the internet can reach your Linode at its FQDN
Say you own the top-level domain "testyboi.com" and want to make sure that people trying to reach "www.testyboi.com" (aka, the FQDN) arrive at your Linode. To accomplish this, following the instructions in our DNS Manager guide, you'd do the following:
- From your domain registrar control panel, set "testyboi.com" to point to Linode's name servers
- Use DNS Manager to create a zone for "testyboi.com"
- Create an A/AAAA record for the "www" subdomain (which is confusingly referred to as "Hostname" in DNS Manager) in the "testyboi.com" zone to point to your Linode's public IP address
After these changes have been made and have fully propagated, the DNS will point external queries directed at "www.testyboi.com" to your Linode's public IP address.
Use /etc/hosts so your local system can reach your Linode at its FQDN
Now, say you want queries for "www.testyboi.com" to resolve to your Linode only from within your local system, and not through the DNS system. For these examples, assume your Linode's public IPv4 address is 203.0.113.10. Here, you could accomplish this by simply adding the following line to your /etc/hosts file:
Now, even if you haven't set up "www.testyboi.com" from your domain registrar/DNS Manager, your local system will direct queries for "www.testyboi.com" to 203.0.113.10 like so:
$ ping www.testyboi.com PING www.testyboi.com (203.0.113.10) 56(84) bytes of data. 64 bytes from www.testyboi.com (203.0.113.10): icmp_seq=1 ttl=63 time=0.713 ms 64 bytes from www.testyboi.com (203.0.113.10): icmp_seq=2 ttl=63 time=0.715 ms 64 bytes from www.testyboi.com (203.0.113.10): icmp_seq=3 ttl=63 time=0.710 ms
While I replaced the IP addresses, the above output actually came from one of my Linodes even though I don't own "www.testyboi.com".
Use /etc/hosts so your local system can reach your Linode at its hostname
Further, I could add anything else to that line in my /etc/hosts file, such as my system's hostname, which I've humbly set to "benrulez". I'll now update the line in /etc/hosts like so:
203.0.113.10 www.testyboi.com benrulez
And you can see the result:
$ ping benrulez PING www.testyboi.com (203.0.113.10) 56(84) bytes of data. 64 bytes from www.testyboi.com (203.0.113.10): icmp_seq=1 ttl=63 time=0.961 ms 64 bytes from www.testyboi.com (203.0.113.10): icmp_seq=2 ttl=63 time=0.837 ms 64 bytes from www.testyboi.com (203.0.113.10): icmp_seq=3 ttl=63 time=0.924 ms
Pretty cool—you can see that "benrulez" is now treated as an alias for "www.testyboi.com". For more on the /etc/hosts file, run
man hosts on your system.
Do system tools need FQDN?
Well, this really depends on the tools themselves, and what you're trying to accomplish with them. The things to keep in mind are:
- Do you want the internet at large to access a FQDN? If so, configure your domain registrar and DNS records accordingly.
- Do you want your local system tools to reach a FQDN without having to rely on DNS? If so, configure your /etc/hosts file as above—your system will rely on this file to resolve any specified FQDNs.
As you can see, FQDN and hostnames can be a bit tricky, but I hope this breakdown helps you understand them. Feel free to follow up with any other questions!
edit: added more on hostnames