Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How come when setting name server records, so you can work out what IP address a domain belongs to, you always use domains?

eg,

ns1.hostingcompany.com
ns2.hostingcompany.com

How come they can work out what IP address the name servers refer to?

Why aren't IP addresses used? Surely that would be more efficient? For a domain name lookup, it has to go:

  1. find out name server address
  2. resolve name server address to IP address (eg, ns1.hostingcompany.com to xxx.xxx.xxx.xxx)

But if IP addresses were used rather than host names, it could skip the second step?

share|improve this question

3 Answers 3

For the same reason you use names instead of IPs for Google, or Yahoo, or Amazon: so that if the IP of the server changes, they only need to update the DNS record, and you the customer don't have to do anything at all.

If you point your NS records to your hosting company's DNS servers by IP address, if those addresses change, you have to update your NS records to point to the new address. If you point to their DNS servers by DNS name, yes, you have to do an additional lookup, but you don't have to do anything if those servers' IPs change.

share|improve this answer

It's custom, but not always true: sometimes plain IP addresses are used. That's a lot of work when the IP address changes though.

And, if a name server record (like ns.example.com) is within the same domain ("in the same zone") as the record that is being requested (like www.example.com), then so-called glue records are used to specify both the domain name of the DNS server and its IP address. So, an example zone file could include:

[..]
example.com. NS  ns        ; ns.example.com is the nameserver for example.com
[..]
example.com. A   10.0.0.1  ; ip address for "example.com"
ns           A   10.0.0.2  ; ip address for "ns.example.com"
[..]

Strictly speaking, glue records are only required to avoid circular references, but in practice are also used to speed up DNS queries.

(Aside, note that some domain registrars provide name servers with different top-level domains, just in case something fails. The Dutch TransIP provides things like ns1.transip.nl, ns2.transip.eu and ns3.transip.net.)

share|improve this answer

What ~quack said, plus most operating systems will hold results in cache for some time. The very first DNS lookup would incur the small time cost of looking up the IP, subsequent queries will use the cached results.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.