Jump to content

Ad blocking


Recommended Posts

How to remove ads from web pages and Android apps.

Before:

4d262a31311et.jpg

After:

5643795dd011t.jpg

Installation

Install necessary packages:

opkg install dnsmasq-full iptables ndmq

Create a netfilter hook /opt/etc/ndm/netfilter.d/010-intercept-dns.sh:

#!/bin/sh

[ "$table" != "nat" ] && exit 0

lan_ip=$(ndmq -p 'show interface Bridge0' -P address)

iptables -t nat -I PREROUTING -p udp -m udp --dport 53 -j DNAT --to-destination $lan_ip:65053
iptables -t nat -I PREROUTING -p tcp -m tcp --dport 53 -j DNAT --to-destination $lan_ip:65053

Make it executable:

chmod +x /opt/etc/ndm/netfilter.d/010-intercept-dns.sh

Add the following lines to the /opt/etc/dnsmasq.conf:

no-resolv
server=77.88.8.88#1253
server=77.88.8.2#1253
port=65053

Download your favorite blacklist to /opt/etc/hosts. For example:

wget -O /opt/etc/hosts http://winhelp2002.mvps.org/hosts.txt

Done! Reboot your router for the changes to take effect.

Troubleshooting

  1. Make sure you have not configured custom DNS servers in the Internet Connection properties.

  2. Flush your operating system DNS cache (in Windows — ipconfig /flushdns)

  3. Close and open your web browser.

Notes

Notes

The iptables rules redirect all DNS requests to the dnsmasq. The dnsmasq uses /opt/etc/hosts as an exception list. Yandex.DNS anti-ad servers are used for the unlisted hostnames. You can replace Yandex.DNS with Norton ConnectSafe or AdGuard public servers.

Link to comment
Share on other sites

  • 3 years later...
41 минуту назад, ikebanat сказал:

ndmq package is not available

1. You can install packages libndm and ndmq from archive (for mipsel - http://bin.entware.net/mipselsf-k3.4/keenetic/archive/). But it's deprecated.

2. You can install package jq and use RCI interface. Something like 

wget -qO - http://127.0.0.1:79/rci/show/interface/Bridge0 | jq -r '.address'

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...