Report this

What is the reason for this report?

DNS Tips and Tricks

Updated on December 22, 2022
DNS Tips and Tricks

Introduction

In this article, you’ll learn three tricks you can do with DNS. If you’ve ever done any work with DNS configuration, these little tricks may help you get through your workflow a little faster. You’ll learn some commands and ways to work with DNS data in your terminal, like how to check the current name servers. When you’re finished, you’ll even know how to set up DNS load balancing.

How to Confirm Your DNS Records are Working Using WHOIS and Dig

DigitalOcean is one of the many options you have for managing your domain name servers. In this example, you’ll see what DNS records look like when using DigitalOcean. You can point your domain to the DigitalOcean name servers , and you might see that pinging it still displays the old information.

This may occur because the old DNS information has not had a chance to propagate. For example, your home internet provider will cache the DNS information for a designated amount of time known as TTL (Time To Live) and will provide only that information until it expires. The time to live is commonly set to half an hour.

You can verify that you are using the DigitalOcean name servers by running WHOIS; the output should include the most current name server information:

  1. whois yourdomainname.com
Output
Domain Name: YOURDOMAINNAME.COM Registrar: ENOM, INC. Whois Server: whois.enom.com Referral URL: http://www.enom.com Name Server: NS1.DIGITALOCEAN.COM Name Server: NS2.DIGITALOCEAN.COM Name Server: NS3.DIGITALOCEAN.COM Status: ok

After checking that the WHOIS information has been correctly updated, you can use dig to verify that the DigitalOcean name servers are serving DNS records for your domain name.

  1. dig -t NS yourdomainname.com @ns1.digitalocean.com
Output
; <<>> DiG 9.10.6 <<>> -t NS yourdomainname.com @ns1.digitalocean.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44786 ;; flags: qr aa rd; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;yourdomainname.com. IN NS ;; ANSWER SECTION: yourdomainname.com. 7200 IN NS ns3.digitalocean.com. yourdomainname.com. 7200 IN NS ns2.digitalocean.com. yourdomainname.com. 7200 IN NS ns1.digitalocean.com. ;; Query time: 30 msec ;; SERVER: 2001:4860:4802:32::6e#53(2001:4860:4802:32::6e) ;; WHEN: Thu Dec 22 12:11:26 CST 2022 ;; MSG SIZE rcvd: 161

All of this information is useful as it provides the fastest way to confirm that your site is connected to the correct name servers and that the information is propagating while your site is updating.

How to Set Up DNS Load Balancing

DNS records can provide a way of building a simple load balancer to distribute site visitors across several IP addresses, each one serving identical content. If more than one IP address is connected to a site, visitors will be sent to one of the connected IP addresses in order. Although this is a helpful way to serve more visitors and prevent the site from going down if one server fails, DNS load balancing does not account for geography, network congestion, or user IP address (among others). You can learn how to address these issues by checking out our What is a CDN article.

To set up DNS Load balancing, fill out the site’s A records with @ in the hostname, directing users to the main domain, and with the correct IP in the IP Address field. Your setup should look something like this:

dns

How To Change Name Servers Without Site Downtime

When changing your site’s name servers from your current host to DigitalOcean, you can do so without any site downtime.

Start by setting up all of your DNS settings in the DigitalOcean interface. Doing this will have no effect on your current website because the site has been configured on the original host.

Once you put in your A, CNAME, and MX server records, access your domain registrar. If you do not remember where you registered your name, you can look it up using “WHOIS”, a protocol that displays a site’s identifying information, such as the IP address and registration details.

Open up the command line and type:

  1. whois example.com

The command will display all of the details associated with the site, including the Technical Contact which contains your domain registrar.

Once you have the information, you can change the name servers to point to DigitalOcean (ns1.digitalocean.com, ns2.digitalocean.com, ns3.digitalocean.com), and the website will be transferred over with no downtime.

Conclusion

In this tutorial, you learned three tricks you can use to work with the DNS records of your site. From here, you can learn more about the details of DNS in our Intro to Managing DNS tutorial series.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Etel Sverdlov
Etel Sverdlov
Author
See author profile

Former Director of Community at DigitalOcean. Expert in cloud topics including LAMP Stack, CentOS, Ubuntu, MySQL, SSL certificates, and more.

Milecia McGregor
Milecia McGregor
Author
Senior Technical Writer
See author profile
Category:
Tags:

Still looking for an answer?

Was this helpful?
Leave a comment...

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!

Is there a recommended way to set up DNS without switching to Digital Ocean nameservers? I’m not able to switch over, unfortunately, as the website will be running from a subdomain and I don’t have control over DNS settings.

I guess what would be cool is if Digital Ocean were to create an A record for each droplet based on the droplet name. e.g. testsite.droplets.digitalocean.com

It then ought to be possible to use a CNAME for the external DNS entry and that way, if the IP address were to change possibly by destroying the existing droplet and creating a new one with the same name, it wouldn’t be necessary to change external DNS settings.

Hope that makes some sense… :/

It looks like you can simply use your own name servers without using digital ocean’s by following the “How To Change Name Servers Without Site Downtime” section above, but simply omitting the last step of changing the domain name servers to Digital Oceans.

Then look up your droplet’s IP address within Digital Ocean’s network and add that with the new hostname a-record to your existing DNS settings, effectively duplicating the setup for each droplet. I’m not sure how stable the IP address is, so that might need to be updated if you move between hosting locations or if you delete your droplet from what I understand.

Not sure if there are any other gotchas by not moving over your domain to Digital Ocean’s nameservers, but for testing a new host this should help. With a larger number of subdomains, mx record, spf record I don’t want to have to change over just to test out the service.

How much is it cost? I meant DNS management, is it for free ?

Hello DO,

Is it possible to configure “my own” NS (name server), like NS1.MYDOMAIN.COM. using CNAME with NS1.DIGITALOCEAN.COM.?

Thank you very much in advance.

DNS is free

I’m joining to the question about “my own” NS like NS1.MYDOMAIN.COM. using CNAME with NS1.DIGITALOCEAN.COM.?

I’m joining too (NS1.MYDOMAIN.COM)

Hi, I am just writting an article about own DNS servers. Will post it here as soon as it is approved. It just need some more correction.

Thanks for free DNS.

I’m joining too (NS1.MYDOMAIN.COM)

You can either install a DNS server on a droplet and set up glue records for that droplet, or simply use DigitalOcean’s DNS Manager and forward your nameservers to it by creating glue records that point to DigitalOcean’s NS IPs.

ns1.yourdomain.com -> ns1.digitalocean.com (69.55.55.74) etc.

Yes, please, what jerome said!

“”" I guess what would be cool is if Digital Ocean were to create an A record for each droplet based on the droplet name. e.g. testsite.droplets.digitalocean.com “”"

Would be very helpful!

Is it possible to just use DigitalOcean for hosting WITHOUT delegating DNS management?

@ph: Yes, of course. You can just point an A record to your droplet with your current DNS host.

@ph: Possible. Like @Kamal said just point an A record to your droplet. By the way, I’m using DNSimple instead of DigitalOcean’s for DNS Management.

I’m trying to use no-ip.com to point one of my free domains to my droplet using the IP address. I do this for my home internet connection and it works fine, but so far I’m not able to access my droplet via no-ip’s assigned domain name. I can access the droplet just fine via the IP address. I wanted to ask here if you guys know of any issues with free dynamic DNS services before I hit up their support channels.

Never mind, it looks like it was an outage on their end. Everything seems to be working fine now. Please delete this and my above comment if you need to.

When I try the dig command, it shows my hostname as connected to my IP address, not the name server. Also wherever it says “NS” in the example of what you should see, mine says A. I followed the directions for setting up a DNS for the A record, but didn’t do anything for CNAME. Is that part of the problem? I’m stuck.

@sarahkhank: What’s the domain name you’re dig-ing?

I have the same thing as sarahkhank. When I use the dig command on ericmeerstra.ca, the answer section comes up as an A and not an NS and gives my own IP address.

i cannot magage a subdomain to work… how i should configure my dns?

@Manuel: How do you have your subdomain set up currently?

How do I simply add a DNS alias? Like gmail.mydomain.com to mail.google.com/a/mydomain.com

@flavioribeiro.com: You can’t add a DNS alias. I believe you can just add this CNAME record:

gmail CNAME ghs.google.com.

and set a custom domain for google apps (it’s somewhere in the settings).

I get the following from the dig command

; <<>> DiG 9.8.3-P1 <<>> techbasics.ca @ns1.digitalocean.com ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4361 ;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; WARNING: recursion requested but not available

;; QUESTION SECTION: ;techbasics.ca. IN A

;; ANSWER SECTION: techbasics.ca. 1800 IN A 162.243.1.50

;; Query time: 4595 msec ;; SERVER: 198.199.120.125#53(198.199.120.125) ;; WHEN: Wed Sep 11 18:52:44 2013 ;; MSG SIZE rcvd: 47

My site isnt up.

Didnt have apache server installed working on it now.

Glad it’s working now :]

hi, i can’t access my domain with www. in url, how i can access this?I put the www in CNAME but dont work, please help me…

@gustavoferrarigranero: What’s the domain?

i’m still looking for a tut that teach using own nameserver like ns1.mydomain.com

To direct your domains to your DigitalOcean droplet without changing nameserver info at the registrar simply add two DNS A records with the IP address of your droplet (for example 123.45.67.890):

@ A 123.45.67.890 www A 123.45.67.890

Working fine for me on Ubuntu droplet with multiple domains and virtual hosts.

I’m having issues setting up a subdomain. The url is api.wearerockable.com. I’ve created an A record that forwards to the IP address of the droplet but when I ping or whois it doesn’t resolve to a host.

@jonathan: It’s resolving fine for me. Can you please check again?

I have one drop which is called priyatnogo-appetita.com. At the drop site server priyatnogo-appetita.com. In dns record - A Records@198.199.127.162. Now I want to create a second dropon which will also be placed site server priyatnogo-appetita.com (for load balancing). How to give the name of the new drop, any, and dns record - A Records@IP.new.droplets, or need to give a name necessarily priyatnogo-appetita.com? Thanks in advance for your reply.

@asterixoder: You can simply create another A record with the name of @ and the value of the new droplet’s IP address. (<a href=“http://en.wikipedia.org/wiki/Round-robin_DNS”>Round-robin DNS</a>)

How can I create PTR record? On the DNS it is written that ‘To update your PTR record please update your Droplet’s hostname through the control panel.’ but though I have a defined hostname in control panel I don’t have PTR.

@friczy: You just have to rename your droplet to a FQDN, the PTR record will be set automatically. You can also see them here: <a href=“https://cloud.digitalocean.com/domains”>https://cloud.digitalocean.com/domains</a>.

I use dig to verify that the DigitalOcean name servers are serving DNS records for my domain name but the result return status SERVFAIL. I change Name Server on my domain and add domain on DigitalOcean already. How Can I fixed it?

Creative CommonsThis work is licensed under a Creative Commons Attribution-NonCommercial- ShareAlike 4.0 International License.
Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.