ubuntu设置系统代理

安装trojan等代理工具并配置启动,得到端口号

例如

10.10.1.10:8080

系统代理设置

我们将在/etc/profile.d/proxy.sh下添加一个shell脚本文件,这将确保设置适用于所有已登录的用户:

sudo vim  /etc/profile.d/proxy.sh

 

将以下内容写到文档中:

 # set proxy config via profie.d - should apply for all users
export http_proxy="http://10.10.1.10:8080/"
export https_proxy="http://10.10.1.10:8080/"
export ftp_proxy="http://10.10.1.10:8080/"
export no_proxy="127.0.0.1,localhost"
# For curl
export HTTP_PROXY="http://10.10.1.10:8080/"
export HTTPS_PROXY="http://10.10.1.10:8080/"
export FTP_PROXY="http://10.10.1.10:8080/"
export NO_PROXY="127.0.0.1,localhost"
#将要从代理中排除的其他IP添加到NO_PROXY和no_proxy环境变量中

 

 

为该文件填加执行权限:

sudo chmod +x  /etc/profile.d/proxy.sh

 

激活文件以开始使用代理设置,或者注销并重新登录:

source /etc/profile.d/proxy.sh
#查看环境变量进行确认是否生效
env | grep -i proxy

 

清除代理

unset http_proxy

unset https_proxy

unset HTTP_PROXY

unset HTTPS_PROXY

 

posted @ 2023-08-24 16:15  然然1907  阅读(178)  评论(0编辑  收藏  举报