linux 网络代理相关

linux 网络

问题描述

  • linux 不能访问互联网,通过 windows 代理访问互联网
  • 通过 clash 进行代理实现

windows 端

  • clash 允许局域网访问:红色方块地方开启
    • 开启的时候允许专用网络、公用网络访问,否则需要从防火墙中开启

  • 防火墙中中开启允许专用网络、公用网络访问
    • WIndows 安全中心 -> 允许应用通过防火墙 -> 下面的打开即可

linux 端

  • windows 的 clash 中复制命令,图片中的橙色部分
    • 复制下来之后大概长这个样子
    • 其中 host 表示 windows 的 ip,port 表示 windows clash 开启的端口
      • windows 的 ip 可以使用 cmdipconfig 查看
      • 端口就是橙色部分右边显示的数字
1
2
3
export https_proxy=http://host:port;
export http_proxy=http://host:port;
export all_proxy=socks5://host:port;
  • 例如
    • ip:119.75.217.109
    • port:7890默认端口,建议修改
1
2
3
export https_proxy=http://119.75.217.109:7890;
export http_proxy=http://119.75.217.109:7890;
export all_proxy=socks5://119.75.217.109:7890;

ssh

  • ssh 协议没有被设置转发,需要在 ~/.ssh/config 中进行配置
  • 如下是一个 github ssh 的配置
    • 其他都正常配置,加上最后一行即可
1
2
3
4
5
6
Host github.com
User banbao990
Hostname github.com
PreferredAuthentications publickey
IdentityFile xxxxxx
ProxyCommand nc -x host:port %h %p
  • 同样的例子
1
2
3
4
5
6
Host github.com
User banbao990
Hostname github.com
PreferredAuthentications publickey
IdentityFile xxxxxx
ProxyCommand nc -x 119.75.217.109:7890 %h %p

vscode 配置