|
本帖最后由 XiaoZzzzziFu 于 2023-2-1 16:51 编辑
大自然的搬运工
参考openwrt官方给出的教程官方教程 和https://forum.openwrt.org/t/how-to-updated-2021-installing-adguardhome-on-openwrt/113904
ssh工具连接路由器,安装依赖
- opkg update
- opkg install sudo ca-certificates ca-bundle curl wget-ssl tar unzip bind-tools libcurl4
复制代码 安装AdGuardHome
- curl -s -S -L https://raw.fastgit.org/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v
- #原地址为https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh,改成了CDN链接节点方便国内访问
复制代码 之后浏览器打开 你的路由器ip:3000 (如192.168.1.1:3000)初始化配置AdGuardHome, 网页管理 监听端口改3000,dns服务器 监听端口改为54 或其他你喜欢的端口,设置用户名与密码,完成初始化配置
进入 路由器ip:3000登录AdGuardHome 自行配置dns服务器和其他设置
来到openwrt防火墙(fw3) 自定义规则选项 添加
- iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 54 #54改为你上面设置的dns服务器监听端口
- ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 54 #54改为你上面设置的dns服务器监听端口
复制代码 没有自定义规则选项 尝试用winscp之类的工具登录openwrt ,编辑/etc/config/firewall 文件,最后面添加- config include
- option path '/etc/firewall.user'
复制代码
如有相关字段就不需要加了,然后编辑/etc/firewall.user 文件 添加上面的 自定义规则 保存文件,重启防火墙或路由器之后,登录AdGuardHome 管理页面应该就能看到有统计记录了。
简单的国内外域名用不同DNS分流功能,参考坂本dalao :
通过winscp等工具登录openwrt, 进入/etc/config/ 目录下 新建文件--文件名 dnsrule.sh,输入内容- ##!/bin/bash
- CHINADNS=tls://dot.pub
- ##=号后为国内dns地址 按需填写,这里为腾讯DOT地址
- LIST="$(dirname $0)/dnsrule.txt"
- ##下面的地址是国外DNS地址 ,按需填写
- cat <<EOF > ${LIST}
- tls://8.8.4.4
- https://doh.opendns.com/dns-query
- https://dns64.dns.google/dns-query
- EOF
- curl -s https://github.moeyy.xyz/https://raw.githubusercontent.com/felixonmars/dnsmasq-china-list/master/accelerated-domains.china.conf | sed -E "s#server=(\/.+\/)114\.114\.114\.114#[\1]${CHINADNS}#g" >> ${LIST}
- ##https://github.moeyy.xyz/为CDN地址,用来加速raw.githubusercontent.com
复制代码 保存,下一步 通过ssh工具 运行
- sh /etc/config/dnsrule.sh
复制代码 运行之后会在/etc/config下生成文件dnsrule.txt
下一步修改ADG配置文件
找到/opt/AdGuardHome/AdGuardHome.yaml 文件,打开文件找到字段 upstream_dns_file: " " ,在" "中插入地址 /etc/config/dnsrule.txt- upstream_dns_file: "/etc/config/dnsrule.txt"
复制代码
保存之后 ssh运行 /etc/init.d/AdGuardHome restart #重启AdGuardHome服务
即可简单分流
可以通过crontab计划任务定时更新dnsrule.txt 文件
- 0 3 */2 * * sh /etc/config/dnsrule.sh && sleep 15 && /etc/init.d/AdGuardHome restart #每两天的凌晨3点更新dnsrule.txt文件
复制代码
更新AdGuardHome:
通过winscp 在/etc/config/ 目录下新建文件 文件名 upagh.sh 内容:- #Grab updated AGH from server and save to /tmp
- curl -L -S -o '/tmp/AdGuardHome_linux_mipsle_softfloat.tar.gz' -s\
- 'https://static.adguard.com/adguardhome/release/AdGuardHome_linux_mipsle_softfloat.tar.gz'
- #Stop AGH
- /etc/init.d/AdGuardHome stop
- #unzip updated file over top of AGH in /opt
- tar x -vzf /tmp/AdGuardHome_linux_mipsle_softfloat.tar.gz -C /opt
- #cleanup /tmp
- rm /tmp/AdGuardHome_linux_mipsle_softfloat.tar.gz
- #Restart AGH
- /etc/init.d/AdGuardHome start
- echo 'Updated'
复制代码
ssh运行 sh /etc/config/upagh.sh 测试运行是否正常,正常的话可以通过计划任务定时更新AdGuardHome版本- 0 4 1 * * sh /etc/config/upagh.sh #每月1号凌晨4点更新AdGuardHome
复制代码
其他CPU架构路由器更新ADG :到ADG-github-wiki 里找地址,在 Packaged releases 里面有支持架构的地址,将地址和文件名替换,如x86- #Grab updated AGH from server and save to /tmp
- curl -L -S -o '/tmp/AdGuardHome_linux_386.tar.gz' -s\
- 'https://static.adguard.com/adguardhome/release/AdGuardHome_linux_386.tar.gz'
- #Stop AGH
- /etc/init.d/AdGuardHome stop
- #unzip updated file over top of AGH in /opt
- tar x -vzf /tmp/AdGuardHome_linux_386.tar.gz -C /opt
- #cleanup /tmp
- rm /tmp/AdGuardHome_linux_386.tar.gz
- #Restart AGH
- /etc/init.d/AdGuardHome start
- echo 'Updated'
复制代码
|
|