Overview #
In this tutorial I’m using an Ubuntu 24.04 LTS server with the IP 192.168.70.2
.
DNSmasq Setup #
Install DNSmasq #
# Install dnsmasq
sudo apt install dnsmasq -y
# Backup original configuration
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
Edit Configuration #
# Edit the configuration (override the original)
sudo vi /etc/dnsmasq.conf
domain-needed
bogus-priv
expand-hosts
listen-address=127.0.0.1
listen-address=192.168.70.2 # Define static IP of interface
bind-interfaces
server=8.8.8.8 # Define public DNS server
server=8.8.4.4 # Define public DNS server
# Define DNS entries:
address=/host1.local/192.168.1.100
address=/host2.local/192.168.1.101
# Define reverse DNS entries
ptr-record=100.70.168.192.in-addr.arpa,host1.local
ptr-record=101.70.168.192.in-addr.arpa,host2.local
Note: The following DNS entry host1.local
also includes wildcard subdomains like example.host1.local
.
Restart DNSmasq #
# Restart DNSmasq service
sudo systemctl restart dnsmasq
# Check the status
sudo systemctl status dnsmasq
Test DNS Resolution #
# Test DNS resolution
nslookup host1.local
# Test DNS resolution: Subdomain
nslookup subdomain.host1.local
# Test DNS resolution: Reverse DNS
nslookup 192.168.1.100
# Test DNS resolution: Define DNS server
dig @192.168.70.2 host1.local
# Test DNS resolution: Define DNS server, subdomain
dig @192.168.70.2 subdomain.host1.local