why are there several nameservers for my domain?

Solution 1:

As others have commented, there are multiple nameservers for redundancy purposes.

If you have a single DNS server and it goes down, all your services go down with it regardless (er, whichever services rely on IP name resolution at least). If you have multiple name servers then when one fails the other(s) will take over or at least be reachable.

Without going into the topic of dns caching... In general, domains utilize multiple servers which typically segregate services. Most likely you actually have multiple servers hosting different services in your domain. It's likely your mail services are running on different servers than your web services, for example. So, then, when your web server goes down your mail is likely to continue to flow. If you had a single dns server and it was also down then you would not receive mail, even though your mail server is still up. Having multiple dns servers solves this case.

Also, you'll want those multiple DNS servers on different IP subnets so that when a router goes down or something similar your name resolution won't go down with it. This happened to Microsoft a while back.

Solution 2:

A nameserver is there to resolve a hostname to an IP address. You need two nameservers, as if one goes down then your host is inaccessible via name

You're right though, this doesn't alter the fact that if you only have one host and it's down, then it doesn't matter how many nameservers you have - The host will still be inaccessible via name

Solution 3:

You're right in that if you lose your primary DNS/Webserver and they're on the same box, it doesn't matter too much as far as your web hosting goes. There is still one very good reason to have redundant DNS and that's for email.

When a remote server attempts to send mail to your domain, it'll perform a lookup to find the MX records. If it can see them (because your secondary is up) but cant contact them, that mail will be queued. When your Web/DNS/Mail server comes back online, eventually the remote server will try redelivery and the message will come through.

If on the other hand you have no secondary DNS servers, when the remote end goes to lookup your domain and it's offline, it sees nothing. In that case, instead of queuing the email, it will bounce. Arguably if your domain has no mail service that's not a problem. In my experience DNS can be more fragile than other services though so the more redundancy you have the better.

Solution 4:

Correct, if you have only one server, it doesn't matter that much. But normally, you'll have multiple servers on different DNS records.

For this reason it's important not to have a single point of failure in DNS.