adguard home 客户端ip识别为内网怎么办?
笔记 AdGuard Home 101

最近我遇到了这个棘手的问题,首先我要说明一下,我使用VPS搭建daguard home,也许我的方法在你的软路由上不适用。

  • 那么首先我们要知道,adguard home 是如何知道你的ip的?在不存在前置反向代理的情况下,则会获取直接连接他的客户端ip。而在有前置代理的情况下呢?我们在https://github.com/AdguardTeam/AdGuardHome/wiki/Encryption#reverse-proxy 可以找到:

    The nginx.conf file should contain the appropriate directives to add the supported forwarding headers to the request which are X-Real-IP or X-Forwarded-For. This may be achieved with ngx_http_realip_module which is explained here. In short, the module takes real IP address of the client and writes it to the HTTP request's header. The AdGuard Home will receive and interpret the value of this header as real client's address. The address of the reverse proxy server will be received too and also checked against the "trusted" proxies list.
    nginx.conf 文件中应包含相应的指令,以便将支持的转发头(即 X-Real-IP 或 X-Forwarded-For)添加到 HTTP 请求中。这可以通过 ngx_http_realip_module 来实现,具体用法可以 在这里 查到。简而言之,该模块会获取客户端的实际 IP 地址,并将其写入 HTTP 请求的头部;AdGuard Home 会接收并解析该头部中的 IP 地址(即客户端的实际地址),同时还会检查该地址是否存在于“受信任的代理服务器列表”中。

如果你是自己编写的dns代理程序或者使用nginx等反代软件,那么注意要保证X-Forwarded-For能够正确传递。

  • 其次是要添加内网ip段到AdGuardHome.yaml的trusted_proxies,此处也可在官方解答中找到:

    To enable AdGuard Home to handle DNS-over-HTTPS requests from a reverse proxy server, set the trusted_proxies setting in AdGuardHome.yaml to the IP address of the proxy server. If you have several proxy servers, you can use a CIDR instead of a simple IP address.
    为了让 AdGuard Home 能够处理来自反向代理服务器的 DNS-over-HTTPS 请求,请将 AdGuardHome.yaml 中的 trusted_proxies 设置设置为代理服务器的 IP 地址。如果您使用的代理服务器有多台,可以使用 CIDR 地址(而不是简单的 IP 地址)来进行配置。
    

我是使用docker搭建的,所以填写的是容器内的ip段。如果到这里还无法成功,希望你能注意一下防火墙,以及修改后AdGuard Home是否重启以应用配置,ip段是否正常配置。

adguard home 客户端ip识别为内网怎么办?
https://chiban.fyi/archives/adguard-home-ke-hu-duan-ipshi-bie-wei-nei-wang-zen-me-ban
作者
Chiban
发布于
更新于
许可