If you have Pi-hole on your network, that means you also have Dnsmasq, and therefore can have some local DNS fun.

Today I was wanting to wildcard a local domain to my NAS. I added a dnsmasq conf file to the box running Pi-hole containing:
Where the is the local ip of the NAS. Now on the local network whateveriwant.nas points at the NAS.


Finding this very useful.

It's also worth noting that Dnsmasq will respect the /etc/hosts file on the machine running Pi-hole. You can use it just like the hosts file on your computer, but it will apply across the local net.

I use this all the time to keep up with all the little devices on the LAN. For instance say I have an Odroid SBC I need to shell into, and I've setup an entry for it in Pi-hole's hosts file. Now rather than,
I can do something like,
ssh username@odroid

Show thread

@rho I have no idea how to do this, but, I'm about to check it out. Thanks for the tip.

@rho Doesn't this break things with the DNS cache once you leave the network? Then it tries to get to a 192.x IP when it should use the NAT IP

@Matter Yeah, this is very much a local network only solution. Leaving the local net won't really break anything so much, but rather just wont work.

I don't have my NAS exposed outside the LAN at the moment. When/if I ever do I would use a registered domain, and get rid of the pointers in Dnsmasq (since upstream DNS would be handling it.)

@rho IPv6 saved me for this: you can't access your IPv4 if you're in the NAT (on most routers), but when I set up IPv6 on my server everything suddenly started working even on the local network

Much better UX than telling users they can't sync when they're next to the server but should go home to get it to work πŸ˜†

@Matter @rho You can configure something called hairpin NAT to solve that issue.

@kelbot @rho yes, but not on any consumer router you get from the ISP that I've seen.

@Matter @rho I don't think most people considering selfhosting their own servers are likely to be using a crappy ISP provided router.

@kelbot @rho The bar is pretty low nowadays, with efforts like Yunohost and Freedombox... and most of the time it's good enough otherwise

@Matter @rho I don't want anywhere near them for security reasons alone. Then you've got the lack of control and features. Its not expensive to get something light years better. Totally worth it IMO.

@kelbot @rho it's not always possible to do that... I've been trying to get a modem-only device for years now

@Matter @rho Sure it is. Just pass everything through and hook your router up behind it.

@Matter @rho I'd prefer a modem only, but you could just treat the ISP router like it was just a modem and only hook up one of the lan ports into the wan port of your own router.

Sign in to participate in the conversation

Fosstodon is an English speaking Mastodon instance that is open to anyone who is interested in technology; particularly free & open source software.