Skip to content

用Adguard Home自建DNS服务

Why

  • 图个安心
  • 加速
  • 一劳永逸的屏蔽广告,和防止钓鱼

下载安装

https://github.com/AdguardTeam/AdGuardHome/releases

wget https://static.adguard.com/adguardhome/release/AdGuardHome_linux_amd64.tar.gz
tar xvf AdGuardHome_linux_amd64.tar.gz && cd AdGuardHome && ./AdGuardHome -s install

# stop
./AdGuardHome -s stop
# 卸载
./AdGuardHome -s uninstall
# 下面是AdGuardHome的常用命令
# cd AdGuardHome
# start
./AdGuardHome -s start 
./AdGuardHome -s restart 
# 显示当前的服务状态。
./AdGuardHome -s status

配置

页面配置 – 还是要设到53端口上 – 这样客户端使用起来比较容易

常规设置,把勾搭上,启用日志

速度不要限制;上游DNS服务器填上

https://dns.quad9.net/dns-query
https://dns.cloudflare.com/dns-query

把能实现广告过滤的清单加上

#EasyList China : 国内网站广告过滤的主规则。
https://easylist-downloads.adblockplus.org/easylistchina.txt
#CJX's Annoyance List : 过滤烦人的自我推广,并补充EasyPrivacy隐私规则。
https://raw.githubusercontent.com/cjx82630/cjxlist/master/cjx-annoyance.txt
#I don't care about cookies : 我不关心 Cookie 的问题,屏蔽网站的 cookies 相关的警告。
https://www.i-dont-care-about-cookies.eu/abp/
# others
https://gitee.com/halflife/list/raw/master/ad.txt
https://gitee.com/xinggsf/Adblock-Rule/raw/master/rule.txt
https://gitee.com/xinggsf/Adblock-Rule/raw/master/mv.txt
https://easylist-downloads.adblockplus.org/easyprivacy.txt
https://cdn.jsdelivr.net/gh/neoFelhz/neohosts@gh-pages/127.0.0.1/basic/hosts
https://cdn.jsdelivr.net/gh/privacy-protection-tools/anti-AD/anti-ad-easylist.txt
https://gitee.com/banbendalao/adguard/raw/master/ADgk.txt
https://cdn.jsdelivr.net/gh/vokins/yhosts/data/tvbox.txt
https://anti-ad.win/easylist.txt

加一些例外,不然优酷可能看不了 (@@mp4.ts) – @@是允许的意思

修改本地配置 – 最主要就是改下blocked_response_ttl到60,其他都可以在页面改

~/AdGuardHome ❯ vi AdGuardHome.yaml

使用

网页配置就用 http://IP:3000 记得在宝塔中打开防火墙。如果加了域名反代,需要指向3000端口;然后就可以类似 https://dns.domain.com 来访问了。

需要的地方,把DNS改成DNS服务器的IP就行了。记得防火墙要打开53端口。

参考

主要参考了这篇

Sample yaml

bind_host: 0.0.0.0
bind_port: 3000
users:
- name: adguard_bw
  password: xxxxxxx
http_proxy: ""
language: ""
rlimit_nofile: 0
debug_pprof: false
web_session_ttl: 720
dns:
  bind_host: 0.0.0.0
  port: 53
  statistics_interval: 7
  querylog_enabled: false
  querylog_interval: 1
  querylog_size_memory: 1000
  anonymize_client_ip: false
  protection_enabled: true
  blocking_mode: default
  blocking_ipv4: ""
  blocking_ipv6: ""
  blocked_response_ttl: 10
  parental_block_host: family-block.dns.adguard.com
  safebrowsing_block_host: standard-block.dns.adguard.com
  ratelimit: 0
  ratelimit_whitelist: []
  refuse_any: true
  upstream_dns:
  - https://dns.quad9.net/dns-query
  - https://dns.cloudflare.com/dns-query
  bootstrap_dns:
  - 202.96.128.166
  - 210.75.24.195
  - 202.96.134.133
  - 9.9.9.9
  - 149.112.112.112
  - 1.1.1.1:53
  - 1.0.0.1:53
  - 8.8.8.8:53
  - 8.8.4.4:53
  all_servers: true
  fastest_addr: false
  allowed_clients: []
  disallowed_clients: []
  blocked_hosts: []
  cache_size: 4194304
  cache_ttl_min: 0
  cache_ttl_max: 0
  bogus_nxdomain: []
  aaaa_disabled: false
  enable_dnssec: false
  edns_client_subnet: true
  filtering_enabled: true
  filters_update_interval: 168
  parental_enabled: false
  safesearch_enabled: true
  safebrowsing_enabled: true
  safebrowsing_cache_size: 1048576
  safesearch_cache_size: 1048576
  parental_cache_size: 1048576
  cache_time: 30
  rewrites: []
  blocked_services: []

Leave a Reply

Your email address will not be published.