Block ads on the Internet using the capabilities of MikroTik devices. Blocking is carried out using an address list (with a list of ad networks) and Firewall rules.
We block the display of advertisements from major ad networks, but you can also add your own ad networks (which are used on the sites you visit).
Remember that displaying advertisements is a means of rewarding site authors (eg MHelp.pro).
Blocking ad networks can also cause problems with logging into ad accounts on websites. Consider this if you or your users are webmasters.
- Create Address list
- Create Firewall Rule
- Add ad network address to block list
- How to find ad networks on site
- List of popular ad networks
Article in other languages:
🇪🇸 – MikroTik Firewall: Bloquear anuncios los sitios web
🇷🇺 – MikroTik Firewall: Блокировка рекламы на сайтах
🇫🇷 – MikroTik Firewall: Bloquer les publicités sur les sites Web
🇩🇪 – MikroTik Firewall: Blockieren Sie Anzeigen auf Websites
🇳🇱 – MikroTik Firewall: Advertenties op websites blokkeren
Create Address list
Let’s create an AdNetworks address list and add ad network domains to it.
[IP] -> [Firewall] -> [Address Lists] ->[+] -> [Name: AdNetworks ] -> [Comment: Blocking IP addresses of ad networks from this list.]
/ip firewall address-list add list="AdNetworks" comment="Blocking IP addresses of ad networks from this list."
Create Firewall Rule
We create a firewall rule that, upon detecting traffic from ad networks (AdNetworks list), puts the IP address of the ad network in the block list – BlackList (from the article “MikroTik Protection (basic device security setting)“).
[IP] -> [Firewall] -> [Raw] -> [+] -> [General: Chain=prerouting; Advanced: Src. Address List=AdNetworks; Action: add src to address list=BlackList, Timeout=2d 00:00:00; Comment="Rule #25 \"AdNetworksList\": drop connections from ad networks."]
/ip firewall raw add chain=prerouting src-address-list=AdNetworks action=add-src-to-address-list address-list=BlackList address-list-timeout=2d comment="Rule #25 \"AdNetworksList\": drop connections from ad networks."
Place the rule in the Raw table according to its number in the comment.
Add ad network address to block list
Google is the most popular advertiser, block the following ad network domains:
Add the domain to the AdNetworks address list:
[IP] -> [Firewall] -> [Address Lists] ->[+] -> [Name: AdNetworks; Address: adservice.google.com] -> [Comment: * Google ads]
Add other domain names in the same way or execute in the terminal:
/ip firewall address-list add address=tpc.googlesyndication.com list=AdNetworks comment="* Google ads"
You can also block the Google Tag Manager service, which is used to add third-party scripts to a web page:
/ip firewall address-list add address=securepubads.g.doubleclick.net list=AdNetworks comment="* Google Tag Manager"
If you use Russian-language sites, add the local advertising networks Yandex and Relap to the block list:
/ip firewall address-list add address=an.yandex.ru list=AdNetworks comment="* Yandex ads" /ip firewall address-list add address=relap.io list=AdNetworks comment="* Relap.io ads"
For other countries, you can add to the block list, the Criteo ad network:
/ip firewall address-list add address=static.criteo.net list=AdNetworks comment="* Criteo ads"
I use the * character in every comment to filter values and easily view the list of blocked networks.
How to find ad networks on site
Instructions for Google Chrome:
- Open the page of the site with advertising;
- Open Developer Tools (F12 key or Ctrl+Shift+I combination);
- Turn on the display of Coverage in the panel;
- Click the button Start instrumenting coverage and reload page;
Now you can see all scripts used on this web page and add scripts from unwanted domain names to the AdNetworks list.
I do not recommend adding a large number of ad networks to the block list – this can significantly increase the CPU load on weak routers. But blocking major ad networks can significantly reduce the number of ad units displayed for all devices on your network (especially mobile).
Large ad networks (Google, Yandex) use ad moderation and set rules that limit the position or number of ad units on a page. Blocking the more “junk” ad networks is probably the best solution.
Advertisements are a way of income for webmasters, motivating them to create quality content.
List of popular ad networks
List of common ad networks (will be updated)
Worldwide ad networks
Google, Criteo, Adsafeprotected.
/ip firewall address-list add address=tpc.googlesyndication.com list=AdNetworks comment="* Google ads" /ip firewall address-list add address=adservice.google.com list=AdNetworks comment="* Google ads" /ip firewall address-list add address=static.criteo.net list=AdNetworks comment="* Criteo ads" /ip firewall address-list add address=static.adsafeprotected.com list=AdNetworks comment="* Adsafeprotected ads" /ip firewall address-list add address=cdn.adsafeprotected.com list=AdNetworks comment="* Adsafeprotected ads"
Russian-language ad networks
/ip firewall address-list add address=an.yandex.ru list=AdNetworks comment="* Yandex ads"
/ip firewall address-list add address=relap.io list=AdNetworks comment="* Relap.io ads"
If you find popular ad networks (global or regional), write in the comments, I will add the rules to the article.
In addition to advertisements, analytics systems are installed on sites that violate your privacy and collect data, about blocking analytics systems and increasing privacy on the Internet, will be in the next article.
🟢 How to block ads on websites using MikroTik equipment was discussed in this article. I hope you can now reduce the number of displayed ads for devices on your network. However, if you run into any problems while setting up, feel free to write in the comments. I will try to help.