Do you ever want to be able to type something simple, like router.themays.me in the address bar and get sent straight to the router admin page? Its much easier to remember a simple web address than several IP addresses. In the case of our home network, I’ve got several to remember. I’ve got the address of the NAS, Hubitat, Node-RED, AdGuard, Plex, my router, and several others. While I’ve organized my IP addresses to make sense based on the network function and/or access that device requires, its not as easy to remember exactly which IP address I’ve assigned to which piece of equipment. This is where custom DNS assignments (or DNS rewrites) come in.
Custom DNS entries allow me to specify something friendly. Using the same example, I want to go to my router page. Router IPs are usually easy, since they are the gateway IP. But, if I want instead to type something simple I can. Or maybe your spouse for some random reason wants to mess with the router (stranger things have happened). I’ll show you how to set this up.
This post won’t make sense without some basic detail about what DNS really is. DNS, or Domain Name System, is like an address book for the Internet. When you type www.themays.me into the browser address bar, you’re really asking your computer to find a specific IP address out of the trillions of IP addresses on the planet. Since its impossible to know all the IP address for all the websites you use, DNS makes this easy for the average person.
Basically, when you type themays.me into an address bar, your computer will send out a query to the DNS server (i.e. Google, Cloudflare, etc.). That DNS will query its database to see if it knows who owns themays.me and resolve a specific IP address. If that DNS server does not know, it moves the query to another DNS server. At some point, the query is returned with a “yes, I know where to find themays.me”. Once that happens and an IP address is resolved, your browser can connect to the website. Additionally, because the correct path is now known to that site, through caching your future connections will be a little faster. That’s a super simple explanation from an amateur.
Setting up Custom DNS entries
I’m going to use AdGuard primarily in this post as an example, but most home DNS servers have this capability. Synology NAS boxes can serve as the local DNS server, AdGuard and PiHole both are DNS servers that also block ads on your network, and you can even modify a file on your PC to resolve host names locally on that PC. I prefer to use a network DNS since the entries are applied across your entire network, versus one PC. If you don’t have a local DNS server, see this post for info on setting up PiHole or Adguard. Likewise, if you have a Synology NAS see this article for setting up a server on the NAS. Note that Synology’s DNS server does not block ads.
I’ll be using AdGuard as an example in this post, but the process is similar for PiHole. Synology is a little more involved, as you have to have some working knowledge of how A Records, CNAME Records, and AAAA records work. I won’t hit on Synology in this post, since I prefer to use a network ad-blocker if I’m going to the trouble of setting up a DNS server.
In AdGuard you want to go to the Filters menu. Under Filters, select “DNS Rewrites”. Essentially what you’re doing is telling the DNS server that a typed address (e.g. router.themays.me) needs to go to a specific IP address (e.g. 192.168.1.1).
Once in the rewrite menu the process for AdGuard is pretty simple. Hit “Add DNS Rewrite” and first type in what you want your friendly name to be. In the second box type the IP address that the name should point to. Hit the save option and add any other rewrites you want. This process is similar for PiHole.
One important step afer you finish adding entries is to flush the DNS cache. In PiHole it’s under settings, but for AdGuard it’s as easy as disabling and enabling blocking. I also found that my rewrites were not working initially, but a quick router reboot took care of that.
At this point, if you type myservice.mywebsite.com (assuming you set the entry up correctly), your home DNS server will send you to the service page to log in. All other requests it can’t resolve get forwarded to the next level server.
One thing to remember with rewrites and DNS records is that specific ports cannot be used. Most of these services are accessed via a specific port for admin manager. One way around this, since you have a friendly name, is to favorite in the browser. But, why not do that in the first place?
For me, it’s simply because I occasionally need to access these services remotely. This is usually because a site has broke, an automation hasn’t triggered, or I need to adjust a setting. WordPress doesn’t allow links to IP addresses. Likewise, I can’t access these particular links from outside my network (since I’m using my cellular or other network DNS server). Since I’m also usually on mobile, I can’t easily look up or type in IP addresses. Solution: VPN. With my VPN I can still take advantage of my ad blocker away from home and also access my local network. There’s several security concerns, but that’s also why you harden your network devices (especially those facing the public web). Rather than digging through the favorites tab, I can head over to a bookmarked link directly from the mobile homepage or just type the site in directly.
Another positive is you can get rid of some of those annoying security warnings from the browser. If you set up a security certificate, you can’t assign it to an IP address. You can, however, assign it to a domain. You accomplished that with a rewrite.