Notes on setting up dnsmasq as a DHCP and DNS server
Just some quick notes on how to set up dnsmasq as both a DHCP and DNS server. Most of the steps are copied from my old post here plus some info I found online: dnsmasq For Easy LAN Name Services dnsmasq on the Gentoo wiki dd-wrt's page on dnsmasq
1. Install it with:
pkg install dnsmasq
2. Make it start on boot:
echo 'dnsmasq_enable="YES"' >> /etc/rc.conf
3. Move the default configuration file out of the way with:
mv /usr/local/etc/dnsmasq.conf /usr/local/etc/dnsmasq.conf.old
4. Create a new /usr/local/etc/dnsmasq.conf and add the following:
interface=em0
domain=weirdbricks.com
dhcp-range=192.168.2.100,192.168.2.165,12h
dhcp-option=option:router,192.168.2.1
#dhcp reservations
dhcp-host=08:00:27:BB:65:49,192.168.2.90,infinite
#log DNS queries
log-queries
#log DHCP details
log-dhcp
#log file to use
log-facility=/var/log/dnsmasq.log
#dns stuff
domain-needed
bogus-priv
bind-interfaces
#option 6 = DNS server to use - this is important!
dhcp-option=6,192.168.2.99
#forward internet DNS requests to the router
server=192.168.2.1
Then in my /etc/hosts file I added:
192.168.2.90 chunkserver1
5. Restart dnsmasq so the changes can take effect:
service dnsmasq restart
Optional: If you need to reject DHCP offers from a DHCP server, you can do it using this on FreeBSD.