How to properly set "hostname", "hosts" file and add "A/AAAA record"?

I'm a little confused with the Linode's Official Guide and have difficulties in properly setting up. If you see any improper setting, please let me know.

Let's say my website is www.goodjob.com and my linode is running debian 10. And my user name is nick.

I set the hostname with this command.

hostnamectl set-hostname gj

And my terminal become to look like this.

nick@gj $ cat /etc/hostname
gj

In the Linode's Getting Started Guide, I have to edit the file /etc/hosts as follows,

127.0.0.1 localhost.localdomain localhost
203.0.113.10 example-hostname.example.com example-hostname
2600:3c01::a123:b456:c789:d012 example-hostname.example.com example-hostname

So, I edited this file as follows (except ip address). Do I need to edit the first line? Why?

127.0.0.1 localhost.localdomain localhost
203.0.113.10 gj.goodjob.com gj
2600:3c01::a123:b456:c789:d012 gj.goodjob.com gj

I bought my domain from namecheap and added ns1.linode.com … ns5.linode.com as Custom DNS. Then I Add A/AAAA Record from the Linode's Domains menu. This one is for ipv4.

Create A/AAAA Record
Hostname = www
IP Address = 203.0.113.10
TTL = Default

This one is for ipv6.

Create A/AAAA Record
Hostname = www
IP Address = 2600:3c01::a123:b456:c789:d012
TTL = Default

The problem is that if I do setup as above, my site do not work without www (see below). If I setup without www (i.e. leave a blank in Hostname), my site do not work with www.

nick@gj $ ping goodjob.com
ping: goodjob.com: Name or service not known

Please help.

3 Replies

Hey Nick,

It looks like you've done a great job so far! To answer your questions directly:

So, I edited this file as follows (except ip address). Do I need to edit the first line? Why?

When you are modifying /etc/hosts, you are basically setting aliases for specific IPs. 127.0.0.1, which is the first line, is for a localhost loopback address. You don't need to edit the first line as your hostname was already set earlier and also within this /etc/hosts file, so I'd leave this address for any programs or scripts that might try to use the alias localhost.

The problem is that if I do setup as above, my site do not work without www (see below). If I setup without www (i.e. leave a blank in Hostname), my site do not work with www.

This makes sense, since you only set one A/AAAA and you pointed it towards www. If you'd like for the address to resolve correctly without needing www, simply make another A/AAAA record that has the hostname blank, like so:

Create A/AAAA Record
Hostname = 
IP Address = 203.0.113.10
TTL = Default

Create A/AAAA Record
Hostname = 
IP Address = 2600:3c01::a123:b456:c789:d012
TTL = Default

-Sam

I have a multi site installation on one linode with apache, php and mariadb. I've deployed the wordpress sites successfully and added conf files for each to apache. I also disabled the default conf file for Apache. I added two aaaa records for each domain. One uses the ipv4 ip address of the linode. The other the ipv6 address of the linode. I left the hostname empty for each. I am not seeing the website when I visit either domain. Could it be my domain registrar lagging on the update of the DNS name servers? Or is there something else that I've missed?

We have a few guides that can help with troubleshooting issues with domains:

You can start by using the dig command to see if the records are showing up. Here are a few examples using google.com:

# IPv4
dig +short google.com
142.250.80.110

# IPv6
dig AAAA +short google.com
2607:f8b0:4006:80d::200e

# NS 
dig NS +short google.com
ns3.google.com.
ns2.google.com.
ns1.google.com.
ns4.google.com.

If any of those don't return a result, I'd recommend going back to the domains section of Cloud Manager to double check that each domain's record is correct and includes all of the records you mentioned. You mentioned leaving the host blank, which is the most common issue I've seen, but you can also just make sure that it saved properly and there are no misspellings.

If the records look right with dig you can also check to see if they have propagated everywhere with DNSChecker. It's possible that some regions aren't updated yet.

Finally, if the records are correct and propagating, you can first check to see if the issue is possible caching on your computer by visiting the site in a different browser or private window. If that works, you can clear your cache to be able to visit the site from your preferred browser. If that's not the issue, the next step is looking through our guide to Running Multiple WordPress Sites on a Single Linode to see if there are any steps you missed or any issues with your configuration.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct