🌐

DNSmasq DHCP Setup Guide

Jun 19, 2025

Overview

This lecture explains how to use DNSmasq as a DHCP server, provides a walkthrough of its configuration, and reviews essential IT infrastructure network services.

Using DNSmasq as a DHCP Server

  • DNSmasq can serve as a DHCP server in addition to DNS.
  • A DHCP server is generally configured on a machine with a static IP address.
  • The server’s network interface (e.g., eth_srv) should connect to the network to distribute DHCP.
  • For the example, eth_srv is assigned the IP 192.168.1.1/24.
  • eth_cli is the client interface, initially without an IP address.
  • The DHCP server is configured to listen for client requests and assign IP addresses from a specific range.

Basic DNSmasq DHCP Configuration

  • The interface option sets the listening interface for DHCP queries (e.g., eth_srv).
  • The bind-interfaces option restricts DNSmasq to configured interfaces only.
  • The domain option tells clients the domain name for local queries.
  • DHCP options specify the default gateway and DNS server for clients.
  • The DHCP range defines which IPs can be assigned and the lease time (e.g., 12 hours).
  • Avoid overlapping the server’s static IP with the DHCP range.

Running the Simulation

  • Use sudo dnsmasq -d -C dhcpconfig to start DNSmasq with the configuration.
  • On another terminal, run sudo dhclient -i eth_cli -v to simulate a DHCP client.
  • The client interface (eth_cli) receives an IP address (e.g., 192.168.1.80).
  • DHCP lease duration determines how long an IP is reserved for a client.

DNSmasq Output and Hostname Resolution

  • DNSmasq logs DHCP packet exchanges and updates hostname mappings.
  • It can act as an authoritative DNS server for locally assigned addresses.
  • Hostnames assigned can be resolved via local DNS queries (e.g., with the dig command).

Best Practices and Real-world Use

  • In production, DHCP servers and clients typically run on separate devices.
  • Test DHCP and DNS setups on isolated networks, never on production networks.

Key Terms & Definitions

  • DHCP (Dynamic Host Configuration Protocol) — Automatically assigns IP addresses and configuration to devices on a network.
  • DNSmasq — A lightweight tool providing both DNS and DHCP services.
  • Lease Time — Duration an IP address is assigned to a client before expiration.
  • Static IP Address — A fixed IP address manually assigned to a device.

Action Items / Next Steps

  • Review the DNSmasq DHCP configuration options.
  • Practice setting up a DHCP server and client on a test network.
  • Read about additional DHCP options for advanced network setups.