安装Clash Meta
在Mac上安装Clash Meta:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/clash_meta/meta/main/install.sh)"
打开配置文件
默认配置文件位于 ~/clash_meta/config.json,可以使用文本编辑器打开。
调整DNS设置
在配置文件中,找到dns字段,将其设置为你的DNS服务器IP地址:
"dns": "192.168.1.1"
添加域名过滤规则
在filter部分添加你需要过滤的域名列表:
"filter": [ "ads.example.com", "social.example.com" ]
设置路由和网关
在routes字段中设置.../,作为所有网络的默认路由,并指定本地网关:
"routes": [
{
"ip": "...",
"mask": 0,
"gateway": "192.168.1.1"
}
]
配置Port Forwarding
在port_forwarding部分添加你需要转发的端口:
"port_forwarding": [
{
"listen": "...",
"port": 808,
"gateway": "192.168.1.1"
},
{
"listen": "...",
"port": 8443,
"gateway": "192.168.1.1"
}
]
安全设置
在firewall部分添加允许的本地端口:
"firewall": [
{
"outbound": "all",
"destination": "localhost",
"port": 5432
}
]
保存并重启Clash Meta
保存配置文件后,重启Clash Meta服务:
clash-metactl restart
这样Clash Meta将根据你的需求进行网络管理和安全过滤。









