Karl-Henrik


The random ramblings of Karl-Henrik 'KH' Nilsson


Configuring local dns for Ubiquity EdgeMax

I recently installed an internal DNS server in my network, and with some DNS caching rules I was noticing some pretty decent differences in DNS lookup speeds. I started to configure the router to pass my new DNS server as the primary DNS provider with a fallback to Google 8.8.8.8.

Configuring the router for this was easier said than done as the lack of a proper CLI reference guide forced me to stitch this solution together from multiple forum posts, questions and the little snippets of CLI in the EdgeOS user guide. This is honestly the first time I experienced a bit of an annoyance with a ubiquity product, I hope it’s just weak Google-Fu on my part, but it does not look that way.

How to set it up.

Right out of the box the EdgeMax is configured to accept whatever DNS servers the WAN DHCP is broadcasting, so let’s disable that first.

set interfaces ethernet eth0 dhcp-options name-server no-update

Because we are adding local DNS posts we only wish to use the Google DNS as a fall back and not as a primary DNS, so to make sure that we only respond with our primary DNS server we configure strict order as such, it’s also important that you add the primary name-server last as strict order seems to mean that it prioritises the last name-server added.

set service dns forwarding options strict-order

set service dns forwarding name-server 8.8.8.8
set service dns forwarding name-server 192.168.0.100 

It might be tempting just setting the system DNS directly using the system name-server option available in the GUI, but as UBNT Lab points out it is generally not a good idea. Pointing the system name-server to localhost is preferable as it will make the request go through DNSmasq and be handled just like a clients DNS request.

set system name-server 127.0.0.1

When we are done configurating it’s time to commit and save changes and release and renew our dhcp information

commit
save
exit

release dhcp interface eth0
renew dhcp interface eth0

As a final step we can show what forwarding nameservers we have and check the dns forwarding stastistics to see that requests are comming in and are being handled correctly.

show dns forwarding nameservers
# someuser@ubnt:~$ show dns forwarding nameservers
# -----------------------------------------------
#   Nameservers configured for DNS forwarding
# -----------------------------------------------
# 8.8.8.8 available via 'statically configured'
# 192.168.0.100 available via 'statically configured'

show dns forwarding statistics
# ----------------
# Cache statistics
# ----------------
# Cache size: 150
# Queries forwarded: 1496
# Queries answered locally: 367
# Total DNS entries inserted into cache: 4732
# DNS entries removed from cache before expiry: 108
 
# ---------------------
# Nameserver statistics
# ---------------------
# Server: 192.168.1.100
# Queries sent: 1445
# Queries retried or failed: 0
 
# Server: 8.8.8.8
# Queries sent: 0
# Queries retried or failed: 0

Thats it! Good luck and let me know if you implemented anything of this.

full script in one place for anyone that needs it!

configure

set interfaces ethernet eth0 dhcp-options name-server no-update
set service dns forwarding options strict-order

set service dns forwarding name-server 8.8.8.8
set service dns forwarding name-server 192.168.0.100 
set system name-server 127.0.0.1

commit
save
exit

release dhcp interface eth0
renew dhcp interface eth0