centos7 搭建基于局域网http服务的yum源

bioamin在之前写过一篇文章,主要用于redhat系统在有外网情况下,使用外网yum源。

redhat7.3安装yum源 基于外网的http服务

https://www.cnblogs.com/students/p/9646247.html

安全月开始后,外网无法访问,本文主要记录安装局域网环境yum源;

1.背景描述

服务器没有外网
环境 centos7.3
已经关闭了防火墙和selinux
已经安装了httpd服务

2.方案

先通过本地搭建一个可以上网的虚拟机,然后将rpm包进行下载,然后上传服务器制作yum源

3.1下载rpm包

这里是中科大的镜像源,由于虚拟机dns解析有问题,采用了ip访问。将所有的rpm包进行下载。这里总计有10019个rpm包,

rsync -av rsync://202.141.176.110/centos/7/os/x86_64/Packages/ /centos

tar centos.tar.gz /centos

3.2将rpm包上传服务器,制作yum源

cd /home/yum_local/data
tar -xzvf centos.tar.gz
#使用createrepo命令制作yum源,这里在centos目录下会生成一个repodata目录
createrepo centos/

3.3开启httpd服务(我这里无法启动,检测80端口被占用,修改端口为8081)

vim /etc/httpd/conf/httpd.conf
#Listen 80
Listen 8081


systemctl start httpd
systemctl enable  httpd

 

4.局域网内的客户端配置

vi  /etc/yum.repos.d/http.repo

[base]
name = "Centost7 HTTP YUM"
baseurl = http://172.2.10.205:8081/centos/
gpgcheck = 0
enabled = 1
[updates]
name = "Centost7 HTTP YUM"
baseurl = http://172.2.100.205:8081/centos/
gpgcheck = 0
enabled = 1

5.服务端yum源更新

执行yum源更新命令
将rpm包放到目录内,执行yum更新命令
createrepo  --update centos/

 

posted @ 2019-08-16 11:11  bioamin  阅读(2651)  评论(0编辑  收藏  举报