The Domain Name System (DNS) is vital for the running of the web. In a nutshell, it converts requested domain names into IP (Internet Protocol) addresses – which is what computers use to find websites, deliver emails, and the many other activities that take place on the web.
Understanding how DNS works and its configuration – whether you’re looking to add a DNS record or edit an existing one – can help you better manage your WordPress site.
Table of contents
- Definition of terms
- What is DNS?
- How DNS works
- DNS records you need to know about
- What does a DNS record look like?
- When to access your DNS records
- How to manage DNS records for a WordPress website
- DNS tools and queries
- Frequently Asked Questions – FAQs
Definition of terms
Throughout this article, we will make reference to certain technical terms and abbreviations, some of which may not be part of everyday parlance. As such, we thought it might be useful to include a short section briefly explaining what these terms mean.
- TLD: Top-Level Domain. Example .com
- URL: Uniform Resource Locator – The full name of a resource, including TCP/IP information. Example www.melapress.com
- FQDN: Fully Qualified Domain Name – The full domain name that includes hostname, domain, and TLD. Example www.melapress.com
- Domain name: Name of the domain example melapress.com
- TCP/IP: Transmission Control Protocol/Internet Protocol. The main protocol (language) used by devices communicating over a network such as the internet.
- Registrar: The company with which you registered your domain name.
- Hosting provider: The company that provides you with hosting for your WordPress website.
What is DNS?
The resources we access on a network, be it the internet or our home/office network, need an address. This address allows us to find those resources. Resources can include email servers, web servers, a network printer, etc.
This address is called an IP address and is defined by the TCP/IP protocol – the main language of the internet. Addresses are made up of four numbers between 0 and 255, with each number separated by a full stop:
Remembering these numbers can be difficult, which is why we typically use a URL. URLs like www.melapress.com and www.google.com are easier to remember than a string of numbers.
Even though we use URLs, computers still need the IP address to find the resource we want to access. This is where DNS comes in. DNS converts the URLs we type into IP addresses by referencing its lookup table. As a WordPress administrator or website owner, you need to ensure that your DNS server is configured properly, to allow visitors and customers to find you.
How DNS works
Before we get into DNS records, it is worth taking some time to look at how DNS works. While DNS can get slightly complicated when you look beneath the surface, in principle, it is very straightforward.
We will illustrate this with an example – visiting www.melapress.com
Step 1: Request the IP address of the domain name
Once you type the URL www.melapress.com into the address bar of your browser, your computer or smartphone sends a request to the DNS server, asking for the IP address of www.melapress.com.
The initial request is sent to the DNS server configured on your device. Typically, this is assigned by your router or ISP and is configured automatically upon connection to the network, assigned by the DHCP.
Geek note: Before sending a request to the DNS server, your computer first checks the hosts file. This text file maps domains with IP addresses, making them hard-coded. This is mostly used for the loopback address, which is 127.0.0.1 however allows any IP to be assigned to any domain.
Step 2: Recursive DNS server requests the Name Servers of the domain
Network and ISP DNS servers are called recursive DNS servers because they do not store domain data. Instead, they forward your query to other DNS servers, who send back the answer (the IP address of the requested website).
The recursive DNS server (the DNS server your device contacted) contacts other DNS servers higher up in the hierarchy (such as root servers) to get the IP address of the Name Servers (NS) for the domain melapress.com. Name Servers (NS) are DNS servers that hold information about domains.
Every domain has one or more Name Servers (NS). Whenever a DNS server needs to resolve the IP address of a domain they are responsible for, a DNS server holding the NS record answers the query. You configure the Name Servers (NS) for a domain when you buy the domain.
Step 3: Recursive DNS Server Requests the Name Servers to Resolve the FQDN
At this stage, the recursive DNS server your device contacted has the list of name servers for the domain you want to browse. So it sends a request to one of the servers to resolve the FQDN www.melapress.com to an IP address. The DNS server checks its A records and answers with the IP. In this case, it is 18.104.22.168.
Step 4: Recursive DNS Server Replies with an IP Address
Now that the recursive DNS server your device contacted has the IP address of the FQDN www.melapress.com, it sends it back to your device.
Step 5: Your Device Connects to the Web Server
Your device connects to the web server on that IP address it received from the recursive DNS server and requests the page on www.melapress.com. The web server responds by sending the data, which your browser starts downloading and rendering.
DNS records you need to know about
There are eight different types of DNS records – each one having its own use. As a WordPress administrator, however, there are five records of particular interest – which we will discuss in some detail down below.
A Record stands for Address Record. It is used to associate a URL (www.melapress.com) with an IP address.
A records are used to tell DNS where a particular website is located. In essence, it directs a URL to the webserver’s IP address. In certain situations, one A record can have multiple IPs assigned to it – such as in the case of load balancing or round-robin setup, for example.
You should have at least one DNS record that lists your domain.
CNAME stands for Canonical Name Record. It is used to create domain aliases, such as when setting sub-domains. An example of this would be using a CNAME record for blog.melapress.com that points to www.melapress.com or creating a subdomain like ftp.melapress.com with the same IP as www.melapress.com
MX stands for Mail Exchange. MX records specify the mail server and are used to route emails. As an example, if you were to send an email to firstname.lastname@example.org, your mail server must query MX records to determine where the email needs to be sent.
One thing to note here is that MX records also have a priority configuration. Lower numbers indicate higher priority. Priority can be used to configure backup mail servers in case the primary mail server goes down.
NS stands for Name Server. NS records specify which DNS server has the authority for a particular domain. This record essentially tells other DNS servers that they have reached the authoritative DNS server for a particular domain.
You should have at least one NS record in your authoritative DNS server for your domain. In most cases, you’ll have multiple records that point to different authoritative DNS servers for redundancy purposes.
TXT stands for text. TXT Records were originally intended as a note-storage space, allowing administrators to save any kind of notes on the DNS server – hopefully related to DNS and not their grocery shopping list.
TXT records are also used by third parties to verify domain ownership. Here, you need to add a specific TXT record to confirm you own the domain, such as when configuring Google Analytics. TXT records are also used by a number of protocols, such as SPF and DKIM, which are email antispam and authentication protocols, respectively.
What does a DNS record look like?
A DNS record must include essential information that allows computers to understand what it is and what it refers to. Understanding what this information is can help you configure your own records.
- Record name: The domain name of the record
- Record type: The type of record (ex., A record)
- TTL (Time To Live): The number of seconds a record is valid for. Once the TTL is reached, the record needs to be refreshed. The refresh is done automatically by the DNS server.
- IP/Host: The IP address or hostname for the record
When to access your DNS records
Managing DNS as a WordPress administrator is not something you need to do every day. In most cases, you’ll need to manage records when:
- Setting up WordPress for the first time/ registering a new domain
- Setting up services such as Google Analytics and Hotjar
- Changing hosting provider
- Getting a CDN service (such as Cloudflare)
How to manage DNS records for a WordPress website
Your DNS records are typically held at;
- Your registrar
- Your hosting provider
- DNS service provider
- Your own DNS servers
– depending on how your environment is configured. This can vary depending on your setup – in most cases, however, the registrar and WordPress hosting provider are one and the same. In such cases, you’ll find everything in one place. Sadly, there are no DNS management plugins available.
In this section, we will cover tutorials for managing DNS on a number of platforms.
CPanel is a backend management system that’s something of a gold standard and is used by many service providers. Anyone who has been a web administrator long enough will surely have crossed paths with this platform. GoDaddy, for example, uses CPanel with some of its hosting plans, as do many others.
In CPanel, DNS records are managed from Domains > Zone Editor. Simply click on Manage next to the domain name you want to create or edit DNS records for.
To add a new record, click the Add Record button. To edit an existing record, click on the Edit button next to the DNS record you want to edit. Remember to click Save Record once done.
Hostinger is a registrar and hosting service provider with data centers around the world. They use hPanel – a custom control panel designed by Hostinger themselves. They offer plenty of documentation on their website should you require it.
To manage DNS records through Hostinger, navigate to Domains, then click the arrow next to the domain you want to manage DNS records for. Next, locate DNS/Nameservers within the sidebar and click.
Depending on how your DNS is set up, you will see different options. If Hostinger is not your registrar, you’ll find available options under External Domains. If your domain was purchased through Hostinger, you’d find a DNS records option instead. DNS records can be managed from here.
GoDaddy is a service provider offering domain registration and hosting, among other things. They offer DNS management through their account page, making it easy to configure.
To manage DNS records with GoDaddy, first click on My Products, go to the Domains tab, and click on Manage All. Click on the ellipses (…) in the Manage column and then click on Manage DNS.
WPEngine is a WordPress hosting provider. You can find DNS settings in the DNS details tab, which you can access by navigating to Domains and then DNS Details from the user portal.
Kinsta is a cloud platform that offers hosting services. DNS is managed through MyKinsta. When setting up DNS for the first time, you’ll need to click on the Add Your First Domain option, which is available in the DNS tab. This will create a DNS zone for you, which also allows you to add additional domains.
DNS tools and queries
A small mistake in the DNS configuration can lead to big problems – people won’t be able to access your website or send you emails. In this section, we will look at how you can use nslookup, dig, and other DNS tools to test your DNS setup.
Nslookup and Dig DNS Tools
Both Nslookup and Dig are command-line tools found on many operating systems. These tools are used to send queries to DNS servers. Nslookup is more popular with Windows users, while Dig is more popular with Mac OS and Linux users. Both use similar queries and commands.
Querying a DNS Server with Dig
The most basic DNS query you can send to a DNS server is to resolve a domain name into an IP address. By default, both Dig and Nslookup query A records, so just type the below in the command line to get the answer:
- Linux/Mac: dig www.melapress.com
- Linux/Windows: nslookup www.melapress.com
Below is a screenshot of the nslookup command and the response from the server:
Here is a breakdown of the response:
- Server: 22.214.171.124 is the IP address of the DNS server we queried and sent a response.
- Address: 126.96.36.199#53 is the IP address and port number of the DNS service.
- Name: www.wpwhitesecurity.com is the domain name we queried.
- Address: 188.8.131.52 is the IP address where the domain www.wpwhitesecurity.com is hosted. This is the record we are looking for.
Authoritative & Non-Authoritative Answers from the DNS Server
Did you notice the text ‘Non-authoritative answer’ in the DNS server response? That means that the server you queried is not the authoritative name server of the domain wpwhitesecurity.com. This means that the answer we received is a cached or forwarded response.
To get a response from the authoritative server, you have to find the name servers (NS records) of the domain and query them directly. We’ll do this in the below example.
Finding the Name Servers of a Domain
The name servers of a domain are the servers that hold the DNS zone of a domain (the main authority for that domain). These are the servers you specify when registering a new domain.
To find the name servers of a domain, use the following command:
dig [domain_name] NS
NS is the type of DNS record we want to know. So to find the NS (name server) records of the domain wpsecurityauditlog.com, the command should be:
dig www.wpsecurityauditlog.com NS
Below is a screenshot in which the request and the important sections from the answer are highlighted:
As part of the response, you can see that we have sent one query (QUERY:1) and got four answers (ANSWER: 4).
This is a list of the four name servers for the domain wpwhitesecurity.com. In this section, you can also see the Time to Live (TTL) value of every record, which is 300.
Technical details of the query, such as how long it took the server to respond, when it was sent, the size of the message, etc.
Querying a Different DNS Server
By default, the Dig or Nslookup tool sends the query to the DNS server configured on your device’s network interface. Typically this is the DNS server of an ISP, a web host, or the network you are connected to. Therefore if you want an authoritative answer about a particular record or FQDN, you have to query the name server directly. To do this, use the following command format:
dig @[server] [domain]
Since we now know the name servers of the domain wpsecurityauditlog.com, we can query one of them directly. In this case, we are querying 184.108.40.206, which is the IP address of the ns1cvw.name.com name server. We want the server to resolve the IP address of the FQDN www.wpwhitesecurity.com. The command is:
dig @220.127.116.11 www.wpwhitesecurity.com
Here is the response from the server:
This is the answer from the server. The FQDN wpwhitesecurity.com resolves to the IP address 18.104.22.168.
Using DNS Tools to Find a Domain’s Mail Servers
When you send an email to email@example.com, your mail server sends DNS requests to find the IP address of the wpsecurityauditlog.com domain mail servers. Mail server records on DNS are MX records, also known as Mail Exchanger records. To find the MX records of a domain, use the following command format:
dig [domain] [MX]
Below is the response from the DNS server for the dig wpwhitesecurity.com MX command:
The DNS server’s answer.
From the answer, we can see that the domain wpwhitesecurity.com has three mail servers. The number in front of every mail server record is the server’s priority. The lower the number is, the higher the priority. This means that when you send an email to this domain, first, your mail servers try to connect to aspmx.l.google.com because it has a priority of 10. If, for some reason, it is unavailable, then the servers try to connect to the next server, in this case, the server with a priority of 20.
Other Uses for DNS Tools
The Dig and Nslookup DNS tools can be used to query any DNS server for any type of record. For example, you can use these tools to retrieve the TXT records of a domain, which are typically used by SPF and other frameworks. Dig also has an any switch. When used, it downloads all the records for a particular domain.
Geek note: If you want to learn more about DNS and the different types of records, try getting the records for google.com or wikipedia.org.
Checking DNS Propagation
To minimize traffic and requests between servers, DNS servers cache DNS records for the time specified in the Time to Live (TTL) value. TTL is specified in seconds for every DNS record and works like an expiration date.
The higher the TTL value of a DNS record, the longer it will take for a change to propagate, because the DNS servers cache the record for much longer. On the other hand, a low TTL value means that a DNS record change will be propagated very quickly. However, a low TTL value also means an increase in the number of DNS resolution requests.
You should set a high TTL value for DNS records, like 86,400 seconds (24 hours). Only use lower values, something like 3,600 seconds (1 hour), when you are planning a DNS record change. As long as you lower the TTL a few days or weeks before the change, the change should be propagated in a respectable time.
You can use the free online tool What’s My DNS to check if a DNS record change has been propagated. To run a test, simply type in the record and configure the expected results by clicking on the cogwheel.
Frequently Asked Questions – FAQs
DNS is not set in WordPress but through your nameserver provider, which is usually your registrar or hosting provider. Since providers often have proprietary backends, there is no one procedure that is the same for everyone.
In our article, we looked at some well-known service providers and provided general instructions on how to manage DNS with them. Most providers offer DNS setup documentation, so be sure to check your provider’s website for more information.
To point DNS to your WordPress, you will need to set up an A record with your hosting provider. This lets DNS servers know where to find your website.
Check your hosting provider’s documentation for more information on how to do this since the procedure can vary from one provider to another.
A subdomain is a child object of the domain. Using WP White Security as an example, blog.wpwhitesecurity.com is a subdomain of wpwhitesecurity.com. A subdirectory, on the other hand, is simply a subdirectory of the domain, which using the above example, would look like wpwhitesecurity.com/blog