Logo with initials

Nifty command lines: host

──── 2 mins
Last Updated: 9 February 2021

This post is part of the Nifty Command Lines series.

I’ve been hosting my websites and my domains with different providers for a long time. Ergo 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

Show A records

host -t a alvin.codes

Show CNAME

host -t cname alvin.codes

Show Name Servers

host -t ns alvin.codes

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

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

Good luck, Alvin

364 words

Share