Nifty command lines: host
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
host -t cname alvin.codes
Show Name Servers
host -t ns alvin.codes
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
22.214.171.124. (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:
126.96.36.199 188.8.131.52 184.108.40.206 220.127.116.11
Feel free to reach for this article next time you have a domain to set up, I sure will.
Good luck, Alvin