首页 > 其他分享 >LVS-DR1

LVS-DR1

时间:2024-08-29 08:55:00浏览次数:13  
标签:10.0 00 LVS DR1 0.0 forever lft ff

LVS-DR模式同网段实现

  说明:DIP、VIP、RIP同网段

拓扑:

 

 

 

环境说明:

1、client网关指向Router,跨网段访问lvs-VIP,需要指定正确网关和路由,如果client和Route之间还有其他路由或防火墙设备,网关设置直连路由IP

2、虚拟机模拟路由器,Router需要开启路由转发ip_forward

3、实验环境模拟路由器直连client和lvs架构,Router可以不配置网关

4、lvs必须有网关:10.0.0.x;如果不配置网关,不接收 “源CIP--目VIP”的数据包,因为数据包到达时,发现CIP和自己不在同网段,假设自己返回响应则需要通过网关发出数据包,但是没有网关,响应返回不了,干脆不接受

5、lvs,rs,都需要配置VIP,VIP一般配置在lo上,VIP在lo上子网掩码一般是32位,如果在ensX端口,32位可以,24位也可以,会自动生成路由,但是lo上24位掩码不会自动生成路由,影响访问

6、避免arp广播VIP冲突,关闭rs内核参数,忽略arp广播对VIP的查询,忽略自己对自己VIP的arp广播宣告

7、由于lvs调度请求时,源目IP不变"CIP-VIP",没有新的IP封装,调度给后端RIP时,依赖MAC地址转发,所以lvs调度器和RS需要在一个物理网络

8、lvs-DR模式,请求经过lvs,响应不经过lvs,RS的网关不指向lvs,而是“出口路由”

9、tcp握手有5次 

 

各主机路由情况:

[root@client ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.43.122  0.0.0.0         UG    100    0        0 ens33
192.168.43.0    0.0.0.0         255.255.255.0   U     100    0        0 ens33

[root@router ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 ens33
192.168.43.0    0.0.0.0         255.255.255.0   U     101    0        0 ens37

[root@lvs ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.101      0.0.0.0         UG    100    0        0 ens33
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 ens33

[root@rs1 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.122      0.0.0.0         UG    100    0        0 ens33
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 ens33

[root@rs2 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.122      0.0.0.0         UG    100    0        0 ens33
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 ens33

 

示例:基于轮询算法、DR模式配置验证

【注意】示例中添加VIP的方法是临时添加,永久添加需要写入配置文件,或者使用nmcli命令添加VIP

1、client配置:

[root@client ~]# ip a 
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:25:c5:6f brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.121/24 brd 192.168.43.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 2408:840c:931f:6abb:250:56ff:fe25:c56f/64 scope global mngtmpaddr dynamic 
       valid_lft 3270sec preferred_lft 3270sec
    inet6 fe80::250:56ff:fe25:c56f/64 scope link 
       valid_lft forever preferred_lft forever

 

2、Router配置:

[root@router ~]# grep -i ip_forward /etc/sysctl.conf       #永久有效
net.ipv4.ip_forward=1
[root@router ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:29:49:d5 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.122/24 brd 10.0.0.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
3: ens37: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:dd:76:5c brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.122/24 brd 192.168.43.255 scope global noprefixroute ens37
       valid_lft forever preferred_lft forever
    inet6 2408:840c:931f:6abb:20c:29ff:fedd:765c/64 scope global mngtmpaddr dynamic 
       valid_lft 3232sec preferred_lft 3232sec
    inet6 fe80::20c:29ff:fedd:765c/64 scope link 
       valid_lft forever preferred_lft forever

 

3、lvs配置:

[root@lvs ~]# ip a a 10.0.0.100/32 dev lo:1        #临时有效
[root@lvs ~]# ipvsadm -A -t 10.0.0.100:80 -s rr    #添加VIP,和调度算法
[root@lvs ~]# ipvsadm -a -t 10.0.0.100:80 -r 10.0.0.123:80 -g    #添加RS映射
[root@lvs ~]# ipvsadm -a -t 10.0.0.100:80 -r 10.0.0.124:8080 -g  #lvs-DR模式不支持端口映射
[root@lvs ~]# ipvsadm -ln 
[root@lvs ~]# ipvsadm -ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  10.0.0.100:80 rr
  -> 10.0.0.123:80                Route   1      0          0         
  -> 10.0.0.124:80                Route   1      0          0    #lvs-DR模式不支持端口映射
[root@lvs ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.0.0.100/32 scope global lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:31:8a:01 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.125/24 brd 10.0.0.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever 

 

4、RS配置:

[root@rs1 ~]#  ip a a 10.0.0.100/32 dev lo:1     #临时有效
[root@rs1 ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet 10.0.0.100/32 scope global lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:50:56:24:31:9e brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.123/24 brd 10.0.0.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
[root@rs1 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore #关闭arp应答
[root@rs1 ~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore  #关闭arp应答
[root@rs1 ~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce #关闭arp广播宣告
[root@rs1 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce #关闭arp广播宣告

[root@rs2 ~]# ip a a 10.0.0.100/32 dev lo:1 #临时有效 [root@rs2 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet 10.0.0.100/32 scope global lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 00:50:56:3e:3c:3e brd ff:ff:ff:ff:ff:ff inet 10.0.0.124/24 brd 10.0.0.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever
[root@rs1 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore #关闭arp应答
[root@rs1 ~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore  #关闭arp应答
[root@rs1 ~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce  #关闭arp广播宣告
[root@rs1 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce #关闭arp广播宣告

 5、验证:

[root@client ~]#  curl 10.0.0.100

MAC地址:

C-MAC:    00:50:56:29:49:d5

R-IP1-MAC:  00:0c:29:dd:76:5c

R-IP2-MAC:  00:50:56:29:49:d5

LVS-MAC:    00:50:56:31:8a:01

RS1-MAC:    00:50:56:24:31:9e

RS2-MAC:    00:50:56:3e:3c:3e

Wireshark抓包VMNET8:CIP和VIP保持不变,VS重新封装源目MAC转发给RS,RS响应报文不经过VS:

 

标签:10.0,00,LVS,DR1,0.0,forever,lft,ff
From: https://www.cnblogs.com/cnblogsfc/p/14208961.html

相关文章

  • LVS-DR2
     LVS-DR模式不同网段实现说明:DIP与RIP和VIP不同网段 拓扑:   环境说明:1、client网关指向Router,跨网段访问lvs-VIP,需要指定正确网关和路由,如果client和Route之间还有其他路由或防火墙设备,网关设置直连路由IP2、虚拟机模拟路由器,Router需要开启路由转发ip_forward3......
  • keepalived-lvs-DR
    keepalived实现lvs高可用说明:lvs单实例拓扑: 环境说明:1、client网关指向Router,跨网段访问lvs-VIP,需要指定正确网关和路由,如果client和Route之间还有其他路由或防火墙设备,网关设置直连路由IP2、虚拟机模拟路由器,Router需要开启路由转发ip_forward3、实验环境模拟路由器......
  • LVS
    问题LVSNAT模式必须设置默认路由指向DIR地址,如果不设置数据包RS服务器能否将数据包正确的返回给客户端。DR/TUN模式增加一条静态路由目标地址VIP地址,dev设备指向VIP的网口,如果不设置RS服务能否正确接收到DirectorServer发送的数据包LVSDR/TUN模式,RS服务器一定配置VIP地址在......
  • lvs+keepalive大战haproxy+keepalive实现高可用集群
    华子目录lvs+keepalive实验架构实验前的准备工作1.主机准备2.KA1和KA2上安装`lvs+keepalive`3.webserver1和webserver2上安装httpd4.制作测试效果网页内容5.所有主机关闭`firewalld`和`selinux`6.开启httpd服务实验步骤1.webserver1和webserver2上配置vip2.webserver1和......
  • LVS+Keepalived群集
    目录keepalived的热备方式keepalived的安装与服务一、使用Keepalived双机实现热备案例1:主服务器配置2:备用服务器的配置3:测试虚拟ip的连通性二、LVS+Keepalived高可用性1:主调度器配置健康状态检查的方式2:从调度器配置3:服务器池配置(1)web1网络的配置(2)web2服务器配置......
  • [米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-08 仿真验证
    软件版本:Anlogic-TD5.9.1-DR1_ES1.1操作系统:WIN1064bit硬件平台:适用安路(Anlogic)FPGA实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板板卡获取平台:https://milianke.tmall.com/登录"米联客"FPGA社区http://www.uisrc.com视频课程、答疑解惑! 4仿真验证仿真代码的顶层如下......
  • [米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-09 ICMP层程序设计
    软件版本:Anlogic-TD5.9.1-DR1_ES1.1操作系统:WIN1064bit硬件平台:适用安路(Anlogic)FPGA实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板板卡获取平台:https://milianke.tmall.com/登录"米联客"FPGA社区http://www.uisrc.com视频课程、答疑解惑! 5上板调试5.1硬件连接本次......
  • [米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-04 IP层程序设计
    软件版本:Anlogic-TD5.9.1-DR1_ES1.1操作系统:WIN1064bit硬件平台:适用安路(Anlogic)FPGA实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板板卡获取平台:https://milianke.tmall.com/登录"米联客"FPGA社区http://www.uisrc.com视频课程、答疑解惑! 3.3IP层ICMP层数据和UDP层数......
  • [米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-05 ARP层程序设计
    软件版本:Anlogic-TD5.9.1-DR1_ES1.1操作系统:WIN1064bit硬件平台:适用安路(Anlogic)FPGA实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板板卡获取平台:https://milianke.tmall.com/登录"米联客"FPGA社区http://www.uisrc.com视频课程、答疑解惑 3.4ARP层该层具有接收ARP请求......
  • [米联客-安路飞龙DR1-FPSOC] UDP通信篇连载-06 UDP层程序设计
    软件版本:Anlogic-TD5.9.1-DR1_ES1.1操作系统:WIN1064bit硬件平台:适用安路(Anlogic)FPGA实验平台:米联客-MLK-L1-CZ06-DR1M90G开发板板卡获取平台:https://milianke.tmall.com/登录"米联客"FPGA社区http://www.uisrc.com视频课程、答疑解惑! 3.5UDP层该层实现用户数据和U......