Dnsmasq can be enabled to also provide the DHCP service on the Edgerouter X. Its DHCP server integrates with the DNS server and allows local machines with DHCP-allocated addresses to appear in the DNS. Dnsmasq also caches DNS records, reducing the load on upstream nameservers and improving performance, and can be configured to automatically pick up the addresses of its upstream servers.
When the dnsmasq cant resolv a domainname from its cache, it has to forward them to a DNS server to be resolved.
To add DNS servers use
set service dns forwarding name-server <DNS IP>.
If we want to also add the name-servers provided by the ISP use
set service dns forwarding dhcp eth0.
To query all the servers and use the result from the first responder
set service dns forwarding options all-servers.
We can also set another number on the cache size
set service dns forwarding cache-size 400.
After this we are add some options to the DNS forwarding.
edit service dns forwarding we do
options domain-neededthat sets the Dnsmasq to only forward internet domains to the DNS servers.
Otherwise Dnsmasq will try to resolve the domain towards etc/hosts or DHCP.
set options no-hosts Dnsmasq won't read hosts from etc/hosts if we want locals domains to resolve towards DHCP.
edit service dns forwarding ; set options no-hosts ; set options domain-needed ; set cache-size 400 ; set options all-servers ; set dhcp eth0 ; set name-server 22.214.171.124 ; set name-server 126.96.36.199 ; set name-server 188.8.131.52 ; set name-server 184.108.40.206 ; set name-server 220.127.116.11 ; top
This configuration will set dnsmasq to use fast public DNS servers, so we want to tell the DHCP client to not update /etc/resolv.conf with the DNS servers provided by the ISP, so this is turned of with
set interfaces ethernet eth0 dhcp-options name-server no-update.
Start with having the DHCP server to use Dnsmasq with
set service dhcp-server use-dnsmasq enable.
(Then we want to set a domain name for the range of the DHCP server
set service dhcp-server shared-network-name LAN subnet 192.168.1.0/24 domain-name lan., needed?)
The system name-server is where DNS queries on the system are sent to be resolved, and we want those to be sent to dnsmasq.
If there already is a name-server sending requests somewhere else it is deleted with
delete system name-server.
A new name-server is set with
set system name-server 127.0.0.1 that points to the IP of the local host and thus also to dnsmasq.
Article beeing rewritten. Old Text below.
This article shows how to setup and configure the Edgerouter to use dnsmasq to use external DNS servers, and to resolve local hostnames from DHCP. The configuration was made on an Edgerouter X running EdgeOS with version 2.0.8-hotfix.1 right after running the Basic Setup Wizard, wherfe eth0 is configured as the WAN port.
When logged into EdgeOS terminal interface there are two different modes.
configure to enter the configuration mode.
Configuration revisions can then be compared with
If you are happy with them, the changes can be commited with
commit, and if not all uncommit changes can be undone with
To make the changes permanent, they are written to file with
When ready configuring use
exit go back to operational mode. To update your /etc/resolv.conf in line with the settings, let the DHCP client release and renew your WAN IP with
release dhcp interface eth0 and
renew dhcp interface eth0. After this we can view the outcome with
show dns forwarding nameservers and
show dns forwarding statistics.
Below are all the commands above collected.
configure set interfaces ethernet eth0 dhcp-options name-server no-update edit service dns forwarding ; set name-server 18.104.22.168 ; set name-server 22.214.171.124 ; set name-server 126.96.36.199 ; set name-server 188.8.131.52 ; set name-server 184.108.40.206 ; set cache-size 400 ; set options all-servers ; top delete system name-server set system name-server 127.0.0.1 compare commit save exit release dhcp interface eth0 renew dhcp interface eth0 show dns forwarding nameservers show dns forwarding statistics