需求解决
- 某公司业务生产环境下没有网络环境,无法使用yum源进行更新
准备环境
- 一台可以上网的
Windows
主机
Clash for Windows
下载地址
使用方法
1.0 打开Clash for windows设置
Port
: 监听端口
Allow LAN
: 开启监听LAN网卡(点击开启)
Log Level
: 日志等级
其他的就不多介绍了,反正你只需要开启Allow LAN
即可
鼠标悬浮在Allow LAN
上即可看到你的以太网IP地址
- 例如:假如我的以太网IP地址为
192.168.1.10

1.1 yum配置
这里以Centos7-Base
源为例
[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
proxy=http://192.168.1.10:7890 # 写你的以太网IP+Clash监听的端口
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
proxy=http://192.168.1.10:7890
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
proxy=http://192.168.1.10:7890
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
proxy=http://192.168.1.10:7890
1.2 Linux服务器配置
export http_proxy=192.168.1.10:7890
export https_proxy=192.168.1.10:7890
如果你想要永久的对其生效,请将它写到初始化环境变量当中:
echo "http_proxy=192.168.1.10:7890" >> /etc/profile
source /etc/profile
1.3 最后查看请求日志
当你配置完成以上内容的时候,请务必执行一下yum makecache
来探测一下yum是否可以正常连入外网。
你应当查看Clash for windows
当中会有请求日志,由于客户IP私密性就不粘贴日志了.
