Centos7 下代理配置

对于提供服务的服务器来说,一般都配置在内网环境中,而在内网下公司处于安全的考虑,一般不开放外网的访问权限。这时如果想要访问外网,一般需要配置公司提供的代理服务器再进行使用。下面介绍几种配置代理的方法:

 

添加代理

方式一:在 /etc/environment 下进行配置

在 /etc/environment 添加代理服务的内容:

# 通过自己搭建账号密码的代理服务器
http_proxy="http://username:password@proxysrv:8080/"
https_proxy="https://username:password@proxysrv:8080/"
ftp_proxy="ftp://username:password@proxysrv:8080/"
no_proxy=".mylan.local,.domain1.com,host1,host2" # 通过公司提供 export http_proxy=http://proxy.esl.cisco.com:80/ export https_proxy=https://proxy.esl.cisco.com:80/ ftp_proxy=https://proxy.esl.cisco.com:80/ export http_proxy export https_proxy export ftp_proxy 

方式二: /etc/profile 下添加:

export http_proxy=http://proxy.esl.cisco.com:80/
export https_proxy=https://proxy.esl.cisco.com:80/
ftp_proxy=https://proxy.esl.cisco.com:80/
export http_proxy
export https_proxy
export ftp_proxy

方式三:在~/.bash_profile文件中添加,只对当前用户有效:

# ~/.bash_profile
export http_proxy=http://proxy.esl.cisco.com:80/
export https_proxy=https://proxy.esl.cisco.com:80/

在配置后使用 source 命令对应,执行source ~/.bash_profile后生效

查询配置的代理

env | grep -i proxy

临时删除代理

unset http_proxy
unset https_proxy
unset ftp_proxy
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值