目录
一.实验环境
1.调度器(VS)
2.真实服务器(RS)
3.客户端
二.实验配置
1.VS中打开内核路由器功能
2.RS装上http服务
3.VS安装LVS软件
4.在RS上输入测试内容
5.在VS进行测试
6.在VS中添加调度策略
三.客户端测试

一台客户机、一台调度器、两台真实服务器
VMVare网络设置NAT模式子网IP为172.25.254.0,仅主机模式子网IP为192.168.0.0
VMVare设置eth0网卡为NAT模式,eth1为仅主机模式
[root@LVS ~]# cat /etc/NetworkManager/system-connections/eth0.nmconnection [connection] id=eth0 type=ethernet interface-namw=eth0 [ipv4] address1=172.25.254.100/24,172.25.254.2 method=manual dns=114.114.114.114; [root@LVS ~]# cat /etc/NetworkManager/system-connections/eth1.nmconnection [connection] id=eth1 type=ethernet interface-namw=eth1 [ipv4] address1=192.168.0.100/24 method=manual VMVare设置eth0网卡为仅主机模式
[root@webserver1 ~]# cat /etc/NetworkManager/system-connections/eth0.nmconnection [connection] id=eth0 type=ethernet interface-namw=eth0 [ipv4] address1=192.168.0.10/24,192.168.0.100 method=manual [root@webserver2 ~]# cat /etc/NetworkManager/system-connections/eth0.nmconnection [connection] id=eth0 type=ethernet interface-namw=eth0 [ipv4] address1=192.168.0.20/24,192.168.0.100 method=manual VMVare设置eth0网卡为NAT模式
[root@client ~]# cat /etc/NetworkManager/system-connections/eth0.nmconnection [connection] id=eth0 type=ethernet interface-namw=eth0 [ipv4] address1=172.25.254.200/24,172.25.254.2 method=manual dns=114.114.114.114; [root@LVS boot]# echo "net.ipv4.ip_forward=1" > /etc/sysctl.conf 
[root@LVS boot]# sysctl -p net.ipv4.ip_forward = 1 [root@LVS ~]# yum install httpd -y [root@LVS boot]# dnf install ipvsadm -y [root@webserver1 ~]# echo webserver1 - 192.168.0.10 > /var/www/html/index.html [root@webserver1 ~]# systemctl enable --now httpd [root@webserver2 ~]# echo webserver2 - 192.168.0.20 > /var/www/html/index.html [root@webserver2 ~]# systemctl enable --now httpd [root@LVS boot]# curl 192.168.0.10 webserver1 - 192.168.0.10 [root@LVS boot]# curl 192.168.0.20 webserver2 - 192.168.0.20 [root@LVS boot]# ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn [root@LVS boot]# ipvsadm -A -t 172.25.254.100:80 -s rr [root@LVS boot]# ipvsadm -a -t 172.25.254.100:80 -r 192.168.0.10:80 -m [root@LVS boot]# ipvsadm -a -t 172.25.254.100:80 -r 192.168.0.20:80 -m [root@LVS boot]# ipvsadm -Ln IP Virtual Server version 1.2.1 (size=4096) Prot LocalAddress:Port Scheduler Flags -> RemoteAddress:Port Forward Weight ActiveConn InActConn TCP 172.25.254.100:80 rr -> 192.168.0.10:80 Masq 1 0 0 -> 192.168.0.20:80 Masq 1 0 0 [root@client ~]# for i in {1..10} > do > curl 172.25.254.100 > done webserver2 - 192.168.0.20 webserver1 - 192.168.0.10 webserver2 - 192.168.0.20 webserver1 - 192.168.0.10 webserver2 - 192.168.0.20 webserver1 - 192.168.0.10 webserver2 - 192.168.0.20 webserver1 - 192.168.0.10 webserver2 - 192.168.0.20 webserver1 - 192.168.0.10