Disable the DNS cache


I use a &#x1F517Pi-Hole DNS server in my network to block malware, advertisements, and transmission of telemetry data. However, it occasionally happens that I need to whitelist or blacklist an address. In such cases, it is more than annoying when the operating system runs a DNS cache service.

Warning

These changes can have negative effects on the performance of your system. You should only make them if there is an actual need to do so. In addition, there may be problems if you frequently change your network connection (e.g., with a mobile laptop).

If you only occasionally want to clear your system's DNS cache, you can do so with:

sudo systemctl restart systemd-resolved

This script is used to disable the DNS cache service:

sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved
sudo mv /etc/resolv.conf /etc/resolv.conf.original

sudo bash -c "cat > /etc/resolv.conf" <<EOF
nameserver 192.168.178.35
EOF

In the example, .35 is the address of my Raspberry Pi, where Pi-Hole is running in a Docker container. You must adjust this according to your circumstances!

Source:


In Firefox open “about:config” and set the following values to 0: