Linux 网络代理设置

刚开始没有弄清楚 [~/.bashrc] [/etc/profile] [~/.bash_profile]文件的优先级及作用所以设置代理的时候每个文件都添加了代理.所以设置代理之前可以参考(https://blog.csdn.net/u013968345/article/details/21262033)了解不同文件的作用及优先级,这里截取了一部分内容做参考


/etc/profile , /etc/bashrc

是系统全局环境变量设定

~/.profile , ~/.bashrc

用户家目录下的私有环境变量设定

当登入系统时候获得一个shell进程时,其读取环境设定档有三步

  • 1.首先读入的是全局环境变量设定档/etc/profile,然后根据其内容读取额外的设定的文档,如 /etc/profile.d和/etc/inputrc
  • 2.然后根据不同使用者帐号,去其家目录读取 ~/.bash_profile 如果这读取不了就读取 ~/.bash_login,这个也读取不了才会读取 ~/.profile,这三个文档设定基本上是一样的,读取有优先关系
  • 3.然后在根据用户帐号读取 ~/.bashrc 至于 ~ /.profile 与 ~/.bashrc * 的不区别都具有个性化定制功能 ~/.profile 可以设定本用户专有的路径,环境变量,等,它只能登入的时候执行一次 ~/.bashrc也是某用户专有设定文档,可以设定路径,命令别名,每次shell script的执行都会使用它一次
    Centos 7

vim /etc/yum.conf

export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
export ftp_proxy=http://IP:PORT

vim /etc/wgetrc

export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
export ftp_proxy=http://IP:PORT

vim /etc/profile

export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
export ftp_proxy=http://IP:PORT

Ubuntu 18.04

vim /etc/profile

export ftp_proxy=http://IP:PORT
export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
export all_proxy=http://IP:PORT

vim /etc/wgetrc

export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
export ftp_proxy=http://IP:PORT

vim /etc/yum/yum.conf

export http_proxy=http://IP:PORT
export https_proxy=http://IP:PORT
export ftp_proxy=http://IP:PORT

docker

vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://IP:PORT/" "HTTPS_PROXY=http://IP:PORT/" "NO_PROXY=localhost,127.0.0.1,10.132.*,docker-registry.somecorporation.com"~            

你可能感兴趣的:(运维)