lala.im:配置V2Ray使用AdGuard的DNS达到去广告的目的

運維技術·VPN代理·lala.im · 2019-06-25 · 105 人浏览

原文地址:https://lala.im/5916.html,請支持原作者!該處僅作轉載。

安装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了:

範例

運維技術 VPN代理 lala.im
Theme Jasmine by Kent Liao