当前位置:网站首页>LVS-DR模式多网段案例
LVS-DR模式多网段案例
2022-06-25 07:36:00 【wwzroom】
LVS-DR模式多网段案例
1.实验架构

原理补充:
路由器的eth0要配置两个ip,因为在不同的网段,rs和lvs的VIP和RIP不在同一网段,lo:VIP172.168.100/32必须是32位的,24位的不行,因为配置在回环网卡上,回环网卡是没有路由的,只要在同一网段,就能够连接,如果是24位的话,172.16.0.200和172.168.100在同一网段,就会在本地转圈,不能转发到172.16.0.200,因此必须要设置32位,这样没有同网段其他主机,就能够进行转发到172.16.0.200了,如果绑定在eth0上的话就不存在这个问题。
2.实验环境
环境:五台主机
一台:客户端 eth0:仅主机 192.168.10.6/24 GW:192.168.10.200
一台:ROUTER
eth0 :NAT 10.0.0.200/24 NAT 172.16.0.200/24
eth1: 仅主机 192.168.10.200/24
启用 IP_FORWARD
一台:LVS
eth0:NAT:DIP:10.0.0.8/24 GW:10.0.0.200
lo:VIP 172.16.0.100/32
两台RS:
RS1:eth0:NAT:10.0.0.7/24 GW:10.0.0.200
lo:VIP 172.16.0.100/32
RS2:eth0:NAT:10.0.0.17/24 GW:10.0.0.200
lo:VIP 172.16.0.100/32
3.后端RS1的IPVS配置
1.修改主机名
[[email protected]:~]#
hostnamectl set-hostname rs1.magedu.org && exit
2.安装httpd服务
[[email protected]:~]#
yum -y install httpd;echo rs1 `hostname -I` > /var/www/html/index.html;systemctl enable --now httpd
3.修改网关为10.0.0.200,dns用不上,可以删除
[[email protected]:~]#
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=10.0.0.7
PREFIX=24
GATEWAY=10.0.0.200
DNS1=10.0.0.2
DNS2=180.76.76.76
ONBOOT=yes
[[email protected]:~]#
systemctl restart network
4.绑定VIP到lo回环网卡,同时关掉lo回环网卡arp
[[email protected]:~]#
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[[email protected]:~]#
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
#总开关和具体的网卡开关都要关掉才行。
[[email protected]:~]#
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[[email protected]:~]#
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
5. 配置VIP地址
[[email protected]:~]#
cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-lo:1
[[email protected]:~]#
vim /etc/sysconfig/network-scripts/ifcfg-lo:1
DEVICE=lo:1
IPADDR=172.16.0.100
NETMASK=255.255.255.255
ONBOOT=yes
NAME=loopback1
[[email protected]:~]#
systemctl restart network
#临时配置方法,不需重启
ifconfig lo:1 10.0.0.100/32
4.后端RS2的IPVS配置
1.修改主机名
[[email protected]:~]#
hostnamectl set-hostname rs2.magedu.org && exit
2.安装httpd服务
[[email protected]:~]#
yum -y install httpd;echo rs1 `hostname -I` > /var/www/html/index.html;systemctl enable --now httpd
3.修改网关为10.0.0.200,dns用不上,可以删除
[[email protected]:~]#
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=10.0.0.17
PREFIX=24
GATEWAY=10.0.0.200
DNS1=10.0.0.2
DNS2=180.76.76.76
ONBOOT=yes
[[email protected]:~]#
systemctl restart network
4.绑定VIP到lo回环网卡,同时关掉lo回环网卡arp
[[email protected]:~]#
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[[email protected]:~]#
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
#总开关和具体的网卡开关都要关掉才行。
[[email protected]:~]#
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[[email protected]:~]#
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
5. 配置VIP地址
[[email protected]:~]#
vim /etc/sysconfig/network-scripts/ifcfg-lo:1
DEVICE=lo:1
IPADDR=172.16.0.100
NETMASK=255.255.255.255
ONBOOT=yes
NAME=loopback1
[[email protected]:~]#
systemctl restart network
#临时配置方法,不需重启
ifconfig lo:1 10.0.0.100/32
5.client客户端网络配置
1.修改网卡,必须要配置网关,因为要和rs直接建立连接。
[[email protected] ~]#vim /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses: [192.168.10.6/24]
gateway4: 192.168.10.200
nameservers:
search: [magedu.com, magedu.org]
addresses: [180.76.76.76, 8.8.8.8, 1.1.1.1]
[[email protected] ~]#netplan apply
[[email protected] ~]#route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.10.200 0.0.0.0 UG 0 0 0 eth0
192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
6.路由主机配置
1.vmware添加仅主机网卡,详细见下图
2.修改eth0网卡
[[email protected]:~]#
hostnamectl set-hostname route.magedu.org;exit
[[email protected]:~]#网关和dns解析用不上,可以删除。
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR1=10.0.0.200
PREFIX=24
IPADDR2=172.16.0.200
PREFIX=24
GATEWAY=10.0.0.2
DNS1=10.0.0.2
DNS2=180.76.76.76
ONBOOT=yes
3.配置eth1网卡
[[email protected]:~]#
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1
[[email protected]:~]#
vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
NAME=eth1
BOOTPROTO=static
IPADDR=192.168.10.200
PREFIX=24
GATEWAY=10.0.0.2
DNS1=10.0.0.2
DNS2=180.76.76.76
ONBOOT=yes
[[email protected]:~]#
nmcli con reload
[[email protected]:~]#
nmcli con
NAME UUID TYPE DEVICE
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0
eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 ethernet eth1
Wired connection 1 36a1faac-f944-3a4a-98d1-21929b079ddf ethernet --
4.重启网卡
[[email protected]:~]#
nmcli con up eth1#
#也可以删除Wired connection 1
[[email protected]:~]#
nmcli con delete Wired\ connection\ 1 #必须添加\
[[email protected]:~]#
nmcli con up eth0
5.开启转发功能
[[email protected]:~]#
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
[[email protected]:~]#
sysctl -p

7.LVS的网络配置
1.修改主机名
[[email protected]:~]#
hostnamectl set-hostname lvs.magedu.org && exit
2.安装相关包
[[email protected]:~]#
yum -y install ipvsadm
3.配置网络,网关和dns可以删除,因为不需要访问互联网。
[[email protected]:~]#
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
NAME=eth0
BOOTPROTO=static
IPADDR=10.0.0.8
PREFIX=24
GATEWAY=10.0.0.200
DNS1=10.0.0.2
DNS2=180.76.76.76
ONBOOT=yes
[[email protected]:~]#
nmcli con reload
[[email protected]:~]#
nmcli con up eth0
5.配置回环网卡ip,临时方法。
[[email protected]:~]#
ifconfig lo:1 10.0.0.100/32
#添加在lo网卡上一个地址(临时添加)
[[email protected]:~]#
ip a a 172.16.0.100/32 dev lo label lo:1 #lable 是添加标签
8.LVS主机配置lvs规则
1.添加规则,管理集群服务
[[email protected]:~]#
ipvsadm -A -t 172.16.0.100:80 -s wrr
2.添加规则,管理集群中的rs
[[email protected]:~]#
ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.7:80 -g -w 1
[[email protected]:~]#
ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.17:80 -g -w 1
[[email protected]:~]#
ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.16.0.100:80 wrr
-> 10.0.0.7:80 Route 1 0 0
-> 10.0.0.17:80 Route 1 0 0
9.client测试访问
1.访问检测
[[email protected] ~]#while :;do curl 172.16.0.100;sleep 1;done
rs2 10.0.0.17
rs1 10.0.0.7
rs2 10.0.0.17
边栏推荐
- QSS 不同风格的按钮
- 浏览器查看当前页面所有的监听事件
- Daily question brushing record (III)
- Sharepoint:sharepoint 2013 with SP1 easy installation
- Biweekly investment and financial report: capital ambush Web3 infrastructure
- Iframe is simple to use, iframe is obtained, iframe element value is obtained, and iframe information of parent page is obtained
- 在二叉树(搜索树)中找到两个节点的最近公共祖先(剑指offer)
- 想开个户,网上股票开户安不安全?
- Sharepoint:sharepoint server 2013 and adrms Integration Guide
- 钱堂教育商学院给的证券账户安全吗?能开户吗?
猜你喜欢

【操作教程】TSINGSEE青犀视频平台如何将旧数据库导入到新数据库?

城链科技平台,正在实现真正意义上的价值互联网重构!

How to calculate critical weight indicators?

Bluecmsv1.6-代码审计

View all listening events on the current page by browser

Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits

Unity addressable batch management

35岁腾讯员工被裁员感叹:北京一套房,存款700多万,失业好焦虑

各种同步学习笔记

软件测试月薪10K如何涨到30K,只有自动化测试能做到
随机推荐
Check whether the point is within the polygon
Data preprocessing: discrete feature coding method
How to analyze the grey prediction model?
After using the remote control of the working machine, problems occurred in the use of the local ROS, and the roscore did not respond
如何实现一个系统调用
UEFI:修复 EFI/GPT Bootloader
leetcode.13 --- 罗马数字转整数
SwipeRefreshLayout+RecyclerView无法下拉问题排查
家庭服务器门户Easy-Gate
Exchange: manage calendar permissions
以科技赋能设计之美,vivo携手知名美院打造“产学研”计划
4 raisons inconnues d'utiliser le "déplacement sûr à gauche"
Is it safe to open an account for stocks on the Internet? Can the securities account be used by others?
How is the ISM model analyzed?
打新债安不安全 有风险吗
Data-centric vs. Model-centric. The Answer is Clear!
在网上股票开户安全吗?证券账户可以给别人用吗?
How to calculate the fuzzy comprehensive evaluation index? How to calculate the four fuzzy operators?
NIPS 2014 | Two-Stream Convolutional Networks for Action Recognition in Videos 阅读笔记
在二叉树(搜索树)中找到两个节点的最近公共祖先(剑指offer)