宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

一、简介

虚拟路由器冗馀协议VRRP )可将虚拟路由器的责任

动态分配给局域网的VRRP路由器之一。 控制虚拟路由器IP地址的VRRP

路由器称为主路由器,它将数据包转发到这些虚拟IP地址。 当主路由器不可用时

是的,此选择过程提供动态故障切换机制,这允许虚拟路由器的IP地址

作为终端主机的默认第一跳路由器。 使用VRRP的好处是有更高的默认路径

不需要为每个终端主机配置动态路由或路由发现协议,而是使用。 VRRP包封装在IP中

中发送。 这是局域网接入设备备份协议。 将为局域网网络中的所有主机设置默认值

网关,这样来自主机的目标地址不在本网段中的消息将通过默认网关交换到三层

机器实现了主机与外部网络的通信。

工作原理

VRRP仅定义了一条消息——vrrp,这是多播消息,由主三层交换机确定

是为了通知他的存在而发行的。 这些消息可以检测虚拟第3层交换机的各种参数,还可以

用于主三层楼交换机的选举。

VRRP定义了三种状态模型:初始状态初始化、活动状态Master和备份状态

备份。 只有活动交换机才能为向虚拟IP地址传输的请求提供服务。

VRRP消息封装在IP消息中,支持各种高级协议,同时支持VRRP是真实的

接口IP地址被设置为虚拟IP地址。

那么,如何从备份组的多个交换机中选择主节点? 这项工作由我们在备份组中的每台上完成

交换机上配置的具有相同IP地址的虚拟交换机已完成。

虚拟交换机根据配置的优先级大小选择主交换机,使用优先级最高的作为主交换机

机械、状态为主、优先顺序相同时开关没有设定优先顺序时采用默认值

100 )的情况下,比较接口的主IP地址,大的主IP地址成为主交换机,这提供了实际的路径

提供服务。 其他交换机作为备份交换机,始终监视主交换机的状态。 主开关正常时

运行时,每隔一定时间发送VRRP多播消息,通知组中的备份交换机、主机

开关工作正常。 如果组内的备份交换机长时间没有来到自主交换机

的VRRP多播消息将它的状态转换为Master。 如果组中有多个备份交换机,则可以

可以生成多个主交换机。 在这种情况下,每个主交换机将VRRP消息的优先级与自己的书进行比较

的优先顺序。 如果本地优先级小于VRRP优先级,则将自己的状态转换为

Backup,否则保持自己的状态。 这样的过程将导致优先级最高的交换

选择新的主交换机以完成VRRP的备份功能。

双层开关lsw3结构

华为还原终端监视器

info : currentterminalmonitorisoff。

华为sys

华为系统视图

Enter system view,返回用户视图with ctrl z。

[Huawei]sysname lsw3

[ ls w3 ]用户插件

[ ls w3 ]用户界面con

[ ls w3 ]用户界面控制台0

[lsw3-ui-console0]id

[ ls w3-ui-console0]空闲时间输出0

[ ls w3-ui -控制台0 ] q

[lsw3]vlan b

[lsw3]vlan batch 10 20

info : thisoperationmaytakeafewseconds.pleasewaitforamoment . done。

[lsw3]int e0/0/1

[ ls w3 -以太网0/0/1 ] PLA

[ ls w3 -以太网0/0/1 ] pdv 10

[ ls w3 -以太网0/0/1 ] int E0/0/2

[ ls w3 -以太网0/0/2 ] PLA

[ ls w3 -以太网0/0/2 ] p dv 20

[ ls w3 -以太网0/0/2 ] int G0/0/1

[ ls w3 -千兆以太网0/0/1 ] PLT

[ ls w3 -千兆以太网0/0/1 ] ptav 1020

[ ls w3 -千兆以太网0/0/1 ] intg0/0/2

[ ls w3 -千兆以太网]

t0/0/2]p l t
[lsw3-GigabitEthernet0/0/2]p t a v 10 20

 

三层交换机 lsw1 配置

<Huawei>undo terminal monitor 
Info: Current terminal monitor is off.
 <Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname lsw1
[lsw1]user-interface console 0
[lsw1-ui-console0]idle-timeout 0 0
[lsw1-ui-console0]q
[lsw1]vlan batch 10 20 
Info: This operation may take a few seconds. Please wait for a moment…done.
[lsw1]vlan 100
[lsw1-vlan100]q
[lsw1]int g0/0/2
[lsw1-GigabitEthernet0/0/2]p l t
[lsw1-GigabitEthernet0/0/2]p t a v 10 20
[lsw1-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[lsw1-GigabitEthernet0/0/2]int g0/0/1
[lsw1-GigabitEthernet0/0/1]p l a
[lsw1-GigabitEthernet0/0/1]p d v 100
[lsw1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[lsw1-GigabitEthernet0/0/1]q
[lsw1]int vlanif 10
[lsw1-Vlanif10]ip add 192.168.10.10 24
[lsw1-Vlanif10]vrrp vr    
[lsw1-Vlanif10]vrrp vrid ?
  INTEGER<1-255>  Virtual router identifier

[lsw1-Vlanif10]vrrp vrid 1?
  INTEGER<1-255>                          
[lsw1-Vlanif10]vrrp vrid 1 vir    
[lsw1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1  配置虚拟的ip地址
[lsw1-Vlanif10]vrrp vrid 1 priority 120                    配置优先级
[lsw1-Vlanif10]vrrp vrid 1 track  interface g0/0/1   配置监听端口
[lsw1-Vlanif10]vrrp vrid 1 track interface g0/0/2
[lsw1-Vlanif10]int vlanif 20
[lsw1-Vlanif20]ip add 192.168.20.10 24
[lsw1-Vlanif20]vrr    
[lsw1-Vlanif20]vrrp vi    
[lsw1-Vlanif20]vrrp vr    
[lsw1-Vlanif20]vrrp vrid 2 vi    
[lsw1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.1
[lsw1-Vlanif20]vrrp v    
[lsw1-Vlanif20]vrrp vrid 2 p    
[lsw1-Vlanif20]vrrp vrid 2 pr    
[lsw1-Vlanif20]vrrp vrid 2 priority 115
[lsw1-Vlanif20]q
[lsw1]int vlanif 100
[lsw1-Vlanif100]ip add 11.0.0.2 30
[lsw1-Vlanif100]q
[lsw1]ip r    
[lsw1]ip rou    
[lsw1]ip route-s    
[lsw1]ip route-static 0.0.0.0 0.0.0.0 11.0.0.1
 

 

 

三层交换机lsw2命令配置

 

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname LSW2
[LSW2]user-in    
[LSW2]user-interface con    
[LSW2]user-interface console 0 
[LSW2-ui-console0]id     
[LSW2-ui-console0]idle-timeout 0 0
[LSW2-ui-console0]q
[LSW2]vlan b    
[LSW2]vlan batch 10 20 100
Info: This operation may take a few seconds. Please wait for a moment…done.
[LSW2]int g0/0/2
[LSW2-GigabitEthernet0/0/2]p l t
[LSW2-GigabitEthernet0/0/2]p t a v 10 20
[LSW2-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[LSW2-GigabitEthernet0/0/2]int g0/0/1
[LSW2-GigabitEthernet0/0/1]p l a
[LSW2-GigabitEthernet0/0/1]p d v 100
[LSW2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[LSW2-GigabitEthernet0/0/1]int vlanif 10
[LSW2-Vlanif10]ip add 192.168.10.20 24
 [LSW2-Vlanif10]vrrp vrid 1 priority 115
Error: The VRRP does not exist.
[LSW2-Vlanif10]int vlanif 20
[LSW2-Vlanif20]ip add 192.168.20.20 24
[LSW2-Vlanif20]vrrp vrid 2     
[LSW2-Vlanif20]vrrp vrid 2 vi    
[LSW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.1
 [LSW2-Vlanif20]vrrp vrid 2 priority 120
  [LSW2-Vlanif20]vrrp vrid 2 track interface g0/0/2
[LSW2-Vlanif20]int vlan    
[LSW2-Vlanif20]int vlani    
[LSW2-Vlanif20]int vlanif 100
[LSW2-Vlanif100]ip add 12.0.0.2 30
[LSW2-Vlanif100]q
[LSW2]ip r    
[LSW2]ip rou    
[LSW2]ip route-s    
[LSW2]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1
[LSW2]

 

 

路由器 R1

 

<Huawei>undo terminal monitor 
Info: Current terminal monitor is off.
<Huawei>sys    
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]user-interface console 0
[R1-ui-console0]idle-timeout 0 0
[R1-ui-console0]q
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 11.0.0.1 30
[R1-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.0.0.1 30
[R1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R1-GigabitEthernet0/0/1]int loo 0
[R1-LoopBack0]ip add 1.1.1.1 24
[R1-LoopBack0]q
[R1]ip route-static 192.168.10.0 24 11.0.0.2
[R1]ip route-static 192.168.10.0 24 12.0.0.2 p    
[R1]ip route-static 192.168.10.0 24 12.0.0.2 preference 70
[R1]ip route-static 192.168.20.0 24 12.0.0.2
[R1]ip route-static 192.168.20.0 24 11.0.0.2 preference 70