dnsmasq is a simple DNS, DHCP, and TFTP server all built into one binary.

Usage[edit]

You can either run dnsmasq using the /etc/dnsmasq.conf configuration file, or specify the configuration as command line arguments.

For example:

dnsmasq --no-daemon --port=0 --log-queries --dhcp-range=192.168.192.11,192.168.192.250,1h --dhcp-option=6,192.168.192.10 --dhcp-option=3,192.168.192.10

DHCP Options[edit]

To get a list of options that you can pass to --dhcp-option, run

dnsmasq --help dhcp

You will get a list of numbers and their associated options like so:

Known DHCP options:
  1 netmask
  2 time-offset
  3 router
  6 dns-server
  7 log-server
  9 lpr-server
 12 hostname
 13 boot-file-size
 15 domain-name
 16 swap-server
 17 root-path
 18 extension-path
 19 ip-forward-enable
 20 non-local-source-routing
 21 policy-filter
 22 max-datagram-reassembly
 23 default-ttl
 26 mtu
 27 all-subnets-local
 28 broadcast
 31 router-discovery
 32 router-solicitation
 33 static-route
 34 trailer-encapsulation
 35 arp-timeout
 36 ethernet-encap
 37 tcp-ttl
 38 tcp-keepalive
 40 nis-domain
 41 nis-server
 42 ntp-server
 44 netbios-ns
 45 netbios-dd
 46 netbios-nodetype
 47 netbios-scope
 48 x-windows-fs
 49 x-windows-dm
 50 requested-address
 54 server-identifier
 60 vendor-class
 64 nis+-domain
 65 nis+-server
 66 tftp-server
 67 bootfile-name
 68 mobile-ip-home
 69 smtp-server
 70 pop3-server
 71 nntp-server
 74 irc-server
 77 user-class
 93 client-arch
 94 client-interface-id
 97 client-machine-id
119 domain-search
120 sip-server
121 classless-static-route

You may specify options using either:

dnsmasq --dhcp-option=<option number>,<value>
dnsmasq --dhcp-option=option:<option name>,<value>

IPv6 options are specified using:

dnsmasq --dhcp-options=option6:<option name>,<value>

PXE Boot[edit]

The next-server is defined using the dhcp-option-force=66,xx.xx.xx.xx option. The boot filename can be defined using the dhcp-boot=xxxx option.

Alternatively, these two options can be passed as a command line option using the -M flag, followed by the filename, next-server hostname, and IP. Eg. -M pxelinux.0,,10.130.4.254. The hostname can be left blank.

Example[edit]

Here is a working example of a PXE boot config that I've used on a RaspberryPi. Dnsmasq here also acts as the TFTP server serving from /tftpboot.

port=0
interface=eth0
bind-interfaces
dhcp-range=10.130.4.110,10.130.4.169,24h

dhcp-boot=/pxelinux.0
dhcp-option-force=66,10.130.4.254

enable-tftp
tftp-root=/tftpboot

Tips[edit]

DHCP Only Server[edit]

The DNS service in dnsmasq can be disabled by setting the port number to 0 and enabling DHCP by specifying the range.

dnsmasq --port=0 --dhcp-range=<start ip>,<end ip>,<lease time>