The glue records for the zone example.com
exist in its parent zone (com
), so you need to query the nameservers of that zone for the nameservers of example.com
without recursing into the subdomain. To do that you first need a nameserver for the parent zone:
user@host:~ $ dig +short com. NS
b.gtld-servers.net.
f.gtld-servers.net.
a.gtld-servers.net.
e.gtld-servers.net.
g.gtld-servers.net.
h.gtld-servers.net.
i.gtld-servers.net.
l.gtld-servers.net.
d.gtld-servers.net.
k.gtld-servers.net.
c.gtld-servers.net.
j.gtld-servers.net.
m.gtld-servers.net.
The nameservers are listed in random order, so you can just pick the first one from the output:
dig +short NS com. | head -n 1
Then query that server for the NS records of the domain in question. The nameservers for the subdomain are listed in the "authority" section of the response, their A records (if there are any) are listed in the "additional" section.
dig +noall +authority +additional +norecurse @b.gtld-servers.net. NS example.com.
Arguments:
+noall
: suppress all output
+authority
: except for the "authority" section
+additional
: and except for the "additional" section
+norecurse
: don't perform a recursive query
Example script:
#!/bin/bash
domain="${1:?Usage: $0 DOMAIN)"
domain="${domain%.}"
ns="$(dig +short NS "${domain#*.}." | head -n 1)"
dig +noall +authority +additional +norecurse @"$ns" NS "${domain}."