It has long been possible to block advertisements in Firefox on Linux, as well as other web browsers. However, blocking ads directly in the web browser leaves you still having to deal with ads in other apps that have them but do not have any add-on or plug-in support for disabling them.
If you’re tired of apps like Skype and others displaying annoying advertisements, it is possible to get rid of them by blocking ads through the DNS system in Linux. Here’s how it works.
What is DNS?
DNS stands for “Domain Name System.” It is the internet’s phonebook and keeps records of every website’s IP address. In modern web browsers, domain names translate to IPs, which are looked up through DNS.
As DNS is the primary way internet users find IP addresses, it can be used as a filtering system by disallowing access to IP addresses in DNS that are known to serve advertisements.
How to block ads via DNS in Linux
There are quite a few public DNS services that promise to filter out advertisements on all of your devices. However, in this guide, we will be focusing on Adguard. Why? It’s a free product and is known to work on Linux quite well. They specifically mention Ubuntu and take the Linux platform seriously.
Note: dislike using the Adguard DNS advertisement filtering service? If you’re savvy with the Raspberry Pi and networking, consider setting up Pi-Hole. It’s an application that anyone can install on the Raspberry Pi to turn it into their own private advertisement DNS filtering system, much like Adguard.
Find the network icon on the panel and click on it. Keep in mind that if you are using Ethernet, the icon will be a wired one. On Wi-Fi, it will be a Wi-Fi logo.
Upon clicking on the network icon in the Gnome Shell panel, you will reveal an options menu. In this options menu, click the arrow next to “Wired Connection” or “Wireless Connection.”
After clicking on “Wired Connection” or “Wireless Connection” in the menu, click “Wired Settings” or “Wireless Settings” with the mouse to launch Gnome’s network configuration tool. Then, follow the step-by-step instructions below.
Step 1: Inside of the Gnome Network settings, locate the “Wired” or “Wireless” area of the window. Then, click on the gear icon next to it.
Step 2: Upon clicking the gear icon, you will see a new window appear. This window is your default connection profile.
Note: Once again, If you are using an Ethernet connection, the window will say “Wired,” and if you are using Wi-Fi, the window will say “Wireless.”
Step 3: Locate the IPv4 tab, and click on it with the mouse.
Step 4: Find the “DNS” section and locate the “Automatic” slider. Then, click the slider to the off position to disable automatic DNS.
Step 5: Click on the text box with the mouse. Then, enter the following IP addresses in the box.
Click the “Apply” button to save the changes to IPv4, and reboot your PC. When you log back in, you will be using Adguard adblocking DNS.
KDE Plasma 5
Locate the network icon in the panel and click on it with the mouse. From there, find the gear icon, and select it to access the KDE Plasma 5 network settings. Then, follow the step-by-step instructions below.
Step 1: Select your primary connection on the left-hand side of the app. If you use an Ethernet connection, you will see “Wired connect.” Wi-Fi users will see their connection under “Wi-Fi”.
Step 2: After selecting your primary network connection, locate the IPv4 tab, and click on it with the mouse. The IPv4 area in KDE Plasma 5 is where users can change DNS settings.
Step 3: Find “Method” in the IPv4 area and change it to “Automatic (Only addresses)”.
Step 4: Locate the “DNS Servers” area and click on the menu next to it with the mouse.
Step 5: When you click on the menu next to the “DNS Servers” area, a pop-up window will appear. In this menu, write out the first Adguard IP address into the text box, and click the “Add” button.
Step 6: After adding the first DNS IP address, write out the second Adguard IP address into the text box, and click the “Add” button.
Step 7: Click the “Apply” button with the mouse to apply the changes and close the window.
Once your DNS settings are changed to Adguard, reboot. When you log back in, you’ll be blocking ads over DNS!
To block advertisements over DNS on Mate, XFCE4, and other desktop environments that use the “nm-applet” tool to manage network connections, start by clicking on the network icon to reveal your network menu. Then, select the “Edit connections” option and follow the step-by-step instructions below.
Step 1: Find the default network connection used on your Linux PC, and select it with the mouse.
Step 2: Click on the gear icon at the bottom-left to edit the connection.
Step 3: When you’ve selected the gear icon, it will open up a settings window for the connection you selected. In this settings window, locate the “IPv4 Settings” tab, and click on it with the mouse.
Step 4: Locate the “Additional DNS servers” box, and select it with the mouse. Then, add in the Adguard DNS servers below.
When all DNS servers are added, click on the “Save” button to save the changes. Then, restart your Linux PC. When the PC finishes restarting, your Mate or XFCE4 PC will be blocking ads via DNS!