Help Center Help Articles Professional Support Community RMA & Warranty Downloads Tech Specs

EdgeRouter - DNS Forwarding Setup and Options

Overview

Readers will learn how the DNS forwarding feature works in EdgeOS and how to configure DNS forwarding using the CLI.

NOTES & REQUIREMENTS:
  • Applicable to the latest EdgeOS firmware on all EdgeRouter models.
  • The latest EdgeOS firmware can be downloaded from the EdgeRouter Downloads page.

Table of Contents 

  1. DNS Forwarding on EdgeOS
  2. Most Common DNS Forwarding Options
  3. Customizing the DNS Forwarding Options
  4. Related Articles

DNS Forwarding on EdgeOS

Back to Top

topology.gif

The EdgeRouter forwards the DNS request from the client to a public DNS server.

EdgeOS includes a DNS forwarding service based on dnsmasq that is consulted when clients use the EdgeRouter as a DNS server. The dnsmasq service runs in the background and will forward all client DNS queries to the specified DNS server(s).

There are two methods that can be used to provide DNS services to clients:

  • Global Provide clients global DNS server(s) using DHCP. In this case, the EdgeRouter's DNS forwarding service is not consulted.
  • Local Provide clients the EdgeRouter's IP address as the DNS server. In this case, the DNS forwarding service is used and all client DNS requests are forwarded.

The latter method is advantageous because the EdgeRouter can cache the DNS information for the clients. If one client has previously resolved the IP address of a website, the next client will be able to access that IP slightly faster by resolving the address locally from the EdgeRouter rather than remotely from a global DNS server. Another benefit of using local DNS forwarding in EdgeOS is the option to resolve local hostnames easily when also using dnsmasq for DHCP. This is explained further in our DHCP Server using Dnsmasq article.

NOTE:There are many different custom configuration options available for dnsmasq. This article only focuses on options that can be configured through the EdgeOS command line.
 
Editing the dnsmasq configuration files manually in the linux subsystem is beyond the scope of this article.

Most Common DNS Forwarding Options

Back to Top

Some of the options below are implemented when using a setup wizard to configure your router, however, they are detailed here for further explanation. These steps may also be useful to further customize your EdgeOS configuration after running the Basic Setup wizard. There is more information about the setup wizard in the Beginners Guide to EdgeRouter article.

CLI: Access the Command Line Interface.You can do this using the CLI button in the GUI or by using a program such as PuTTY.

Modifying the cache size

The default cache size is set to 150. It is possible to increase the size to 1000 or higher to allow a larger cache of more locally answered queries.

set service dns forwarding cache-size <nr>

Defining the listening interfaces

Pick one of the two commands below to define which interfaces are allowed to forward DNS requests.  The listen-on command specifies which interfaces are allowed, all other interfaces are denied:

set service dns forwarding listen-on <interface>
NOTE:The cache size and listening interfaces can also be configured in the Services > DNS > DNS Forwarding tab in the Web UI.

The except-interface command defines which interface is denied, all other interfaces are allowed:

delete service dns forwarding listen-on
set service dns forwarding except-interface <interface>

Defining the name servers

The EdgeRouter will use either manually configured or automatically obtained DNS servers to forward the client requests. The setting below allows the EdgeRouter to use to ISP provided DNS server(s) for DNS forwarding. This option is the default when using the Basic Setup wizard with DHCP selected as the Internet connection-type.

set service dns forwarding dhcp <interface>

To manually define the DNS servers, use the name-server command.

set service dns forwarding name-server <ip-address>
NOTE:You can specify multiple DNS servers with the name-server command.

The configuration below allows the EdgeRouter to use the DNS servers in the system settings to be used for DNS forwarding.

set service dns forwarding system
set system name-server <ip-address>
NOTE: If the system name server is set to loopback address, the router will use the DNS forwarding options for all DNS requests.

Use the commands below to verify the servers that are used for DNS forwarding and the statistics:

show dns forwarding nameservers
show dns forwarding statistics

Customizing the DNS Forwarding Options

Back to Top

This section will show a few DNS forwarding options possible using the EdgeOS CLI commands. This is not a fail-safe way to block or filter all traffic to a specific address.

CLI: Access the Command Line Interface.You can do this using the CLI button in the GUI or by using a program such as PuTTY.

 Forwarding URLs to a specific IP

This example would forward all traffic to domain.com to an internal IP of 192.168.1.10 which could be a webserver or similar device.

set service dns forwarding options address=/domain.com/192.168.1.10

Forwarding a domain to another DNS server

This example allows all DNS queries for a specific domain to be forwarded to another DNS server.

set service dns forwarding options server=/domain.local/192.168.1.10

Related Articles

Back to Top

EdgeRouter - DHCP Server using Dnsmasq

EdgeRouter - Beginners Guide to EdgeRouter

Intro to Networking - How to Establish a Connection Using SSH

Was this article helpful?
136 out of 219 found this helpful