美文网首页
createrepo创建本地yum镜像源

createrepo创建本地yum镜像源

作者: 北二条 | 来源:发表于2019-05-27 16:49 被阅读0次

简介

目前我们系统中大部分是内网的环境,无法访问外网,自己的pc可以访问外网,也能访问内网的环境,多以大部分时间需要搭建一个内网的yum源,但是呢由于内网环境网速被限制,或者不想重复搭建yum源,所以我想着在本地PC上搭建一个yum源供内网自己所有的虚机来使用。

createrepo创建本地yum镜像源

幸亏有createrepo这个强大的命令,省了我很多事情。
首先httpd服务:

yum install httpd
systemctl enable httpd
systemctl start httpd

首先我提前准备好了我常用的所有rpm,放在httpd的资源目录的如下四个目录里:

# cd /var/www/html/ocp
# tree
├── ansible
│   ├── Packages
├── extras
│   ├── Packages
├── ose
│   ├── Packages
└── rpms
    ├── Packages

[root@localhost ocp]# createrepo /var/www/html/ocp/ansible/
[root@localhost ocp]# createrepo /var/www/html/ocp/rpms/
[root@localhost ocp]# createrepo /var/www/html/ocp/ose/
[root@localhost ocp]# createrepo /var/www/html/ocp/extras/

ssh做内网穿透

ssh的隧道真的简直不能再好用,本来打算写代码,要几天实现的东西,竟然ssh一条命令就搞定了,这是我万般推崇的ssh:

ssh -gNR *:9090:192.168.88.18:80 root@172.18.141.128

# -g      Allows remote hosts to connect to local forwarded ports. 
# -N      Do not execute a remote command.  This is useful for just forwarding ports.
# -R      remote_socket:local_socket 和我们之前用的-L恰恰相反

此命令的意思为,把远端172.18.141.128的9090端口,映射到本机192.168.88.18的80端口,以远端机器172.18.141.128为跳板。

我本来思考着,自己写代码,在本地起一个socket client,内网虚机起一个socket server,然后配置内网虚机的所有web请求转发到socket client,通过socket client这种反向代理来实现访问外网的需求,现在不用写了,直接用ssh的隧道应该就可以完成了。

后记

遇到问题,遇到remote-serve总bind loop-back端口的问题,查了一下-R参数,觉得没问题啊:

netstat -apn|grep 9090
tcp        0      0 127.0.0.1:9090          0.0.0.0:*               LISTEN      5833/sshd: root     
tcp6       0      0 ::1:9090                :::*                    LISTEN      5833/sshd: roo

ssh参数文档:

By default, TCP listening sockets on the server 
will be bound to the loopback interface only.  
This may be overridden by specifying a bind_address.  
An empty bind_address, or the address ‘*’, 
indicates that the remote socket should listen on all interfaces.  
Specifying a remote bind_address will only succeed if the server's GatewayPorts option is enabled (see sshd_config(5)).

奥,恍然大悟,原来要开启ssh_config的一个参数GatewayPorts = yes
在remote-server上更改,然后systemctl restart sshd重启ssh服务,大功告成。

相关文章

网友评论

      本文标题:createrepo创建本地yum镜像源

      本文链接:https://www.haomeiwen.com/subject/trghtctx.html