DEV Community

Cover image for Domain records made less weird with `host`
Alvin Bryan
Alvin Bryan

Posted on • Updated on • Originally published at alvin.codes

Domain records made less weird with `host`

I've been hosting my websites and my domains with different providers for a long time. Same goes for emails. In order to connect your domain to your provider or to your email address, you need do 🚨Domain Verification🚨. And that means doing a few obscure DNS operations like changing name servers and whatnot.

You set this up on your domain registrar's website. It's usually hidden behind various clunky UIs. Frustrating is an understatement.

Do you know what the worst part is? After you find the hidden thing, paste the random blob, and sear never to do it again, you can't tell for sure that it worked.

That's where the host command comes in. It lets you inspect the DNS records on your domain from your terminal. It probably does other stuff but that's all I ever needed. With this command, you can finally see what your wrangling with the UI did.

Here are a few examples:

Show TXT records

host -t txt alvin.codes
Enter fullscreen mode Exit fullscreen mode

Show A records

host -t a alvin.codes
Enter fullscreen mode Exit fullscreen mode

Show CNAME

host -t cname alvin.codes
Enter fullscreen mode Exit fullscreen mode

Show Name Servers

host -t ns alvin.codes
Enter fullscreen mode Exit fullscreen mode

The host command is similar to the dig command, but it's a lot simpler and easier to remember. I know which one I prefer between typing dig alvin.codes +noall +answer and host -t a alvin.codes.

Bonus: Gitlab & GitHub

Speaking of hidden settings... Here's a bonus for you. Here's what you need to do to connect Gitlab or Github pages to a custom domain.

For Gitlab, 2 things need to be set:

  • A record set to 35.185.44.232. (Until their IP changes 🤷‍♂️.)
  • A TXT record set to gitlab-pages-verification-code=[Your Verification Code]

For GitHub you need to create a CNAME file at the root of your repository. You can use with the GUI to set it up with the correct values for your domain.

Then, you need to set the following A records:

185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
Enter fullscreen mode Exit fullscreen mode

Feel free to reach for this article next time you have a domain to set up, I sure will.

Good luck,
Alvin

Top comments (0)