2.3 KiB
hide
| hide | |
|---|---|
|
Ad Blocking
SmartDNS can block ads by returning SOA for the corresponding domain name.
Note: If you're using OpenWrt with LuCI, please refer to OpenWrt's domain blocking configuration method.
Basic Configuration Method
-
Block ads via
address /domain/#option, for example:address /example.com/#In the
addressoption:/domain/uses a suffix matching algorithm that includes its subdomains;#alone indicates both IPv4 and IPv6 blocking;- use
#6to block IPv6 only; - use
#4to block IPv4 only; - use
-to unblock this domain.
-
Block IPv6 only:
address /example.com/#6 -
If you want to unblock a particular subdomain:
address /sub.example.com/-
Using Community SmartDNS Ad-Blocking Lists
The community provides regularly updated ad-blocking list files for SmartDNS. You can directly use these ad-blocking list files, and add them to SmartDNS as an option with conf-file. Additionally, you can download and update these files periodically, then restart SmartDNS to take effect.
-
Download the configuration file to the
/etc/smartdnsdirectory:wget https://github.com/privacy-protection-tools/anti-AD/blob/master/anti-ad-smartdns.conf -o /etc/smartdns/anti-ad-smartdns.conf -
Modify the
/etc/smartdns/smartdns.conffile to include the above configuration file:conf-file /etc/smartdns/anti-ad-smartdns.conf
Ad Blocking Lists
| Project | Description | Configuration File |
|---|---|---|
| anti-AD | Anti Advertising for smartdns | https://anti-ad.net/anti-ad-for-smartdns.conf |
Non-SmartDNS List Format
For non-SmartDNS data, simple shell commands can convert it.
hosts Format
The following command converts the /path/to/hosts/file file (replace the path with your actual file) to the format supported by SmartDNS:
cat /path/to/hosts/file | grep -v "^#" | awk '{print "address /"$2"/#"}' > anti-ad-smartdns.conf
dnsmasq Format
The dnsmasq format is similar to SmartDNS, but not compatible. You can convert it using the following command:
cat /path/to/dnsmasq/file | grep address | awk -F= '{print "address "$2"#"}' > anti-ad-smartdns.conf