找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 3435|回复: 6

[R3G] openwrt 手动安装AdGuardHome

[复制链接]
本帖最后由 XiaoZzzzziFu 于 2023-2-1 16:51 编辑

大自然的搬运工

参考openwrt官方给出的教程官方教程https://forum.openwrt.org/t/how-to-updated-2021-installing-adguardhome-on-openwrt/113904
ssh工具连接路由器,安装依赖
  1. opkg update
  2. opkg install sudo ca-certificates ca-bundle curl wget-ssl tar unzip bind-tools libcurl4
复制代码
安装AdGuardHome
  1. curl -s -S -L https://raw.fastgit.org/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v
  2. #原地址为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) 自定义规则选项 添加
  1. iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 54 #54改为你上面设置的dns服务器监听端口
  2. ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 54 #54改为你上面设置的dns服务器监听端口
复制代码
没有自定义规则选项 尝试用winscp之类的工具登录openwrt ,编辑/etc/config/firewall 文件,最后面添加
  1. config include
  2.         option path '/etc/firewall.user'
复制代码

如有相关字段就不需要加了,然后编辑/etc/firewall.user 文件 添加上面的 自定义规则 保存文件,重启防火墙或路由器之后,登录AdGuardHome 管理页面应该就能看到有统计记录了。

简单的国内外域名用不同DNS分流功能,参考坂本dalao
通过winscp等工具登录openwrt, 进入/etc/config/ 目录下 新建文件--文件名 dnsrule.sh,输入内容
  1. ##!/bin/bash
  2. CHINADNS=tls://dot.pub
  3. ##=号后为国内dns地址 按需填写,这里为腾讯DOT地址
  4. LIST="$(dirname $0)/dnsrule.txt"
  5. ##下面的地址是国外DNS地址 ,按需填写
  6. cat <<EOF > ${LIST}
  7. tls://8.8.4.4
  8. https://doh.opendns.com/dns-query
  9. https://dns64.dns.google/dns-query
  10. EOF
  11. 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}
  12. ##https://github.moeyy.xyz/为CDN地址,用来加速raw.githubusercontent.com
复制代码
保存,下一步 通过ssh工具 运行
  1. sh /etc/config/dnsrule.sh
复制代码
运行之后会在/etc/config下生成文件dnsrule.txt
下一步修改ADG配置文件
找到/opt/AdGuardHome/AdGuardHome.yaml 文件,打开文件找到字段 upstream_dns_file: " "   ,在" "中插入地址 /etc/config/dnsrule.txt
  1. upstream_dns_file: "/etc/config/dnsrule.txt"
复制代码

保存之后 ssh运行  /etc/init.d/AdGuardHome restart   #重启AdGuardHome服务
即可简单分流

可以通过crontab计划任务定时更新dnsrule.txt 文件
  1. 0 3 */2 * * sh /etc/config/dnsrule.sh && sleep 15 && /etc/init.d/AdGuardHome restart  #每两天的凌晨3点更新dnsrule.txt文件
复制代码

更新AdGuardHome:
通过winscp 在/etc/config/ 目录下新建文件 文件名 upagh.sh  内容:
  1. #Grab updated AGH from server and save to /tmp
  2. curl -L -S -o '/tmp/AdGuardHome_linux_mipsle_softfloat.tar.gz' -s\
  3. 'https://static.adguard.com/adguardhome/release/AdGuardHome_linux_mipsle_softfloat.tar.gz'

  4. #Stop AGH
  5. /etc/init.d/AdGuardHome stop

  6. #unzip updated file over top of AGH in /opt
  7. tar x -vzf /tmp/AdGuardHome_linux_mipsle_softfloat.tar.gz -C /opt

  8. #cleanup /tmp
  9. rm /tmp/AdGuardHome_linux_mipsle_softfloat.tar.gz

  10. #Restart AGH
  11. /etc/init.d/AdGuardHome start
  12. echo 'Updated'
复制代码


ssh运行 sh /etc/config/upagh.sh 测试运行是否正常,正常的话可以通过计划任务定时更新AdGuardHome版本
  1. 0 4 1 * * sh /etc/config/upagh.sh  #每月1号凌晨4点更新AdGuardHome
复制代码

其他CPU架构路由器更新ADG :到ADG-github-wiki 里找地址,在 Packaged releases 里面有支持架构的地址,将地址和文件名替换,如x86
  1. #Grab updated AGH from server and save to /tmp
  2. curl -L -S -o '/tmp/AdGuardHome_linux_386.tar.gz' -s\
  3.     'https://static.adguard.com/adguardhome/release/AdGuardHome_linux_386.tar.gz'

  4. #Stop AGH
  5. /etc/init.d/AdGuardHome stop

  6. #unzip updated file over top of AGH in /opt
  7. tar x -vzf /tmp/AdGuardHome_linux_386.tar.gz -C /opt

  8. #cleanup /tmp
  9. rm /tmp/AdGuardHome_linux_386.tar.gz

  10. #Restart AGH
  11. /etc/init.d/AdGuardHome start
  12. echo 'Updated'
复制代码

我的恩山、我的无线 The best wifi forum is right here.
请问一下luci-app-AdGuardHome文件包在怎样找,原件源里面没有。

点评

+1,找到回复我一下  详情 回复 发表于 2023-2-2 21:39
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
TikTok 发表于 2023-2-2 20:49
请问一下luci-app-AdGuardHome文件包在怎样找,原件源里面没有。

+1,找到回复我一下

点评

已找到已找到已找到  详情 回复 发表于 2023-2-4 01:48
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

小飞侠8 发表于 2023-2-2 21:39
+1,找到回复我一下

已找到已找到已找到
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

挺好,学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

用这种方法安装的怎么卸载呢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

挺好,学习一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-27 15:36

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表