LVS的nat模式
创始人
2024-11-06 06:10:07
0

目录

一.实验环境

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

1.调度器(VS)

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

2.真实服务器(RS)

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

3.客户端

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;

二.实验配置

1.VS中打开内核路由器功能

[root@LVS boot]# echo "net.ipv4.ip_forward=1" > /etc/sysctl.conf

[root@LVS boot]# sysctl -p net.ipv4.ip_forward = 1

2.RS装上http服务

[root@LVS ~]# yum install httpd -y

3.VS安装LVS软件

[root@LVS boot]# dnf install ipvsadm -y

4.在RS上输入测试内容

[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

5.在VS进行测试

[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

6.在VS中添加调度策略

[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

相关内容

热门资讯

八分钟了解!newpoker怎... 八分钟了解!newpoker怎么安装脚本,哈糖大菠萝能开挂吗,指南书教程(有挂分析)1、哈糖大菠萝能...
方案辅助!微信小程序微乐破解器... 方案辅助!微信小程序微乐破解器2024!解谜真的是有辅助教程(有挂细节)1、进入到微信小程序微乐破解...
第9分钟了解!德普之星有辅助软... 第9分钟了解!德普之星有辅助软件吗,德州局透视脚本,步骤教程(有挂神器)运德普之星有辅助软件吗辅助工...
窍要辅助!洞庭茶苑app辅助!... 窍要辅助!洞庭茶苑app辅助!关于存在有辅助神器(有挂辅助)1.洞庭茶苑app辅助 选牌创建新账号,...
七分钟了解!wepoker怎么... 七分钟了解!wepoker怎么开辅助,wepoker透视脚本免费app,绝活儿教程(有挂细节)1、w...
窍要辅助!嘟咪互动有挂吗!开挂... 窍要辅助!嘟咪互动有挂吗!开挂是有辅助软件(有挂总结)窍要辅助!嘟咪互动有挂吗!开挂是有辅助软件(有...
1分钟了解!wepoker辅助... 1分钟了解!wepoker辅助器最新版本更新内容,德普之星私人局辅助免费,办法教程(有挂辅助)wep...
大纲辅助!心悦海南苹果版辅助器... 大纲辅助!心悦海南苹果版辅助器!关于是有辅助工具(有挂攻略)1、玩家可以在心悦海南苹果版辅助器线上大...
指南辅助!小程序广东雀神智能插... 指南辅助!小程序广东雀神智能插件安装下载!解谜真的是有辅助技巧(新版有挂)运小程序广东雀神智能插件安...
第九分钟了解!wepoker作... 第九分钟了解!wepoker作弊辅助,wpk辅助购买,步骤教程(新版有挂)1、完成wepoker作弊...