这里我直接列出方法吧:
第一步是你的有一个socket5的服务器并且可以正常使用。
然后你可以在本地linux系统或者mac系统中打开一个shell终端,然后根据情况输入以下指令:
在写命令之前我先说一下代理有密码和没密码的区别写法吧。
无密码的写法基本都是代理IP:端口
有密码的写法是:代理用户名:代理密码@代理IP:代理端口
好了下面来讲一下都有哪些代理方式
只设置http代理
格式:export http_proxy=socks5://代理IP:代理端口
案例:
无用户验证: export http_proxy= socks5://114.114.114.114:1080 有用户验证: export http_proxy= socks5://www:32e@114.114.114.114:1080设置https代理
格式:export HTTPS_PROXY=socks5://代理IP:代理端口
案例:
无用户验证: export HTTPS_PROXY= socks5://114.114.114.114:1080 有用户验证: export HTTPS_PROXY= socks5://www:32e@114.114.114.114:1080设置ftp代理
格式:export FTP_PROXY=socks5://代理IP:代理端口
案例:
无用户验证: export FTP_PROXY= socks5://114.114.114.114:1080 有用户验证: export FTP_PROXY= socks5://www:32e@114.114.114.114:1080同时设置http、https以及ftp代理
格式:export ALL_PROXY=socks5://代理IP:代理端口
案例:
无用户验证: export ALL_PROXY= socks5://114.114.114.114:1080 有用户验证: export ALL_PROXY= socks5://www:32e@114.114.114.114:1080
如果要取消设置可以使用unset
比如:
unset ALL_PROXY unset http_proxy unset https_proxyPS:这些设置在重启系统后就会失效。
如果想一直有效可以写入文件:
$ vi ~/.bashrc内容:
# set proxy function setproxy() { export http_proxy=socks5://127.0.0.1:1080 export HTTPS_PROXY=socks5://127.0.0.1:1080 export FTP_PROXY=socks5://127.0.0.1:1080 } # unset proxy function unsetproxy() { unset http_proxy HTTPS_PROXY FTP_PROXY }
然后保存退出
然后我们来使配置立刻生效:
source ~/.bashrc然后我们在终端中输入:
# 设置代理 setproxy # 取消代理 unsetproxy这样就可以随时进行代理和取消了。是不是很方便呢!
除特别注明外,本站所有文章均为博文家原创,转载请注明出处来自https://www.32e.top/services/linux/article-78.html
暂无评论