-
安装OpenClash:
- 在Linux系统上安装OpenClash:
sudo apt install openclash # Ubuntu/Debian sudo yum install openclash # CentOS/RHEL
- 启动服务并设置开机启动:
sudo systemctl start openclash sudo systemctl enable openclash
- 在Linux系统上安装OpenClash:
-
编辑配置文件:
- 打开配置文件:
nano /etc/openclash/openclash.json
- 修改接口设置,确保使用正确的接口(如eth1):
{ "default_route_settings": { "interface": "eth1", "masquerade": true } }
- 打开配置文件:
-
设置防火墙规则:
- 允许所有出站流量:
{ "firewall": { "default_rule": "Allow-Forwarding", "firewall_driver": "nf_tables", "firewall_name": "openclash" } } - 添加路由器规则(可选):
{ "rules": [ { "rule": "route", "description": "NAT规则", "source": ".../", "destination": ".../", "interface": "eth1", "mask": 255.255.255.255, "target": "masquerade", "position": 100 } ] }
- 允许所有出站流量:
-
保存并重启服务:
- 保存并退出编辑器。
- 重启OpenClash服务:
sudo systemctl restart openclash
-
验证配置:
- 检查防火墙规则:
iptables -L -n
- 测试网络连接,例如ping一个远程地址:
ping 192.168.1.1
- 检查防火墙规则:
通过以上步骤,您可以配置OpenClash路由器,确保网络流量被正确管理和过滤。









