Ubuntu配置Clash代理服务

  1. 下载配置文件或者导入订阅连接配置

    1. 下载连接

      1
      2
      wget -O clash.gz 
      https://github.com/Dreamacro/clash/releases/download/v1.17.0/clash-linux-amd64-v1.17.0.gz
    2. 解压

      1
      gzip -d clash.gz
    3. 赋值权限

      1
      sudo chmod +777 clash
    4. 第一次执行创建必要文件:./clash

      1. 安装过程可能会出现网络问题下载不了,可以直接复制下载链接到外部现在再传进去是一样的。

        Untitled.png

    5. 去代理软件复制节点订阅地址

      1. 这里可以复制所有节点地址也可以自己配置节点然后生成地址

      Untitled.png

    6. 配置文件获取。

      方法一

       命令行获取
      
      
       
      1
      wget -U "Mozilla/6.0" -O ~/.config/clash/config.yaml 你的Clash订阅链接网址

      方法二

       用windows的clash软件获取配置文件
      
      
       ![Untitled.png](https://raw.githubusercontent.com/fantasy-ke/picx-images-hosting/master/notion/e82aa3080cae65d53b1e2fe3403b579c.png)
      
    7. 将获取的config文件替换到/root/.config/clash/config.yaml

    8. 最后的文件结构应该是这样

      Untitled.png

  2. 代理改成手动并配置端口

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    # 编辑环境变量
    sudo nano /etc/environment
    # 配置手动代理
    http_proxy="http://127.0.0.1:7890"
    https_proxy="http://127.0.0.1:7890"
    socks_proxy="socks5h://127.0.0.1:7891"
    no_proxy="localhost,127.0.0.1,::1"
    # CTRL+X 保存

    # 应用环境变量
    source /etc/environment
    # 查看代理服务配置
    env | grep -i proxy
    # 重启
    sudo reboot
  3. 启动clash

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # 重启clash服务
    sudo systemctl restart clash
    # 查看clash服务状态
    sudo systemctl status clash
    # 启动clash服务
    sudo systemctl start clash
    # 停止clash服务
    sudo systemctl stop clash
    # 设为开机启动
    systemctl enable clash
  4. 在官方提供的配置链接里指定节点

    1. 打开链接

      1
      http://clash.razord.top/
    2. 配置

      Untitled.png

      Untitled.png

  5. 测试 goolge.com 访问,不要用ping

    1
    2
    3
    4
    5
    6
    7
    # curl google.com
    <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
    <TITLE>301 Moved</TITLE></HEAD><BODY>
    <H1>301 Moved</H1>
    The document has moved
    <A HREF="http://www.google.com/">here</A>.
    </BODY></HTML>
  6. clash成功截图

    Untitled.png

  7. 想恢复正常上网把配置的端口删除然后重启即可。

参考链接

Ubuntu系统安装Clash代理 - 知乎 (zhihu.com)

Ubuntu 安装配置代理(Linux for clash + proxychains) - 爱码帮™分享编程知识和开发经验 (icodebang.com)

docker compose安装clash

参考链接:ubuntu-server20.04安装clash,并快速配置到可用 - linux学习记录 (frank9.com)

docker-compose.yml