创建镜像服务器
-
软件安装:
yum -y install createrepo
yum –install httpd
yum install rsync
-
启动服务
/etc/init.d/httpd start
创建路径
mkdir -pv /var/www/html/centos/6.8/os/x86_64/
-
同步仓库
rsync rsync://mirrors.kernel.org/centos/6.8/os/x86_64/ /var/www/html/centos/6.8/os/x86_64/
rsync –list-only rsync://sjtu.edu.cn/centos/6.8/os/x86_64/
rsync -avz rsync://mirrors.kernel.org/centos/6.8/os/x86_64/ /var/www/html/centos/6.8/os/x86_64/
rsync -avz rsync://mirrors.yun-idc.com/centos/6.8/os/x86_64/ /var/www/html/centos/6.8/os/x86_64/
-
关闭防火墙
/etc/init.d/iptables stop
-
关闭sellinux
setenforce 0
-
配置防火墙及nat
Iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -o eth0 -j MASQUERADE
rsync://mirrors.kernel.org/centos/7.3.1611/os/x86_64/ /var/www/html/ centos/7.3.1611/os/x86_64/
rsync –avz /centos/7.3.1611/os/x86_64/ /var/www/html/centos/7.3.1611/os/x86_64/
Code:
iptables -t nat -A POSTROUTING -s 172.16.31.0/24 -o eth1 -j MASQUERADE
-s 表示源网络,即内网地址;-o 为连接因特网的接口
如果主机上启用了防火墙,需加上下面两句:
Code:
iptables -A FORWARD -s 172.16.31.0/24 -o eth1 -j ACCEPT
iptables -A FORWARD -d 172.16.31.0/24 -m state –state ESTABLISHED,RELATED -i eth1 -j ACCEPT
分别表示:来自内网、出口为eth0的包接受转发;来自eth0、目标地址为内网,且连接状态为建立、相关的包接受转发.
rsync -a /media/cdrom/ /var/www/html/centos/5.11/os/x86_64
centos/5.11/os/x86_64
rsync -avz rsync:/ /sjtu.edu.cn /centos/5.11/os/x86_64/ /var/www/html/centos/5.11/os/x86_64/ –exclude=repodata