Because you just want your site on the internet.

Here’s a list of thing you might want to do with DNS and how to accomplish them.

You’ve ~~impulse purchased~~ bought a domain from one of the infinite registrars on the internet, congrats! Now you’ve got to point it to something interesting and, no, the default parked page with ads all over it does not count.

The registrar you bought the domain name from probably manages DNS as well, so that’s nice and convenient.

Note

When you’re entering these values, you may or may not need the extra . at the end. There’s a reason you technically need it, but most interfaces will put it there for you regardless. Start with the dot and remove it if the service complains.

I have an IP address!

You’ve spun up a server somewhere on the internet and your hosting provider gave you an IP address. Nice!

I’m old and I like www.example.com

Have you ever thought about the fact that “world wide web” takes 3 syllables to say, but everyone says “double-yew double-yew double-yew” (9 syllables) regardless?

Now that you’re appalled at the inefficiency of saying “www”, here’s how you point www.example.com to your IP address.

Create an A record pointing example.com. to my.ip.addr.ess.

Then create a CNAME pointing www.example.com to example.com.

example.com. A my.ip.addr.ess
www.example.com. CNAME example.com.

Congrats, you did the thing.

I’m hip and prefer example.com

Please tell me of your refined taste for espresso.

Then set up your DNS like so

example.com. A my.ip.addr.ess

This sends all subdomains (*) to the apex domain.

I’m difficult and need custom.example.com

That’s cool. That’s cool.

In addition to one of the two options above, add a CNAME for each of the subdomains you want to point to that server’s IP address.

custom.example.com. CNAME example.com.

And so on.

I want to send email!

You want to email people from your sick new domain, do ya? Well best ready yourself to add some MX records, as well as some other fun ones.

MX Records (basically) tell the internet where to send your mail. They look something like this.

messagingengine.com belongs to FastMail. The 10 and 20 indicate priority. If in1-smtp.messagingengine.com. is down, the webserver sending the mail then tries in2-smtp.messagingengine.com..

You’ll also want to add these TXT records; FastMail uses the mesmtp._domainkey.example.com key to sign your outgoing mail. If you don’t have this set up correctly, your emails will have a “via messagingengine.com” label tacked onto them in email clients like gmail. With correct signing, your emails look legit af.

You also want an SPF record, which tells the internet that messagingengine.com is allowed to send email as you. The actual SPF Record type is obsolete, so throw this stuff into a TXT record like so.

All of the that text will be copy-and-paste-able from your email provider, so don’t try and type all that out. We’ve got the heat death of the universe to worry about, so conserve that energy!

GitHub Pages

GitHub Pages is a great way to host a static site. Your initial version will be up in 15 minutes and any updates are basically instantaneous.

There are a few ways to do this, but first you need a file called CNAME (yup, just CNAME, with no extension) that contains the root domain.

example.com is my root domain

To point your apex domain to GitHub Pages, set up some A records pointing to GitHub’s IP addresses.

Then add your apex domain as the contents of the CNAME file:

example.com

There are additional ways to do this if your DNS service supports more complicated setups.

If you want www.example.com to point to example.com (or vise versa), your CNAME file in your project should contain both values, with the highest priority one on top like so:

example.com
www.example.com

Then GitHub will automatically redirect www.example.com to example.com. Woo hoo!

But I want custom.example.com as my root domain

Well first, calm down, I’m getting there.

Second, to configure a custom subdomain, create a CNAME record that points custom.example.com to username.github.io.

More info on GitHub Pages custom domains is available here.

S3 Static Hosting

AWS’s S3 is also a decent way to host a static site.

AWS has instructions about this here.

Follow those instructions and it should look something like this:

Tell your registrar to use another service’s DNS servers.

Your domain registrar probably also lets you change your DNS servers to a different service. Hosting companies like AWS and DigitalOcean also support DNS management, so feel free to point your domain their way and use their superior DNS management interface. All the cool kids are doing it.

You can tell your registrar to use the third-party DNS servers by modifying them somewhere in their undoubtedly bad management interface.

This is what that looks like when you tell namecheap to use AWS’s DNS servers:

If you’re pointing a domain to other service’s DNS servers, they’ll probably be something like

ns1.example.com.
ns2.example.com.
ns3.example.com.

Twiddle Your Thumbs

The time it takes your DNS to update around the world is dictated by the TTL (time-to-live) times specified by your records, but in practice they’ll update when they feel like it, and no sooner.