EdgeOS local DNS resolution

I have a few local services that I access through subdomains configured in CloudFlare’s public DNS. This is pretty useful specially if you, like me, don’t want to run your own DNS server locally.

I expose a S3-like service publicly that I turn on/off when friends want to access so that means that when I access it I go through the Internet and back to my local network, less than optimal when moving big data packets.

I though about setting a second ingress there (this service runs on top of TrueNAS, in a single-node K3s cluster) but that’s another thing that I need to maintain and can break.

Luckily, I use an EdgeRouter X SPF so I can use that to overwrite DNS requests to specific domains. It works wonders, no more editing /etc/hosts for me.

This is my config. First, if you use DHCP, make sure that you set the router’s IP as DNS servers. I put 1.1.1.1 as second NS, in case this breaks.

# Up the cache size a bit
set service dns forwarding cache-size 250

# Set system DNS servers and use them
set system name-server 8.8.8.8
set system name-server 8.8.4.4
set service dns forwarding system

# Set your local adddresses
set service dns forwarding options address=/foo.bar.com/192.168.1.XXX

# Save and check
commit
save
exit

show dns forwarding nameservers
-----------------------------------------------
   Nameservers configured for DNS forwarding
-----------------------------------------------
8.8.8.8 available via 'optionally configured'
8.8.4.4 available via 'optionally configured'

And that’s it. Now when I do an aws s3 sync locally I go directly to my NAS instead of going through the Internet.

You can check out official docs on how to access the configuration console for EdgeOS on this link.