前言
提示:需要安装rinetd代理工具与yum源设置
| 内网服务器 | 192.168.23.121 | 通过rinted代理访问yum源 |
|---|---|---|
| 公网服务器 | 192.168.23.99 | 端口转发代理,可访问外网 |
内网服务器通过公网服务代理转发使用yum源。
一、国内yum源
网易163 yum源:http://mirrors.163.com/.help/
中科大的 yum源:https://lug.ustc.edu.cn/wiki/mirrors/help
sohu的 yum源: http://mirrors.sohu.com/help/
阿里云的 yum源: https://opsx.alibaba.com/mirror
清华大学的 yum源: https://mirrors.tuna.tsinghua.edu.cn/
浙江大学的 yum源: http://mirrors.zju.edu.cn/
中国科技大学yum源: http://centos.ustc.edu.cn/
一、公网服务器rinted代理安装
确认有没有安装 gcc 和 gcc-c++
rpm -qa | grep gcc
rpm -qa | grep gcc-c++
yum install gcc gcc-c++
解压安装
tar zxvf rinetd.tar.gz
mkdir -p /usr/man/man8
make
make install
二、公网服务器rinted使用说明
说明一下(0.0.0.0表示本机绑定所有可用地址)
将所有发往本机8080端口的请求转发到172.19.94.3的8080端口
将所有发往本机2222端口的请求转发到192.168.0.103的3389端口
将所有发往1.2.3.4的80端口请求转发到192.168.0.10的80端口
命令格式是
绑定的地址 绑定的端口 连接的地址 连接的端口
或
源地址 源端口 目的地址 目的端口
1.rinted编辑配置
vi /etc/rinetd.conf
0.0.0.0 99 mirrors.163.com 80 //以使用网易163yum源为例,99是本机99端口,80是目的端口
2.启动程序
pkill rinetd ##关闭进程
rinetd -c /etc/rinetd.conf ##启动转发
echo "rinetd -c /etc/rinetd.conf" >> /etc/rc.local ##开机自启
netstat -antup | grep rinetd ##确认服务开启
3.需要注意
1.rinetd.conf中绑定的本机端口必须没有被其它程序占用
2.运行rinetd的系统防火墙应该打开绑定的本机端口,或者关闭iptables
例如:
-A INPUT -s 124.207.115.68/32 -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -s 124.207.115.68/32 -p tcp -m tcp --dport 3306 -j ACCEPT
-A INPUT -s 124.207.115.68/32 -p tcp -m tcp --dport 80 -j ACCEPT
三、内网服务器yum源设置
1.先备份源yum源
cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2.植入网易163yum源
vim /etc/yum.repos.d/CentOS-Base.repo
[base]
name=CentOS-$releasever - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
四、修改内网服务的hosts
cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.23.99 99 mirrors.163.com // 通过访问公网服务器99端口来访问yum源
五、内网服务器验证yum源是否正常
1.ping 通mirrors.163.com
[root@localhost localhost]# ping mirrors.163.com
PING 99 (192.168.23.99) 56(84) bytes of data.
64 bytes from 99 (192.168.23.99): icmp_seq=1 ttl=64 time=0.113 ms
64 bytes from 99 (192.168.23.99): icmp_seq=2 ttl=64 time=0.171 ms
2.yum源正常使用
[root@localhost localhost]# yum install pam-devel -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package pam-devel.x86_64 0:1.1.8-23.el7 will be installed
--> Processing Dependency: pam(x86-64) = 1.1.8-23.el7 for package: pam-devel-1.1.8-23.el7.x86_64
--> Running transaction check
---> Package pam.x86_64 0:1.1.8-18.el7 will be updated
---> Package pam.x86_64 0:1.1.8-23.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================
Package Arch Version Repository Size
============================================================================================================================================================================
Installing:
pam-devel x86_64 1.1.8-23.el7 base 185 k
Updating for dependencies:
pam x86_64 1.1.8-23.el7 base 721 k
Transaction Summary
============================================================================================================================================================================
Install 1 Package
Upgrade ( 1 Dependent package)
Total download size: 905 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/2): pam-devel-1.1.8-23.el7.x86_64.rpm | 185 kB 00:00:01
(2/2): pam-1.1.8-23.el7.x86_64.rpm | 721 kB 00:00:03
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 231 kB/s | 905 kB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : pam-1.1.8-23.el7.x86_64 1/3
Installing : pam-devel-1.1.8-23.el7.x86_64 2/3
Cleanup : pam-1.1.8-18.el7.x86_64 3/3
Verifying : pam-1.1.8-23.el7.x86_64 1/3
Verifying : pam-devel-1.1.8-23.el7.x86_64 2/3
Verifying : pam-1.1.8-18.el7.x86_64 3/3
Installed:
pam-devel.x86_64 0:1.1.8-23.el7
Dependency Updated:
pam.x86_64 0:1.1.8-23.el7
Complete!
总结
注意rinted代理的使用和yum源的设置
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




