Dnsmasq

Dnsmasq
Dnsmasq - http://www.thekelleys.org.uk/dnsmasq/doc.html

"Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP server. It is designed to provide DNS and, optionally, DHCP, to a small network. It can serve the names of local machines which are not in the global DNS. The DHCP server integrates with the DNS server and allows machines with DHCP-allocated addresses to appear in the DNS with names configured either in each host or in a central configuration file. Dnsmasq supports static and dynamic DHCP leases and BOOTP/TFTP/PXE for network booting of diskless machines."

Manual Installation
mkdir -p ~/.src ; cd ~/.src git clone git://thekelleys.org.uk/dnsmasq.git cd dnsmasq git checkout v2.63 make clean make

sudo make install PREFIX=/opt/dnsmasq
 * 1) installs only two files: 'dnsmasq' and the man page
 * 2) sudo make install  # installs to /usr/local/sbin/

TFILE=`mktemp` cat > $TFILE <<EOF
 * 1) configuration files directory
 * 2) sudo cp dnsmasq.conf.example /etc/dnsmasq.conf

expand-hosts domain=qa.onpar.net conf-dir=/etc/dnsmasq.d
 * 1) local-ttl=300
 * 1) log-queries
 * 1) resolv-file=/etc/resolv.conf

EOF sudo cp $TFILE /etc/dnsmasq.conf rm -f $TFILE sudo mkdir -p /etc/dnsmasq.d

./dnsmasq -s `dnsdomainname`
 * 1) startup, or use the init.d script following

Set the localhost or loop device on the server as a nameserver so it can use the DNS service that it is running. Add the nameserver line below to the top of the list in /etc/resolv.conf. nameserver 127.0.0.1
 * 1) /etc/resolv.conf:

Add the IP address of the DNS host to the /etc/hosts for reverse DNS lookup. 10.10.10.1   fw
 * 1) /etc/hosts

See dnsmasq-init.d

RPM Forge
yum install dnsmasq --enablerepo=rpmforge service dnsmasq start

Configuration
Easy: just put what you want in /etc/hosts, and restart dnsmasq

config files go in /etc/dnsmasq.d/

Sample /etc/dnsmasq.conf: log-queries
 * 1) Log the results of DNS queries handled by dnsmasq
 * 2) NOTE: logs are logged to daemon.debug, make sure syslog captures that level.

local-ttl=60
 * 1) Local domain TTL

domain-needed
 * 1) Never pass short names to the upstream DNS servers.
 * 2) If the name is not in the local /etc/hosts file then "not found" will be returned.

bogus-priv
 * 1) All reverse IP (192.168.x.x) lookups that are not found in /etc/hosts will be
 * 2) returned as "no such domain" and not forwarded to the upstream servers.

expand-hosts
 * 1) We can see our local hosts via our home domain without having to
 * 2) repeatedly specify the domain in our /etc/hosts file.

domain=example.com
 * 1) Your local domain name. It will tell the DHCP server which host to give out IP addresses for.

dhcp-range=192.168.0.20,192.168.0.50,24h
 * 1) The range of IPs that DHCP will serve: 192.168.0.20 to 192.168.0.50, with a lease time
 * 2) of 24 hours. The lease time is how long that IP will be linked to a host.

References:
 * HOWTO Use dnsmasq - http://blogging.dragon.org.uk/index.php/howtos/howto-use-dnsmasq-localhost-nameserver

dhcp
/etc/dnsmasq.d/dhcpd.conf dhcp-range = eth0, 10.10.10.150, 10.10.10.199, 12h dhcp-host = 00:10:99:31:b7:09, 10.10.10.7, voip, 24h

dhcp-host=00:0C:29:64:3D:2A,10.10.10.30,24h # plex
 * 1) dhcp-host=00:10:99:31:b7:09,10.10.10.7,24h # voip

References:
 * HowTo/dnsmasq - Debian Wiki - https://wiki.debian.org/HowTo/dnsmasq
 * DNSMasq as DHCP server - DD-WRT Wiki - http://www.dd-wrt.com/wiki/index.php/DNSMasq_as_DHCP_server

Clear Lease
Edit the lease file and restart dnsmasq: /var/lib/dnsmasq/dnsmasq.leases /var/lib/misc/dnsmasq.leases
 * 1) centos
 * 1) ubuntu

Dynamic DNS
Dynamic DNS is not supported externally.