How to check a record of domain

Run nslookup -type=A example.com 8.8.8.8 and read the Addresses: list. An A record maps a name to an IPv4 address, and a name can carry several. Repeat with -type=AAAA for IPv6. Use Node when you also need the TTL, which nslookup never prints.

Checker offline. Follow the manual steps below, they give the same answer.

Why check this

Run this after any deploy that moves a host: a new load balancer, a region added, a blue-green swap, an environment rebuilt from scratch. The failure it prevents is the one where a test suite passes against an address that is no longer in the record, because the suite resolved the name once at start-up and the record changed ten minutes later.

The check answers one question: which addresses does this resolver hand out for this name right now, and for how long will it keep handing them out. It says nothing about whether anything is listening on those addresses. A name that resolves to a decommissioned IP looks healthy to nslookup and refuses every connection.

Prerequisites

Steps

  1. Step 1.

    Read the IPv4 addresses.

    nslookup -type=A example.com 8.8.8.8
    
    Non-authoritative answer:
    Server:  dns.google
    Address:  8.8.8.8
    
    Name:    example.com
    Addresses:  172.66.147.243
      104.20.23.154
  2. Step 2.

    Read the IPv6 addresses with the same command and a different type.

    nslookup -type=AAAA example.com 8.8.8.8
    
    Non-authoritative answer:
    Server:  dns.google
    Address:  8.8.8.8
    
    Name:    example.com
    Addresses:  2606:4700:10::ac42:93f3
      2606:4700:10::6814:179a
  3. Step 3.

    Read both types with their TTL, which the nslookup output above does not carry. Save it as a-record.js and run node a-record.js example.com.

    const { Resolver } = require('node:dns');
    const name = process.argv[2];
    const r = new Resolver();
    r.setServers(['8.8.8.8']);
    r.resolve4(name, { ttl: true }, (err, addrs) => {
      if (err) { console.log('A    ' + err.code); return; }
      for (const a of addrs) console.log('A     ' + a.address + '  ttl ' + a.ttl);
    });
    r.resolve6(name, { ttl: true }, (err, addrs) => {
      if (err) { console.log('AAAA ' + err.code); return; }
      for (const a of addrs) console.log('AAAA  ' + a.address + '  ttl ' + a.ttl);
    });
    
    A     172.66.147.243  ttl 300
    A     104.20.23.154  ttl 300
    AAAA  2606:4700:10::6814:179a  ttl 300
    AAAA  2606:4700:10::ac42:93f3  ttl 300

    The IPv6 pair came back in the opposite order to step 2. Same records, same resolver, same session.

  4. Step 4.

    Ask for the A record of a name that is an alias and read the whole answer, not the first line.

    nslookup -type=A www.github.com 8.8.8.8
    
    Non-authoritative answer:
    Server:  dns.google
    Address:  8.8.8.8
    
    Name:    github.com
    Address:  140.82.121.3
    Aliases:  www.github.com

    The name you asked for is on the last line. The Name: line holds the canonical name the alias points to.

How to read the result

| What you see | What it means | What to do | | --- | --- | --- | | One address under Addresses: | A single origin answers for this name | Nothing. Confirm the host serves, resolving is not reaching | | Several addresses | The name is load balanced across them | Test every address, not the first one a client picks | | Name: differs from the name you typed | The name is a CNAME and the answer is the target's | Read the Aliases: line and check the alias itself | | A ttl of 300 in step 3 | A resolver may reuse this answer for 300 seconds | Plan a cutover around that number, not around the change time | | Non-existent domain | The name has no records of any type | Check the spelling and the zone the name should live in |

Common mistakes

Sign: Node answers ECONNREFUSED while nslookup on the same machine returns the record.Cause: dns.resolve4 uses the resolver list Node took from the operating system, and it does not fall back to anything when that list points at a stub that refuses queries. On this machine the default list fails and setServers(['8.8.8.8']) succeeds. The two tools are not asking the same server.
Sign: A test asserts on the first address in the answer and fails intermittently.Cause: Record order is not stable. Steps 2 and 3 read the same AAAA pair from the same resolver and got it in opposite order. Assert on set membership, never on position.
Sign: The report says www.example.com has an A record, and the zone file has no such line.Cause: An A query at an aliased name is answered with the target's address, and nslookup prints that target on the Name: line. The alias appears only under Aliases:, which is easy to miss at the bottom of the block.

What to check next

FAQ

How to check a record in dns without installing anything?

nslookup is already on Windows, macOS and most Linux images. Resolve-DnsName example.com -Type A does the same on PowerShell and prints the TTL, which nslookup omits. Node 22 needs no extra package for the script in step 3.

Why does nslookup show two addresses for one name?

The zone holds two A records at that name. Both are valid answers and a client picks one, usually the first it receives. Nothing in the protocol promises which, so treat the pair as a set.

Should an A record and a CNAME both exist at the same name?

No. A CNAME cannot share a name with any other record, so the two are mutually exclusive. If a zone editor accepts both, one of them is being ignored at answer time.

What if the address is right and the site is down?

Then DNS is not the fault. An A record is a mapping, not a health check. Confirm the port answers and the certificate matches the name before reopening the DNS question.

Verified

Verified by Maks Vernynslookup Windows 11 build 22631node 22.23.2

Each output block is what the command above it printed on that date, on the host named in the step. Figures read from a live site move between runs. Compare the shape of the answer rather than the digits, and see the methodology for how a page is re-verified.

basic4 minpublished updated Maks Verny