Walk me through some DNS confusion

One thing I hate about making web sites is struggling with all of the DNS stuff. It’s quite confusing, esp. when you get multiple parties in for multiple services. Here’s what I’m trying to straighten out in my brain:

DOMAIN REGISTRAR - Network Solutions, GoDaddy, etc. These are the people you pay every year or two to renew your domain name.

WEB HOST - This is the company on whose servers the files for your web pages actually reside.

NAMESERVERS - These are the two or more nameserver addresses (like ns50.domainsomething.com) that tell the Internet at large what server to look to when someone types your domain name into a browser.

Now…
The WEB HOST needs to have a ZONE file that says the yourdomain.com is going to be linked to it, yes?

What do the NAMESERVERS have to be? Are they affiliated with your registrar or your web host?

ETA-- Sorry, submitted too soon. And where, exactly, do all of the A, CNAME, MX, and other records live? With Registrar, Web host? etc.?

Your web host will have a nameserver that tells the world that yourdomain.com is at IP 123.45.67.89. IP 123.45.67.89 belongs to a server on your Web host’s network. On that server, they set up your Web site.

All of the other records will be on your Web host’s nameserver too.

The registrar holds the info that yourdomain.com uses the nameserver at your web host’s place.

Think of it sort of like houses. The registrar knows your web site lives in WebHostCity, and that’s all the info the registrar is able to tell your computer. Your computer then needs to connect to the phone book in WebHostCity to find out exactly which house number your web site lives at. The phone book for WebHostCity also tells info like phone number (MX record) and other bits of your Web site’s location (subdomains).

Not exactly. The zone file is the configuration used by the nameserver to configure your DNS records (i.e., A, CNAME, MX, etc.). It resides on the nameserver and is parsed by the DNS software. It will include the A record(s) pointing to the web host.

Typically, but not required. You can run your own nameservers or use a third party.

These are the DNS records that “live” on the nameserver and are delivered when it receives a request (and are configured in the zone file).

A - Address record (www.foo.com -> 192.168.1.2)
CNAME - Canonical name or “alias” record (foo.com -> www.foo.com)
MX - Mail exchanger (mail for foo.com -> mail.foo.com)

Typically, the name servers are provided by your web host. This is preferred because its makes life easier on your web host and easier for you when you want to start doing this like virtual sites. Once you pick your web host they will tell you to change your record so your DNS points to their nameservers. Typically, your registrar provides a web interface so its easy to make this change.