本地有两台主机,分别为:192.168.2.131/24和192.168.2.132/24,本地yum源只能连接互联网;
这两台设备的虚拟机配置如下:
现有一台主机:172.16.254.88/16可连接互联网,如何完成上面两台主机的yum里包的安装!
#首先测试192.168.2.131和132是不是可以通信; [root@~ pxe99]#ping 192.168.2.131 PING 192.168.2.131 (192.168.2.131) 56(84) bytes of data. 64 bytes from 192.168.2.131: icmp_seq=1 ttl=64 time=9.68 ms 64 bytes from 192.168.2.131: icmp_seq=2 ttl=64 time=1.75 ms ^C --- 192.168.2.131 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms rtt min/avg/max/mdev = 1.752/5.716/9.680/3.964 ms [root@~ localhost]#route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736 #添加172那台主机的路由 [root@~ localhost]#route add -net default gw 192.168.2.133 [root@~ localhost]#route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.2.133 0.0.0.0 UG 0 0 0 eno16777736 192.168.2.0 0.0.0.0 255.255.255.0 U 100 0 0 eno16777736 [root@~ localhost]#ping 192.168.2.133 PING 192.168.2.133 (192.168.2.133) 56(84) bytes of data. 64 bytes from 192.168.2.133: icmp_seq=1 ttl=64 time=13.7 ms 64 bytes from 192.168.2.133: icmp_seq=2 ttl=64 time=4.89 ms ^C --- 192.168.2.133 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1008ms rtt min/avg/max/mdev = 4.898/9.310/13.723/4.413 ms [root@~ localhost]#ping 172.16.254.88 PING 172.16.254.88 (172.16.254.88) 56(84) bytes of data. 64 bytes from 172.16.254.88: icmp_seq=1 ttl=64 time=25.2 ms 64 bytes from 172.16.254.88: icmp_seq=2 ttl=64 time=2.47 ms ^C --- 172.16.254.88 ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 1002ms rtt min/avg/max/mdev = 2.472/13.847/25.223/11.376 ms #得知可以连同;另一台131也这么配置
#在主机172上添加IPtables的nat策略 [root@~ localhost]#iptables -F [root@~ localhost]#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j SNAT --to-source 172.16.254.88 #在192主机开始安装 [root@~ pxe99]#yum -y install httpd telnet-server tftp-server