How to setup the dnsmasq
Setting up the dns server for the VM instances
This document explains how to detect a new client connection of the dnsmasq
dnsmasq
Manage the DNS server, DHCP server easily dnsmasq
lstlisting caption= /etc/dnsmasq.d/br_tap.conf
interface=br_tap
listen-address=192.168.0.1
bind-interfaces
bogus-priv
dhcp-range=192.168.0.2,192.168.0.250,255.255.255.0,24h
server=10.32.192.11
server=10.32.193.11
no-resolv
lstlisting
After install and setup this package, each VM instance would use the host's "hosts" (/etc/hosts) file for resolving the DNS query which is requested from in it.
In order to make it work properly, you should change the systemd-resolved configuration of your VM instances. systemdresolv
List of DHCP clients
lstlisting caption= List of dhcp clients ,style=bash
cat /var/lib/misc/dnsmasq.leases
lstlisting
DHCP client connection management
When a new DHCP client gets an address from the dnsmasq service, you may want to bind a new DNS name to it.
In order to do that, you should know when a new client gets an address.
Fortunately, the dnsmasq will execute a script for handling a new client.
lstlisting caption= Configuration ,style=bash
. . .
# Run an executable when a DHCP lease is created or destroyed.
# The arguments sent to the script are "add" or "del",
# then the MAC address, the IP address and finally the hostname
# if there is one.
dhcp-script=/usr/local/bin/dnsmasq.dhcp
. . .
lstlisting
Each client should send their client Id, therefore, the client id must be revised.
client file must be updated to use the mac address for the client id
lstlisting caption= /etc/netplan/somefile.yaml ,style=yaml
network:
version: 2
ethernets:
ens3:
dhcp4: true
dhcp-identifier: mac
lstlisting