背景:由于内网里需要翻墙的设备或者服务器较多,“梯子”只提供3个连接,且每个设备安装clash不现实,所以单独做一个服务器安装clash后提供其他内网服务通过代理连接实现“梯子”功能
前提:一台干净的内网服务器,不建议在此服务器上安装其他应用,单独做代理服务器使用
docker安装(推荐)
clash后台容器
docker run -d --name=clash -v "/home/clash:/root/.config/clash/" -p "7890:7890" -p "7891:7891" -p "9090:9090" --restart=unless-stopped dreamacro/clash
执行上述命令启动clash后台容器
将机场配置yaml的内容,复制到/home/clash/config.yaml中
mixed-port: 7890
port: 7890
socks-port: 7891
redir-port: 7892
allow-lan: true
mode: rule
external-controller: '0.0.0.0:9090'
注意:allow-lan如果时false,一定要改为true,否则不会将上面的端口代理出来
执行docker restart clash
重启clash容器
clash-ui容器
docker run -p 1234:80 -d --rm --name yacd haishanh/yacd
部署成功后,访问http://ip:1234/,配置clash后台容器9090端口,如下图

配置完成后点击进入就可以查看
普通安装
处理服务器
关闭SELinux、firewalld
vim /etc/selinux/config
将 SELINUX=enforcing 改为 SELINUX=disabled,保存后在执行
sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
# 关闭 firewalld
systemctl stop firewalld
systemctl disable --now firewalld
https://github.com/juewuy/ShellClash/blob/master/README_CN.md
export url='https://fastly.jsdelivr.net/gh/juewuy/ShellClash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && bash /tmp/install.sh && source /etc/profile &> /dev/null
开始安装clash
通过WinSCP或其他SCP客户端手动上传内核单独安装/升级内核:(此处用的clashpre内核)
1、参考↑↑↑识别内核及安装版本↑↑↑识别内核并下载对应内核文件:
Clash内核:https://github.com/Dreamacro/clash/releases
Clashpre内核:
Clash.meta内核:
如需要使用vless协议等特殊协议或自定义配置文件功能,需要使用Tun或者混合模式代理UDP流量,请下载Clash.meta内核;否则建议使用Clash内核
2、解压为标准二进制文件,通常无须改名,但务必保证文件名同时包含clash与linux两个字母且clash为首字母
3、之后将该文件使用WinSCP或其他SCP客户端上传至/tmp
4、在SSH中直接运行clash命令
clash
5、参考提示完成加载
命令行输入clash 安装完内核、面板,设置开机启动,修改clash功能设置->切换DNS运行模式 为 fake-ip
面板地址为:http://{内网服务器ip}:9999/ui
日常维护
命令行输入 clash