smol projects

on local dns

29.07.2023 2 min read

Local DNS Records

Tailscale is a neat VPN service that allows you to connect to another device on the Tailscale network, regardless of wherever you are.

Beyond its core offerings, it also comes with some interesting features: one of which is called MagicDNS. With MagicDNS, you can ssh with just the username + machine name, e.g. ssh username@monitoring. You can also access ports with your FQDN (fully qualified domain name - like absolute paths, I guess). Your Tailscale FQDN is comprised of two parts: your machine name, and your tailnet name. E.g. johns-phone, nonsensical-beluga.ts.net - in this case, the FQDN would be johns-phone.nonsensical-beluga.ts.net

All of this is designed to make accessing your services and machines easier. But, this wasn’t enough for me. I didn’t want to have to type subdomain.domain.ts.net every time I wanted to access a service in the browser. Or even http://machine. It’s not super intuitive (to me - YMMV). So, I looked into a way to set up local DNS. Based on my limited knowledge, you can do this in one of two ways: 1) Pi-Hole (I didn’t want to do this), or 2) edit the /etc/hosts file (what I ended up doing). It turns out that this file is used to map IP addresses to hostnames. Here’s what we need to do:

  • sudo nano /etc/hosts - open the /etc/hosts file in nano
  • Find the entry of your Tailscale mapping.
  • Under that, add your custom entry: e.g. xxx.xx.xx.xx machine.local
  • Save and exit
  • You might need to flush DNS

You should now be able to access machine.local in the browser! Works like magic.

Built with Astro and Tailwind 🚀