Local DNS and DHCP with dnsmasq
Quick and simple: here's a dnsmasq configuration to have DHCP and DNS from a local server on your network.
First, install dnsmasq and prepare a folder for configurations. I'm using Ubuntu as an example:
apt update && apt install -y dnsmasq
mkdir /etc/dnsmasq
Now, let's edit /etc/dnsmas.conf
:
systemctl restart dnsmasq
Some assumptions here:
- your router is at 192.168.1.1
- your DNS/DHCP server is at 192.168.1.2. This machine needs a static IP address
Now you can also create some local DNS resolutions:
These only apply to your local network, but they are handy if you want to host a public website and still have it running from within the network without SSL certificate issues.
And here's how you can associate a MAC address with a fixed IP:
Bonus
If you want to block some annoying websites network-wide, it's also easy peasy: go to /etc/dnsmasq.d/blackhole.conf
and add some entries like so:
address=/bad-website.com/127.0.0.1
address=/another-site.com/127.0.0.1
With a bit of smartness and automation, you can even block ads with lists like https://easylist.to/
Have fun!