19.3.2.15
)
$ dig google.com
will give you the IP address for google.com
$ dig -x 172.217.13.174
will do a "reverse DNS lookup" for 172.217.13.174
.
$ dig -x 172.217.13.174
will do a "reverse DNS lookup"
for 172.217.13.174
. This is actually looking up the
PTR
record for 174.13.217.172.in-addr.arpa
there are many types of DNS records (A, NS, MX, PTR, SOA, etc).
A
records store IPv4 addresses.
there can be many A
records for the same name with different IPs.
IPv4 addresses are in A
records and IPv6 addresses are in AAAA
records.
you need the IP address of gmail.com's mail server to send the email.
the mail server for a hostname is in the MX
DNS record
DNS servers all use caching, so it depends when the cache expires.
every DNS response has a parameter called the "TTL" ("time to live"). If you set a shorter TTL, you can update your DNS records faster!
some clients will ignore the TTL and cache the response for a different amount of time instead (like a day)
every domain name has a nameserver (actually usually more than one) which is the source of truth for DNS queries about that domain
there are 2 kinds of DNS servers:
"authoritative": source of truth, like reddit.com's DNS server. These have a authoritative database of IP address.
"recursive": like 8.8.8.8. they just query authoritative nameservers and cache
.com
nameserver
every TLD (.com, .io, etc) has DNS servers that store the nameservers for every domain with that TLD.
.com
nameserver?
There are root nameservers that can tell you where the TLD nameservers are. They're a.root-servers.net
to m.root-servers.net
.
Every recursive nameserver hardcodes the addresses of the root nameservers so that it has an IP address to start with.
you can just make a DNS query to reddit.com's nameserver yourself! (or more likely: use any other recursive DNS server you want)
UDP is more common, but we're seeing a recent move to encrypted DNS over HTTPS which uses TCP.