Linux 让终端ssh走代理流量

操作系统 6 个月前 回复

, ,

-方法一:(推荐使用)

为什么说这个方法推荐使用呢?因为他只作用于当前终端中,不会影响环境,而且命令比较简单

在终端中直接运行:

export http_proxy=http://proxyAddress:port

如果你是SSR,并且走的http的代理端口是12333,想执行wget或者curl来下载国外的东西,可以使用如下命令:

export http_proxy=http://127.0.0.1:12333

如果是https那么就经过如下命令:

export https_proxy=http://127.0.0.1:12333

方法二 :

这个办法的好处是把代理服务器永久保存了,下次就可以直接用了
把代理服务器地址写入shell配置文件.bashrc或者.zshrc

vi ~/.bashrc

直接在.bashrc或者.zshrc添加下面内容

export http_proxy="http://localhost:port"
export https_proxy="http://localhost:port"

或者走socket5协议(ss,ssr)的话,代理端口是1080

export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"

或者干脆直接设置ALL_PROXY

export ALL_PROXY=socks5://127.0.0.1:1080

最后在执行如下命令应用设置

source ~/.bashrc

或者通过设置alias简写来简化操作,每次要用的时候输入setproxy,不用了就unsetproxy。

alias setproxy="export ALL_PROXY=socks5://127.0.0.1:1080" alias unsetproxy="unset ALL_PROXY"

参考https://zhuanlan.zhihu.com/p/46973701

支付宝打赏微信打赏

如果此文对你有帮助,欢迎打赏作者。

发表评论

欢迎回来 (打开)

(必填)