配置V2Ray使用AdGuard的DNS达到去广告的目的

安装v2ray:

bash <(curl -L -s https://install.direct/go.sh)

安装Adguard:

cd /opt
wget https://github.com/AdguardTeam/AdGuardHome/releases/download/v0.96-hotfix/AdGuardHome_linux_amd64.tar.gz
tar -xzvf AdGuardHome_linux_amd64.tar.gz
rm -rf AdGuardHome_linux_amd64.tar.gz
cd AdGuardHome
./AdGuardHome -s install

设置Adguard的DNS服务监听在53端口:

清空默认的配置文件/生成一个UUID:

echo "" > /etc/v2ray/config.json
cat /proc/sys/kernel/random/uuid

编辑配置文件:

nano /etc/v2ray/config.json

下面这是一个KCP服务端的配置示例:

{
  "dns": {
    "servers": [
      "你的服务器公网IP"
    ]
  },
  "inbound": {
    "port": 10087,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "你的UUID",
          "alterId": 64
        }
      ]
    },
    "streamSettings":{
      "network":"kcp",
      "kcpSettings": {
        "mtu": 1350,
        "tti": 20,
        "uplinkCapacity": 30,
        "downlinkCapacity": 100,
        "congestion": false,
        "readBufferSize": 1,
        "writeBufferSize": 1,
        "header": {
          "type": "none"
        }
      }
    }
  },
  "outbound": {
    "protocol": "freedom",
    "settings": {
      "domainStrategy": "UseIP"
    }
  }
}

实际上无论是KCP还是WebSocket,还是其他等等配置,套路都是一样的,只需要先添加一个DNS配置:

  "dns": {
    "servers": [
      "你的服务器公网IP"
    ]
  },

然后在outbound下面的settings内加一条:

"domainStrategy": "UseIP"

重启V2Ray,完成配置:

systemctl restart v2ray

去访问一些网站,然后回到AdGuard的WEB页面,有DNS查询记录就说明OK了:

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注