2021年6月3日 星期四

[dnsmasq] 使用 dnsmasq 快取 dns 去除 spotify 與google 廣告

 

加快本地的dns速度可以使用 dnsmasq 
這個 repo 有個管理界面在 5380 port

jpillora/docker-dnsmasq: dnsmasq in a docker container, configurable via a simple web UI https://github.com/jpillora/docker-dnsmasq

docker run --name dnsmasq -d  -p 53:53/udp -p 5380:8080  -v ~/workspace/dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf --log-opt "max-size=100m"  -e "HTTP_USER=user"  -e "HTTP_PASS=myps"  --restart always jpillora/dnsmasq



如果要 block google ads 或是 spotify的廣告可以使用下面的方式

cache-size=10000 
# This ensures local reverse lookup queries are never sent upstream (e.g. dig +noall +answer -x 10.0.1.1)
bogus-priv
# Names without a dot or other domain part will also not be forwarded upstream
domain-needed

#log all dns queries
log-queries
#dont use hosts nameservers
no-resolv
#use cloudflare as default nameservers, prefer 1^4
server=1.0.0.1
server=1.1.1.1
# server=8.8.8.8
# server=8.8.4.4
# strict-order
# cache-size=10000
all-servers
# cache-size=0
no-negcache
#serve all .company queries using a specific nameserver
server=/company/10.0.0.1
#explicitly define host-ip mappings
address=/myhost.company/10.0.0.2
#address=/google.com/127.0.0.1
address=/adclick.g.doublecklick.net/0.0.0.0
address=/adeventtracker.spotify.com/0.0.0.0
address=/analytics.spotify.com/0.0.0.0
address=/ads-fa.spotify.com/0.0.0.0
address=/analytics.spotify.com/0.0.0.0
address=/audio-ec.spotify.com/0.0.0.0
address=/audio2.spotify.com/0.0.0.0
address=/b.scorecardresearch.com/0.0.0.0
address=/bounceexchange.com/0.0.0.0
address=/bs.serving-sys.com/0.0.0.0
address=/content.bitsontherun.com/0.0.0.0
address=/core.insightexpressai.com/0.0.0.0
address=/crashdump.spotify.com/0.0.0.0
address=/d2gi7ultltnc2u.cloudfront.net/0.0.0.0
address=/d3rt1990lpmkn.cloudfront.net/0.0.0.0
address=/desktop.spotify.com/0.0.0.0
address=/doubleclick.net/0.0.0.0
address=/ds.serving-sys.com/0.0.0.0
address=/googleads.g.doubleclick.net/0.0.0.0
address=/googleadservices.com/0.0.0.0
address=/gtssl2-ocsp.geotrust.com/0.0.0.0
address=/heads-ec.spotify.com/0.0.0.0
address=/js.moatads.com/0.0.0.0
address=/log.spotify.com/0.0.0.0
address=/media-match.com/0.0.0.0
address=/omaze.com/0.0.0.0
address=/pagead2.googlesyndication.com/0.0.0.0
address=/pagead46.l.doubleclick.net/0.0.0.0
address=/partner.googleadservices.com/0.0.0.0
address=/prod.spotify.map.fastlylb.net/0.0.0.0
address=/pubads.g.doubleclick.net/0.0.0.0
address=/redirector.gvt1.com/0.0.0.0
address=/s0.2mdn.net/0.0.0.0
address=/securepubads.g.doubleclick.ne/0.0.0.0
# address=/spclient.wg.spotify.com/0.0.0.0
address=/sto3.spotify.com/0.0.0.0
address=/tpc.googlesyndication.com/0.0.0.0
address=/upgrade.spotify.com/0.0.0.0
address=/v.jwpcdn.com/0.0.0.0
address=/video-ad-stats.googlesyndication.com/0.0.0.0
address=/weblb-wg.gslb.spotify.com/0.0.0.0
address=/www.googleadservices.com/0.0.0.0
address=/www.googletagservices.com/0.0.0.0
address=/adservice.google.com.tw/0.0.0.0
address=/adservice.google.com/0.0.0.0