linux 配置dns及代理

简介

对于新装的环境,可能无法访问外网,此时需要设置代理或DNS实现访问。
类似wget、yum、pip这类命令都需要通过网络进行下载。

配置dns服务

在/etc/resolv.conf中添加如下两行:

nameserver 8.8.8.8
nameserver 8.8.4.4

service network start

设置代理

export http_proxy=http://{user}:{password}@xxxproxy.com:8080/
export https_proxy=http://{user}:{password}@xxxproxy.com:8080/
export ftp_proxy=http://{user}:{password}@xxxproxy.com:8080/

注意密码中的@符号需要url转义为%40

修改/etc/sysconfig/proxy,使其永久生效

PROXY_ENABLED="yes"
HTTP_PROXY=http://{user}:{password}@xxxproxy.com:8080/
HTTPS_PROXY=http://{user}:{password}@xxxproxy.com:8080/
FTP_PROXY=http://{user}:{password}@xxxproxy.com:8080/
posted @ 2018-05-30 10:40  美码师  阅读(2884)  评论(0编辑  收藏  举报