Home
Download

Open Source

Projects
Patches

System Integration

Notes
SRPMs

A simple OpenWrt-based DHCP/DNS server

This document describes how to build a simple DHCP/DNS server on top of OpenWrt. We assume you already have a working OpenWrt installation and that you have configured basic networking (/etc/config/network) and the host's name (/etc/config/system).

The following will configure dnsmasq to provide DHCP (assigning .1–.100), and DNS (e.g., assigning the hostname server.example.com to the computer with MAC address aa:bb:cc:dd:ee:ff). The DNS service will also resolve the local host's name, as set in /etc/config/system.

config dnsmasq
	option domainneeded '1'	
	option boguspriv '1'
	option filterwin2k '0'
	option localise_queries '1'
	option rebind_protection '1'
	option rebind_localhost '1'
	option local '/example.com/'
	option domain 'example.com'
	option expandhosts '1'
	option nonegcache '0'
	option authoritative '1'
	option readethers '1'
	option leasefile '/tmp/dhcp.leases'
	option resolvfile '/tmp/resolv.conf.auto'
	option server '192.168.1.1' # Upstream DNS.

config dhcp 'lan'
	option interface 'lan'
	option start '1'
	option limit '100'
	option leasetime '12h'
	option dhcpv6 'server'
	option ra 'server'
	list dhcp_option '3,192.168.1.1' # Default gateway.
	list dhcp_option '121,192.168.0.0/16,192.168.1.1' # A static route.

config dhcp 'wan'
	option interface 'wan'
	option ignore '1'

config odhcpd 'odhcpd'
	option maindhcp '0'
	option leasefile '/tmp/hosts/odhcpd'
	option leasetrigger '/usr/sbin/odhcpd-update'

config host
	option name 'server.example.com'
	option ip '192.168.1.101'
	option mac 'aa:bb:cc:dd:ee:ff'
Email: www@flyn.org — ✉ 6110 Campfire Court; Columbia, Maryland 21045; USA