Prerequisites
Before you begin, ensure you have:
- A Debian 12 system
- Root or sudo privileges
Step 1: Install Dnsmasq
Install Dnsmasq using the following command:
sudo apt update
sudo apt install -y dnsmasq
Step 2: Configure Dnsmasq
Edit the Dnsmasq configuration file:
sudo nano /etc/dnsmasq.conf
Add the following configuration to the file to specify the DNS server and domain:
server=8.8.8.8
domain=local
You can replace "8.8.8.8" with the IP address of your preferred DNS server.
Step 3: Add Local DNS Entries
Edit the hosts file to add local DNS entries:
sudo nano /etc/hosts
Add entries for your local hosts in the following format:
192.168.1.10 server1.local
192.168.1.11 server2.local
Replace the IP addresses and hostnames with your own values.
Step 4: Restart Dnsmasq
Restart the Dnsmasq service to apply the changes:
sudo systemctl restart dnsmasq
Step 5: Test DNS Resolution
Test DNS resolution by pinging a local hostname:
ping server1.local
You should see successful ping responses.
Conclusion
Congratulations! You have successfully set up local DNS with Dnsmasq on Debian 12. You can now use local hostnames to access devices and services on your network.