How to Install dnsmasq on nixOS Latest
In this tutorial, we will guide you through the process of installing dnsmasq on nixOS Latest. dnsmasq is a lightweight DNS forwarder and DHCP server that is designed to provide network infrastructure for small networks.
Prerequisites
Before installing dnsmasq, you must have a working nixOS Latest system with root access or a user account with sudo privileges.
Step 1 - Updating nixOS
We recommend updating your nixOS system to the latest version using the following command:
sudo nixos-rebuild switch
Step 2 - Installing dnsmasq
Install dnsmasq using the following command:
sudo nix-env -i dnsmasq
If you receive a "command not found" error, then you need to update your NixOS channels using the following command:
sudo nix-channel --update
Step 3 - Configuring dnsmasq
Configuring dnsmasq involves creating a configuration file in the /etc/dnsmasq.d/ directory. We will create a basic configuration file that forwards all DNS queries to Google's DNS servers (8.8.8.8 and 8.8.4.4).
Create a new file called local.conf in the /etc/dnsmasq.d/ directory:
sudo nano /etc/dnsmasq.d/local.conf
Add the following configuration to the file:
server=8.8.8.8
server=8.8.4.4
Save and close the file.
Step 4 - Restarting dnsmasq
Now that you have configured dnsmasq, restart the dnsmasq service using the following command:
sudo systemctl restart dnsmasq.service
Testing
To test dnsmasq, run the following commands:
nslookup google.com
If dnsmasq is working correctly, the response should include the IP address of google.com. If it doesn't work, then check your configuration and restart the dnsmasq service.
Congratulations! You have installed dnsmasq on nixOS Latest, and it is now ready to use.