How Do I Use Dnsmasq as a DNS Server?


Angela Bailey

Dnsmasq is a powerful DNS server that can be used to provide DNS resolution and DHCP services on a local network. It is lightweight, easy to configure, and can be a great solution for small to medium-sized networks. In this tutorial, we will explore how to set up and use Dnsmasq as a DNS server.

What is Dnsmasq?
Dnsmasq is an open-source software package that provides DNS forwarding and caching capabilities along with DHCP services. It acts as both a DNS forwarder and a DHCP server, making it a versatile tool for managing network services.

Setting Up Dnsmasq

To get started with Dnsmasq, you’ll need to install it on your system. Depending on your operating system, installation procedures may vary. Once installed, you can proceed with the configuration.

Configuring Dnsmasq

Dnsmasq uses a configuration file located at “/etc/dnsmasq.conf” by default. You can open the file in your favorite text editor to make changes.

1. Basic Configuration

The first step is to specify the interface that Dnsmasq should listen on. This can be done by adding the following line to the configuration file:


Replace “eth0” with the appropriate network interface name for your system.

2. DNS Configuration

Next, we need to configure the DNS settings. Dnsmasq allows you to define custom DNS records and specify upstream DNS servers for forwarding requests.

To define custom DNS records, add lines in the following format:


This line tells Dnsmasq to resolve all queries for “” to the IP address “192.10”. You can add multiple lines to define different records.

To specify upstream DNS servers, use the “server” directive:


This line tells Dnsmasq to forward DNS requests to the Google Public DNS server at IP address 8.

3. DHCP Configuration

Dnsmasq can also act as a DHCP server, providing IP addresses and other network configuration parameters to client devices.

To enable DHCP, add the following lines to your configuration file:


This line defines a range of IP addresses from 192.100 to 192.200 that can be assigned to clients for a lease period of 12 hours.

You can also specify additional DHCP options such as default gateway and DNS servers:


These lines set the default gateway and DNS server options respectively.

4.Starting and Restarting Dnsmasq

Once you have finished configuring Dnsmasq, you can start or restart the service for changes to take effect.

On most Linux distributions, you can use the following command:

sudo systemctl restart dnsmasq

If you encounter any errors or issues, you can check the logs at “/var/log/syslog” or “/var/log/messages” for troubleshooting.


Dnsmasq is a versatile DNS server and DHCP server that can be easily set up and configured. It provides a lightweight solution for managing network services and offers flexibility in customizing DNS records and DHCP options.

By following the steps outlined in this tutorial, you should be able to set up and use Dnsmasq as a DNS server on your local network. Experiment with different configurations, explore additional features, and make the most of this powerful tool to enhance your networking experience.

Discord Server - Web Server - Private Server - DNS Server - Object-Oriented Programming - Scripting - Data Types - Data Structures

Privacy Policy