Why Is the Order of DNS Setup Important?
When you buy a new domain and want to get your website running on a host or virtual server, the first thing you need to master is DNS setup. Many beginners think it's enough to upload the website files and that's it; but until the DNS records are correctly configured, neither the website will open nor will email work.
The key point is that the order in which you perform tasks in DNS setup directly affects the launch time. If you configure email records first and then move on to web records, you might spend hours confused and think the problem is with the host. In this article, we'll tell you exactly which record to add first, which one second, and why this order matters.
Getting to Know the Main DNS Records
Before anything else, you need to become familiar with the four main types of records you'll need in almost every DNS setup:
- A Record (Address): Connects the domain to an IPv4 address. For example, it connects
example.comto185.10.10.10. - AAAA Record: Similar to A but for IPv6 addresses. If your server has IPv6, this is definitely necessary.
- CNAME Record (Canonical Name): Points a subdomain to another domain. For example, it points
wwwtoexample.com. - MX Record (Mail Exchange): Specifies which email server should receive the domain's emails.
- TXT Record: Used for domain ownership verification, SPF, and DKIM. This record is critical for email deliverability.
In addition to these, there's also the NS (Name Server) record, which is usually managed by the domain registrar and doesn't need manual changes, unless you want to transfer DNS to another server.
Step One: Setting Up Web Records (A and CNAME)
The first thing you need to do is connect the domain to the web server. This is done with an A record. Let's say your server IP address is 185.10.10.10 and your domain is example.com:
example.com. 3600 IN A 185.10.10.10
www.example.com. 3600 IN CNAME example.com.
In your host's DNS management panel, you usually have a simple form where you just need to enter the Host and the Value. For the A record, set the Host to @ or leave it empty (depending on the panel) and set the Value to the server IP. For the CNAME record, enter www as the Host and example.com as the Value.
Why Set Up the A Record First?
Because without an A record, nothing else makes sense. Even if you configure the MX records, you can't test the website until the domain is connected to the web server. By setting up the A record first, you can immediately open the site with the IP address or domain and make sure the files are uploaded correctly.
Common Mistake: Forgetting the www Record
Many users only set up the A record for the main domain and forget the www record. The result is that example.com opens, but www.example.com gives a DNS error. Make sure to add both. If you want users to always be redirected to one version, you can set up a 301 redirect on the web server later.
Step Two: Setting Up Email Records (MX and TXT)
After the website is up, it's time for email. If you want to use your host's email service, you usually get the email server address from the hosting panel. For example:
example.com. 3600 IN MX 10 mail.example.com.
example.com. 3600 IN TXT "v=spf1 a mx ip4:185.10.10.10 ~all"
The number 10 in the MX record is the priority. If you have multiple email servers, the lower number has higher priority. The TXT record with the SPF value tells receiving servers that only the specified servers are authorized to send emails on behalf of your domain.
Don't Forget DKIM and DMARC Records
Many hosts today automatically generate the DKIM record. This record is a long value that needs to be added as a TXT record. Also, add the DMARC record, which looks like this:
_dmarc.example.com. 3600 IN TXT "v=DMARC1; p=quarantine; rua=mailto:admin@example.com"
This record tells destination servers what to do if an email fails SPF or DKIM. Without DMARC, your emails are more likely to end up in the spam folder.
Common Mistake: Setting Up MX Before A
If you set up MX first and then A, in the gap between the two, emails sent to your domain might reach the email server, but the server's responses (like error messages) can't come back because the domain isn't connected to the web server yet. This causes delays in diagnosing the problem. Always do web first, then email.
Step Three: Checking and Testing DNS Settings
After adding all the records, you need to wait for the DNS to propagate across the internet. This process is called DNS Propagation and usually takes between 1 to 48 hours, although in many cases it completes after a few hours.
To test whether the records are correctly configured, use command-line tools:
dig example.com A
dig example.com MX
dig example.com TXT
dig www.example.com CNAME
If the output of each command includes the expected address or value, your settings are correct. If the output is empty or you get an NXDOMAIN error, the record hasn't propagated yet or was entered incorrectly.
Online Tools for Testing DNS
In addition to the command line, you can use online tools like dnschecker.org. These tools check from multiple locations worldwide and show which servers each record has propagated to. This helps you understand whether the problem is with your settings or DNS propagation.
Step Four: Setting Up Subdomains
After the main domain and email are up and running, you'll likely need subdomains like blog, shop, or panel. For each one, add an A or CNAME record:
blog.example.com. 3600 IN A 185.10.10.20
shop.example.com. 3600 IN CNAME example.com
If the subdomain points to a different server, use an A record with that server's IP. If it points to the same main domain, CNAME is a better option because if the IP changes, you only need to change it in one place.
Common Mistake: Using CNAME for the Main Domain
According to DNS standards, you cannot define a CNAME record for the main domain (like example.com). CNAME is only valid for subdomains. For the main domain, you should always use an A record. If you do this, your MX and TXT records might be ignored, and your domain's email will stop working.
Final Tips for Hassle-Free DNS Setup
Here are a few tips we've gathered over years of supporting users:
- Always take a screenshot of your current settings before making any changes. If something goes wrong, you can revert.
- During changes, lower the TTL value (e.g., to 300 seconds) so propagation happens faster. After you're done, set it back to 3600.
- If you use a specific DNS provider, read their documentation. Some panels require the record name with a trailing dot, and some without.
- For important emails, make sure to set up SPF, DKIM, and DMARC records together. SPF alone isn't enough.
If you're a beginner and don't want to risk making mistakes in this process, you can use managed DNS services. Companies like ServerNet provide DNS management tools alongside their hosting services, which makes the whole process much simpler.
Summary
Setting up DNS for a beginner website isn't difficult if you follow the correct order. Here's a summary of the correct sequence:
- A record for the main domain and CNAME record for www
- MX record for email
- TXT records including SPF, DKIM, and DMARC
- Required subdomains
- Final testing with dig or online tools
By following this order, your website and email will go live simultaneously and without confusion. If you run into a problem at any stage, first recheck your settings, then wait for DNS propagation, and finally use testing tools. In most cases, the issue is a small typo or a forgotten record.
Comments 0
No comments yet — be the first!