// Define main function (script entry)
//自定义规则更新不会被覆盖
const prependRules = [
// lan ip
"IP-CIDR,172.172.0.0/32,DIRECT,no-resolve",
"IP-CIDR,192.168.0.0/32,DIRECT,no-resolve",
"IP-CIDR,192.192.0.0/32,DIRECT,no-resolve",
"IP-CIDR,127.0.0.0/32,DIRECT,no-resolve",
// xxx替换为需要自定义的域名
"DOMAIN-KEYWORD,xxx,DIRECT",
//keyword代表任何包含xxx的域名都走指定出口 DIRECT是直连不翻墙的意思
"DOMAIN-SUFFIX,xxx.com,DIRECT",
];
// 国内DNS服务器
const domesticNameservers = [
"https://dns.alidns.com/dns-query", // 阿里云公共DNS
"https://doh.pub/dns-query", // 腾讯DNSPod
"https://doh.360.cn/dns-query" // 360安全DNS
];
// 国外DNS服务器
const foreignNameservers = [
"https://1.1.1.1/dns-query", // Cloudflare(主)
"https://1.0.0.1/dns-query", // Cloudflare(备)
"https://101.101.101.101/dns-query", // OpenDNS(主)
"https://101.102.103.104/dns-query", // OpenDNS(备)
"https://194.242.2.2/dns-query", // Mullvad(主)
"https://194.242.2.3/dns-query" // Mullvad(备)
];
// DNS配置
const dnsConfig = {
"enable": true,
"listen": "0.0.0.0:1053",
"ipv6": true,
"use-system-hosts": false,
"cache-algorithm": "arc",
"enhanced-mode": "fake-ip",
"fake-ip-range": "198.18.0.1/16",
"fake-ip-filter": [
// 本地主机/设备
"+.lan",
"+.local",
// Windows网络出现小地球图标
"+.msftconnecttest.com",
"+.msftncsi.com",
// QQ快速登录检测失败
"localhost.ptlogin2.qq.com",
"localhost.sec.qq.com",
// 微信快速登录检测失败
"localhost.work.weixin.qq.com"
],
"default-nameserver": ["223.5.5.5", "119.29.29.29"],
"nameserver": [...domesticNameservers, ...foreignNameservers],
"proxy-server-nameserver": [...domesticNameservers, ...foreignNameservers],
"nameserver-policy": {
"geosite:private,cn,geolocation-cn": domesticNameservers,
"geosite:google,youtube,telegram,gfw,geolocation-!cn": foreignNameservers,
}
};
// 前置规则
function main(config) {
config["dns"] = dnsConfig;
config.rules = prependRules.concat(config.rules);
return config;
}
复制后覆盖到
clashvergerev 订阅 全局扩展脚本 右键 编辑文件
即可自定义规则 以及dns 注意对齐如果出现错误 清空后保存即可恢复