当前位置:网站首页>Lvs-dr mode multi segment case
Lvs-dr mode multi segment case
2022-06-25 08:42:00 【wwzroom】
LVS-DR Mode multi segment case
1. Experimental framework

Principle supplement :
The router eth0 To configure two ip, Because in different network segments ,rs and lvs Of VIP and RIP Not in the same network segment ,lo:VIP172.168.100/32 Must be 32 Bit ,24 No, I can't , Because it is configured on the loopback network card , The loopback network card has no route , As long as they are in the same network segment , To be able to connect , If it is 24 A word of ,172.16.0.200 and 172.168.100 In the same segment , Will be in the local circle , Cannot forward to 172.16.0.200, Therefore, you must set 32 position , There are no other hosts in the same network segment , Can be forwarded to 172.16.0.200 了 , If bound to eth0 There is no such problem .
2. Experimental environment
Environmental Science : Five hosts
a : client eth0: Host only 192.168.10.6/24 GW:192.168.10.200
a :ROUTER
eth0 :NAT 10.0.0.200/24 NAT 172.16.0.200/24
eth1: Host only 192.168.10.200/24
Enable IP_FORWARD
a :LVS
eth0:NAT:DIP:10.0.0.8/24 GW:10.0.0.200
lo:VIP 172.16.0.100/32
Two sets of 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. Back end RS1 Of IPVS To configure
1. Modify hostname
[[email protected]:~]#
hostnamectl set-hostname rs1.magedu.org && exit
2. install httpd service
[[email protected]:~]#
yum -y install httpd;echo rs1 `hostname -I` > /var/www/html/index.html;systemctl enable --now httpd
3. Modify the gateway to 10.0.0.200,dns It will not be on , You can delete
[[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. binding VIP To lo Looback adaptor , Turn it off at the same time lo Looback adaptor 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
# Turn off the main switch and the specific network card switch .
[[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. To configure VIP Address
[[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
# Temporary configuration method , No need to restart
ifconfig lo:1 10.0.0.100/32
4. Back end RS2 Of IPVS To configure
1. Modify hostname
[[email protected]:~]#
hostnamectl set-hostname rs2.magedu.org && exit
2. install httpd service
[[email protected]:~]#
yum -y install httpd;echo rs1 `hostname -I` > /var/www/html/index.html;systemctl enable --now httpd
3. Modify the gateway to 10.0.0.200,dns It will not be on , You can delete
[[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. binding VIP To lo Looback adaptor , Turn it off at the same time lo Looback adaptor 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
# Turn off the main switch and the specific network card switch .
[[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. To configure VIP Address
[[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
# Temporary configuration method , No need to restart
ifconfig lo:1 10.0.0.100/32
5.client Client network configuration
1. Modify NIC , The gateway must be configured , Because I want to be with rs Establish a connection directly .
[[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. Routing host configuration
1.vmware Add host only network card , See the figure below for details.
2. modify eth0 network card
[[email protected]:~]#
hostnamectl set-hostname route.magedu.org;exit
[[email protected]:~]# Gateway and dns Not available for parsing , You can delete .
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. To configure eth1 network card
[[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. Restart NIC
[[email protected]:~]#
nmcli con up eth1#
# It can also be deleted Wired connection 1
[[email protected]:~]#
nmcli con delete Wired\ connection\ 1 # You must add \
[[email protected]:~]#
nmcli con up eth0
5. Turn on forwarding
[[email protected]:~]#
vim /etc/sysctl.conf
net.ipv4.ip_forward=1
[[email protected]:~]#
sysctl -p

7.LVS Network configuration
1. Modify hostname
[[email protected]:~]#
hostnamectl set-hostname lvs.magedu.org && exit
2. Install related packages
[[email protected]:~]#
yum -y install ipvsadm
3. configure network , Gateway and dns You can delete , Because there is no need to access the Internet .
[[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. Configure loopback network card ip, Temporary method .
[[email protected]:~]#
ifconfig lo:1 10.0.0.100/32
# Add in lo The last address on the network card ( Temporarily add )
[[email protected]:~]#
ip a a 172.16.0.100/32 dev lo label lo:1 #lable Is to add labels
8.LVS Host configuration lvs The rules
1. Add rules , Manage cluster services
[[email protected]:~]#
ipvsadm -A -t 172.16.0.100:80 -s wrr
2. Add rules , Manage... In the cluster 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 Test access
1. Access detection
[[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
边栏推荐
- How to calculate the independence weight index?
- 各种同步学习笔记
- How to calculate the characteristic vector, weight value, CI value and other indicators in AHP?
- 如何实现一个系统调用
- [summary] 1361- package JSON and package lock JSON relationship
- SwipeRefreshLayout+RecyclerView无法下拉问题排查
- Stimulsoft ultimate presents reports and dashboards
- Hyper-v:Hyper-v 第 1 代或第 2 代虚拟机
- How to choose an account opening broker? Is it safe to open an account online?
- Internet of things (intelligent irrigation system - Android end)
猜你喜欢

How is the ISM model analyzed?

Bluecmsv1.6- code audit

Various synchronous learning notes

Rank sum ratio (RSR) index calculation

Exchange:管理日历权限

How to calculate the independence weight index?

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

软件测试月薪10K如何涨到30K,只有自动化测试能做到

How to calculate the distance between texts: WMD

Scanpy(七)基于scanorama整合scRNA-seq实现空间数据分析
随机推荐
城链科技平台,正在实现真正意义上的价值互联网重构!
TrendMicro:Apex One Server 工具文件夹
Bluecmsv1.6-代码审计
leetcode.13 --- 罗马数字转整数
现在网上开通股票账号安全吗?
How to calculate the distance between texts: WMD
如何成为一名软件测试高手? 月薪3K到17K,我做了什么?
Advanced technology Er, meet internship position information
Various synchronous learning notes
UEFI: repair efi/gpt bootloader
紧急行政中止令下达 Juul暂时可以继续在美国销售电子烟产品
Is there any risk in the security of new bonds
故障:Outlook 收发邮件时的 0x800CCC1A 错误
How to calculate the correlation coefficient and correlation degree in grey correlation analysis?
软件确认测试有什么作用?确认测试报告的价格是多少?
Is it safe to open an account for stocks on the Internet? Can the securities account be used by others?
以科技赋能设计之美,vivo携手知名美院打造“产学研”计划
atguigu----17-生命周期
Can I grant database tables permission to delete column objects? Why?
Hyper-v:hyper-v generation 1 or generation 2 virtual machines