[root@lss ~]# vi nat.sh
#!/bin/bash
echo "1" > /proc/sys/net/ipv4/ip_forward
ipvsadm -C
ipvsadm -A -t 192.168.90.100:80 -s rr
ipvsadm -a -t 192.168.90.100:80 -r 192.168.80.102:80 -m
ipvsadm -a -t 192.168.90.100:80 -r 192.168.80.101:80 -m
ipvsadm -Ln
[root@lss ~]# sh nat.sh
192.168.80.101服务器:
Vmnet1内网:192.168.80.101
网关:192.168.80.100
[root@lss01 ~]# yum install -y httpd
[root@lss01 ~]# vi /etc/httpd/conf/httpd.conf
ServerName www.aa.com
[root@lss01 ~]# vi /var/www/html/index.html
<h1>Server aa </h1>
[root@lss01 ~]# service httpd restart
[root@lss01 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
GATEWAY=192.168.80.100
[root@lss01 ~]# service network restart
192.168.80.102服务器:
Vmnet1内网:192.168.80.102
网关:192.168.80.100
[root@lss02 ~]# yum install -y httpd
[root@lss02 ~]# vi /etc/httpd/conf/httpd.conf
ServerName www.bb.com
[root@lss02 ~]# vi /var/www/html/index.html
<h1>Server bb </h1>
[root@lss02 ~]# service httpd restart
[root@lss02 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
GATEWAY=192.168.80.100
[root@lss02 ~]# service network restart
真机浏览器测试:
Vmnet1:192.168.80.88
Vmnet2:192.168.90.88
原文地址:http://blog.51cto.com/13572519/2084181