Help Center Help Articles Community RMA & Warranty Downloads Tech Specs

EdgeRouter - DHCP Server Using Dnsmasq

Translated by AI

Overview

Readers will learn how to enable the Dnsmasq feature on the EdgeRouter's DHCP server.

NOTES & REQUIREMENTS:
Applicable to the v1.9.0 EdgeOS firmware and higher on all EdgeRouter models. Knowledge of the Command Line Interface (CLI) and basic networking knowledge is required. Please see the Related Articles below for more information.
 
Device used in this article:

Table of Contents

  1. Frequently Asked Questions (FAQ)
  2. DHCP Server Defaults and Enabling Dnsmasq
  3. DNS Configuration Additions
  4. Related Articles

Frequently Asked Questions (FAQ)

Back to Top

What is the difference between Dnsmasq and ISC DHCPD?

By default, the EdgeRouter's DHCP server uses the ISC DHCP daemon (DHCPD). The DHCP server can optionally be switched over to start using Dnsmasq instead of ISC DHCPD. One of the advantages of Dnsmasq is the integration of name resolution for local hostnames.

Where do custom Dnsmasq options need to be configured?

Custom options for Dnsmasq need to be configured in the service dns forwarding section. Custom parameters (such as subnet or global parameters) set in the service dhcp-server section are ignored if Dnsmasq is enabled.

How does Dnsmasq interoperate with static host mappings (DCHP reservations)?
When using Dnsmasq, the entries configured under service dhcp-server ... static-mapping will be set as statically assigned A records using the Dnsmasq host-record directive. The static host mappings will override any hostname entries provided by the DHCP clients.

DHCP Server Defaults and Enabling Dnsmasq

Back to Top

topology.png

The EdgeRouter will be configured to issue DHCP assigned IP addresses in the 192.168.1.0/24 range using the Dnsmasq DHCP Server.

By default, the Basic Setup wizard included in EdgeOS will automatically configure and enable the DHCP server on the LAN interface (eth1 in this example). The following configuration is added to the router when using the wizard:

set service dhcp-server disabled false
set service dhcp-server hostfile-update disable
set service dhcp-server shared-network-name LAN1 authoritative enable
set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 default-router 192.168.1.1
set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 dns-server 192.168.1.1
set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 lease 86400
set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 start 192.168.1.38 stop 192.168.1.243
set service dhcp-server static-arp disable
set service dhcp-server use-dnsmasq disable

Like mentioned in the FAQ above, the EdgeRouter's DHCP server uses the ISC DHCP daemon by default. The DHCP server can optionally be switched over to start using Dnsmasq instead of ISC DHCPD.

One of the advantages of Dnsmasq is the integration of name resolution for local hostnames. In this example, the wireless clients in the 192.168.1.0/24 network will obtain an address via DHCP and provide their hostname to the router. The router will then be able to provide name resolution services for all the clients in the local LAN network.

Follow the steps below to enable Dnsmasq for DHCP: 

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.

1. Enter configuration mode.

configure

2. Set the DHCP server to use Dnsmasq.

set service dhcp-server use-dnsmasq enable 

3. Commit the changes and save the configuration.

commit ; save

Dnsmasq Configuration Additions

Back to Top

If used earlier, the Basic Setup wizard included in EdgeOS will also automatically enable DNS forwarding on the LAN interface if the DHCP service was enabled. To manually specify the listening interfaces and name server, run the commands below:

set service dns forwarding listen-on eth1
set service dns forwarding name-server <public-dns-server>

This configuration option will forward all unknown DNS requests to a public DNS server. The EdgeRouter will still resolve names for all known DNS requests using the hostnames learned through Dnsmasq.

NOTE:There is more information about DNS forwarding in the DNS Forwarding Setup & Options article.

Like mentioned in the FAQ earlier, custom options for Dnsmasq need to be configured in the service dns forwarding section. Custom changes (such as subnet or global parameters) in the service dhcp-server section are ignored if Dnsmasq is enabled. It is possible however to set the domain name for the clients in the DHCP server section, for example:

set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 domain-name ubnt.local

Like with ISC DHCPD, we can also create static host mappings (DHCP reservations) using Dnsmasq. These are set in the service dhcp-server section:

set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 static-mapping <hostname> ip-address <ip-address>
set service dhcp-server shared-network-name LAN1 subnet 192.168.1.0/24 static-mapping <hostname> mac-address <mac-address>
NOTE:The hostname entries configured here will be set as statically assigned A records using the Dnsmasq host-record directive and will override any hostname entries provided by the DHCP clients.

Besides hostname resolution for DHCP clients, the EdgeRouter can also be configured to resolve custom host entries. This feature is useful when servers or other networking devices with statistically assigned IP addresses are present in the network. In the example diagram above, there is a statically assigned UAP-AC-Pro providing wireless connectivity to the clients. To create a custom DNS entry for the Access Point, add the following lines to the configuration:

set system static-host-mapping host-name uap-pro.ubnt.local inet <ip-address>
set system static-host-mapping host-name uap-pro.ubnt.local alias uap-pro

We can also set the domain name on the EdgeRouter itself. This will allow the router to resolve the FQDNs of hosts using just the shortnames:

set system domain-name ubnt.local

Related Articles

Back to Top

EdgeRouter - DHCP Server

EdgeRouter - DNS Forwarding Setup and Options

Intro to Networking - How to Establish a Connection Using SSH

Was this article helpful?
0 out of 0 found this helpful