服务器连接外网的方式

  1. 克隆 clash for linux 项目
1
git clone https://github.com/wanhebin/clash-for-linux.git
  1. 进入目录,修改 .env 文件中的订阅地址
1
2
cd clash-for-linux
vim .env

CLASH_URL 是订阅地址 ,CLASH_SECRET 是 web 界面的密码

image-20231026160459452

  1. 执行启动脚本
1
sudo bash start.sh
  1. 加载环境变量
1
source /etc/profile.d/clash.sh
  1. 启动或关闭代理
1
2
3
4
# 开启
proxy_on
# 关闭
proxy_off

检测服务端口

1
2
3
4
5
$ netstat -tln | grep -E '9090|789.'
tcp 0 0 127.0.0.1:9090 0.0.0.0:* LISTEN
tcp6 0 0 :::7890 :::* LISTEN
tcp6 0 0 :::7891 :::* LISTEN
tcp6 0 0 :::7892 :::* LISTEN

检测环境变量

1
2
3
$ env | grep -E 'http_proxy|https_proxy'
http_proxy=http://127.0.0.1:7890
https_proxy=http://127.0.0.1:7890