Recently, I covered how to install and configure dnsmasq on Linux systems (see “How to speed up DNS caching on Linux machines with dnsmasq“). However, that particular setup doesn’t work for the likes of Fedora (both desktop and server editions). So I thought it time to walk through the process of getting the same system setup on Fedora 26. With this in place, you will enjoy faster dns lookups, for faster networking.
So, without further ado, let’s get to the setup.
SEE: 20 quick tips to make Linux networking easier (TechRepublic)
The first thing you must do is install the necessary software. To do this, open up a terminal window and issue the command:
sudo dnf install dnsmasq
Once the installation completes, you’re almost ready to configure. Before we do that, we must create a new unprivileged user and group that will handle the functions of dnsmasq. Issue the following two commands to take care of that:
sudo groupadd -r dnsmasq
âsudo useradd -r -g dnsmasq dnsmasq
Now it’s time to configure.
This is where things vary significantly to the Ubuntu installation. The first thing you want to do is copy the original configuration file with the command:
sudo cp /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
Next we’re going to delete the original configuration file and create a new one with the commands:
sudo rm /etc/dnsmasq.conf
âsudo touch /etc/dnsmasq.conf
Open that new file in your editor of choice and add the following:
Save and close that file.
Next we must create a specific dns resolve file that the system will use. Issue the command sudo touch /etc/resolv.dnsmasq and then open that new file with your editor of choice. The setup of this file is exactly like that of /etc/resolve.conf. So if you use the Google DNS nameservers, the contents of the /etc/resolv.dnsmasq will be:
Save and close that file.
Finally, in the /etc/resolv.conf file, make sure the only line is:
Testing and starting the setup
Before we start dnsmasq, let’s test out configuration with the command:
sudo dnsmasq --test
You should see no errors. That being the case, start up dnsmasq with the command:
sudo systemctl start dnsmasq
Finally, we’ll enable dnsmasq at boot with the command:
sudo systemctl enable dnsmasq
Faster DNS means faster networking
Issue a dig command on a domain and you’ll see a fairly standard response time. Issue the dig command a second time and you’ll see that response time drop to near zero. Congratulations, dnsmasq is working and your networking (to or from your Fedora machine) should now be significantly improved.