网关冗余和负载均衡GLBP
- 格式:docx
- 大小:176.07 KB
- 文档页数:8
2)HSRP(Hot Standby Routing Protocol)(私有协议)(在三层交换机与路由器上可以做)·HSRP是一种网关冗余协议,它通过在冗余网关之间共享协议和MAC,提供不间断的IP路径冗余。
·HSRP在2个或多个路由器间创建虚拟MAC和虚拟IP,其实就是将多台物理的路由器组合成一台虚拟路由器。
主机的网关设为此虚拟IP就可以了。
·HSRP的hello包包含priority(默认100),hello间隔(默认3S),holdtime(默认10S),虚拟网关IP·HSRP的hello包发向组播地址224.0.0.2(所有路由器)·HSRP路由器的默认优先级是100,优先级相同的情况下比较IP地址,越大越优。
·一个HSRP组可以包含多台路由器,在一个稳定的组里面只有两台路由器发送hello 包,一台是active路由器,一台是备份路由器,其它路由器不发送hello包,但都处于监听状态。
·HSRP可以配置多个组,配多个组的目地是为了做负载分担·虚拟MAC地址:前40位固定(0000.0c),将HSRP的组标识符换成十六进制,接到最后就可以了例如:HSRP组为47,换成十六进制是2fMAC地址前40位为0000.0c07.ac最后得到:0000.0c07.ac2f·HSRP状态:1、Initial All routers begin in the initial state, when HSRP is not running (初始状态,如果手动配置虚拟IP,直接跳到Listen状态)2、learn (没有收到hello包,没有虚拟ip地址,等待收到hello包)3、listen(收到hello包,有了虚拟ip地址,除了active和standby,其它路由器都是这个状态)4、speak (周期发送hello包,开始选active和standby router)5、Standby (没选到active的,除了active外优先级最高的router,会继续发hello包,只有一个)6、active (选到的转发的router,会继续发hello包,只有一个)例:R1、R2、R3运行路由协议,宣告所有接口。
先应式路由协议先应式路由协议一、概述先应式路由协议(First Hop Redundancy Protocol,FHRP)是一种网络协议,用于在局域网中提供冗余的默认网关。
它可以确保当某个默认网关失效时,其他可用的默认网关可以接管其工作。
二、常见的FHRP协议1. 虚拟路由器冗余协议(Virtual Router Redundancy Protocol,VRRP)VRRP是一种开放标准的FHRP协议,它可以使多台设备共享同一个虚拟IP地址,并且在其中一台设备失效时自动切换到另一台设备上。
VRRP支持IPv4和IPv6,并且可以设置优先级来确定主设备和备份设备。
2. 网关负载均衡协议(Gateway Load Balancing Protocol,GLBP)GLBP是Cisco开发的FHRP协议,它可以使多个设备共享同一个虚拟IP地址,并且将流量分配给这些设备中的一个或多个。
GLBP支持IPv4和IPv6,并且可以设置优先级来确定主设备。
三、VRRP详解1. VRRP工作原理VRRP使用虚拟路由器(Virtual Router,VR)来代表一组路由器,并且为这组路由器提供一个虚拟IP地址。
其中,一个路由器被选为主路由器,其他路由器则作为备份路由器。
主路由器负责转发流量,而备份路由器则监控主路由器的状态,并在主路由器失效时接管其工作。
2. VRRP优先级VRRP中的每个路由器都有一个优先级,优先级越高的设备越有可能被选为主路由器。
如果两个或多个设备具有相同的优先级,则将根据设备的MAC地址来决定哪个设备成为主设备。
3. VRRP状态转换VRRP中有三种状态:初始化状态、主状态和备份状态。
当一个新的VRRP组被创建时,所有的成员设备都处于初始化状态。
然后,当某个成员设备被选为主设备时,它会进入主状态;其他成员则进入备份状态。
当主设备失效后,其他成员中优先级最高的设备会自动切换到主状态。
四、GLBP详解1. GLBP工作原理GLBP使用虚拟MAC地址和虚拟IP地址来代表一组网关,并且将流量分配给这些网关中的一个或多个。
这部分的讲解要结合幻灯片高可用性:1.HSRP(Hot Standby Routing Protocol):热备份路由协议2.VRRP(Virtual Router Redundancy Protocol):虚拟路由器冗余协议3.GLBP(Gateway load Balancing Protocol):网关负载均衡协议这3个协议都是用来保证网关的备份的HSRP1.思科私有的2.一个虚拟IP地址,一个虚拟MAC地址虚拟IP地址不能和真实IP地址相同虚拟MAC地址:0000.0c07.acXX,其中XX是组号3.一主一辅4.HSRP默认优先级是100,被跟踪的接口不可用后优先级默认降低105.HSRP的6种状态(1)Initial:初始状态,修改配置或接口刚启动时处于这个状态(2)Learn:学习状态,等待活跃路由器发送Hello 消息,收到后就进入监听状态(3)Listen:监听状态,在HSRP组中,除活跃路由器和备用路由器外,其他路由器都处于这种状态。
说白了,这个状态就是用来选举的,如果被选举是备用状态或者是活跃状态,就进入speak状态(4)speak:发言状态,处于发言状态的路由器定期地发送Hello消息,如果在speak状态发现了更优秀的Hello包,此时就转化成listen状态(5)Standby:备用状态,定期发送Hello消息(6)Active:活跃状态,定期发送Hello消息HSRP使用的包:hello,辞职和政变6.配置的时候一定要禁用定向广播命令是:no ip redirects7.关于HSRP的实验(1)路由器上基本配置(2)交换机上基本配置(3)跟踪(4)负载均衡8配置主设备配置3句话standby 1 ip 虚拟IP地址standby 1 preempt //让设备支持抢占功能standby 1 priority 优先级备份设备配置2句话standby 1 ip 虚拟IP地址standby 1 preemptVRRP1.公有的2.一个虚拟IP地址,一个虚拟MAC地址虚拟IP地址可以和真实IP地址相同虚拟MAC地址:0000.5e00.01XX,其中XX是组号3.一主多辅4.VRRP默认优先级是100,不支持跟踪5.协议号112,组播地址224.0.0.18,默认通告间隔1s6.VRRP默认有抢占机制7.关于VRRP的实验(1)路由器上基本配置(2)交换机上基本配置(3)负载均衡HSRP与VRRP之间的区别:1.HSRP是私有的,VRRP是共有的2.HSRP是一主一辅,VRRP是一主多辅3.HSRP支持跟踪,VRRP没有跟踪机制4.HSRP的虚拟IP地址不能和真实IP地址相同,VRRP的虚拟IP地址和真实的IP地址相同5.HSRP中主、辅设备都发送Hello包,VRRP中只有主设备发送Hello包GLBP1.思科私有的2.一个虚拟IP地址,多个虚拟MAC地址3.GLBP和HSRP,VRRP的最大不同在于:可以提供负载均衡4.两个术语:(1)AVF:active virtual forwarder(2)AVG:active virtual gateway5.GLBP的工作原理:(1)GLBP组选举一个AVG,所有组成员都叫做AVF (2)AVG给整个组分配虚拟MAC地址,即每个AVF分配到一个虚拟MAC地址(3)AVG负责回复用户的ARP请求,每次给的虚拟MAC 地址不同,以这种方式实现负载均衡(4)每个AVF负责转发自己负责的那个虚拟MAC的数据6.GLBP支持3种负载均衡的模式(1)host-dependent:确保主机始终使用同一个虚拟MAC地址(2)round-robin:每次轮流地分配AVF的虚拟MAC地址(3)weighted:前往AVF的流量取决于AVF的权重7.关于GLBP的实验(1)路由器上基本配置(2)交换机上基本配置。
网关冗余和负载均衡HSRP一、交换机SW1(R6)交换机SW2(R4)配置R6>enableR6#conf tR6(config)#hostname SW1SW1 (config)#int fa0/0SW1 (config-if)#no shutdownSW1 (config-if)#exitSW1 (config)#int fa0/1SW1 (config-if)#no shutdownSW1 (config-if)#exitSW1 (config)#int fa0/2SW1 (config-if)#no shutdownSW1 (config-if)#exitSW1#vlan databaseSW1 (vlan)#vlan 2VLAN 2 added:Name: VLAN0002SW1 (vlan)#exitSW1#conf tSW1 (config)#int range fa0/0 - 2SW1 (config-if-range)#switchport access vlan 2SW1 (config-if-range)#exitSW1 (config-if-range)#exitSW1(config)#int vlan 2SW1(config-if)#ip add 192.168.13.2 255.255.255.0 SW1(config-if)#no shutdownSW1(config-if)#exitSW1(config)#exitSW1#R4>enableR4#conf tR4(config)#host SW2SW2(config)#int fa0/1SW2(config-if)#no shutdownSW2(config-if)#exitSW2(config)#int f0/0SW2(config-if)#no shutdownSW2(config-if)#exitSW2(config)#exitSW2#vlan databaseSW2(vlan)#vlan 2VLAN 2 added:Name: VLAN0002SW2(vlan)#exitSW2#conf tSW2(config)#int range fa0/0 - 1SW2(config-if-range)#switchport access vlan 2SW2(config-if-range)#endSW2#二、配置PC1(R7)PC2(R5)R7>enableR7#conf tPC1(config)#no ip routingPC1(config)#int e0/0PC1(config-if)#ip add 192.168.13.100 255.255.255.0 PC1(config-if)#no shutdownPC1(config-if)#exitPC1(config)#ip default-gateway 192.168.13.2PC1(config)#exitPC1#R5>enableR5#conf tR5(config)#host PC2PC2 (config)#no ip routingPC2 (config)#int e0/0PC2 (config-if)#ip add 192.168.20.100 255.255.255.0 PC2 (config-if)#no shutdownPC2 (config-if)#exitPC2 (config)#ip default-gateway 192.168.20.2 三、对路由器进行基本配置R1#conf tR1(config)#int e0/0R1(config-if)#ip add 192.168.13.1 255.255.255.0R1(config-if)#no shutdownR1(config-if)#exitR1(config)#int s1/0R1(config-if)#ip add 192.168.12.1 255.255.255.0R1(config-if)#no shutdownR1(config-if)#exitR1(config)#R2>enableR2#conf tR2(config)#int s1/0R2(config-if)#ip add 192.168.12.2 255.255.255.0R2(config-if)#clock rate 128000R2(config-if)#no shutdownR2(config-if)#exitR2(config)#int s1/1R2(config-if)#ip add 192.168.23.2 255.255.255.0R2(config-if)#clock rate 128000R2(config-if)#no shutdownR2(config)#int e0/0R2(config-if)#ip add 192.168.20.2 255.255.255.0R2(config-if)#no shutdownR2(config-if)#exitR2(config)#exitR2#R3>enableR3#conf tR3(config)#int s1/0R3(config-if)#ip add 192.168.23.3 255.255.255.0R3(config-if)#no shutdownR3(config)#int e0/0R3(config-if)#ip add 192.168.13.3 255.255.255.0R3(config-if)#no shutdownR3(config-if)#exitR3(config)#四、配置路由协议R1#conf tR1(config)#router ripR1(config-router)#net 192.168.12.0R1(config-router)#net 192.168.13.0R1(config-router)#passive-interface e0/0//把e0/0接口设为被接口,为了防止从该接口发送RIP信息给R3 R1(config-router)#exitR1(config)#exitR1#R2#conf tR2(config)#router ripR2(config-router)#net 192.168.12.0R2(config-router)#net 192.168.23.0R2(config-router)#net 192.168.20.0R2(config-router)#passive-interface e0/0R2(config-router)#exitR2(config)#exitR2#R3#conf tR3(config)#router ripR3(config-router)#net 192.168.13.0R3(config-router)#net 192.168.23.0R3(config-router)#passive-interface e0/0R3(config-router)#exitR3(config)#exitR3#五、查看路由表R1#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setC 192.168.12.0/24 is directly connected, Serial1/0C 192.168.13.0/24 is directly connected, Ethernet0/0R 192.168.20.0/24 [120/1] via 192.168.12.2, 00:00:28, Serial1/0R 192.168.23.0/24 [120/1] via 192.168.13.3, 00:01:12, Ethernet0/0[120/1] via 192.168.12.2, 00:00:06, Serial1/0R1#前后对比R1#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setC 192.168.12.0/24 is directly connected, Serial1/0C 192.168.13.0/24 is directly connected, Ethernet0/0R 192.168.20.0/24 [120/1] via 192.168.12.2, 00:00:28, Serial1/0R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:02, Serial1/0R1#R2#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setC 192.168.12.0/24 is directly connected, Serial1/0R 192.168.13.0/24 [120/1] via 192.168.23.3, 00:00:17, Serial1/1[120/1] via 192.168.12.1, 00:00:14, Serial1/0C 192.168.20.0/24 is directly connected, Ethernet0/0C 192.168.23.0/24 is directly connected, Serial1/1R2#R3#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setR 192.168.12.0/24 [120/1] via 192.168.23.2, 00:00:16, Serial1/0C 192.168.13.0/24 is directly connected, Ethernet0/0R 192.168.20.0/24 [120/1] via 192.168.23.2, 00:00:12, Serial1/0C 192.168.23.0/24 is directly connected, Serial1/0R3#五、测试R1#ping 192.168.20.100Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.20.100, timeout is 2 seconds: !!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 60/80/120 ms R1#六、配置HSRPR1#conf tR1(config)#int e0/0R1(config-if)#standby 1 ip 192.168.13.254 //启用HSRP功能,并设置虚拟IP地址R1(config-if)#standby 1 priority 120 //配置HSRP的优先级,默认优先级为100R1(config-if)#standby 1 preempt //允许该路由器在优先级是最高时成为活动路由器R1(config-if)#standby 1 timer 3 10 //3为hello时间,10为hold时间R1(config-if)#standby 1 authentication md5 key-string cisco //配置认证密码R1(config-if)#R3#conf tR3(config)#int e0/0R3(config-if)#standby 1 ip 192.168.13.254R3(config-if)#standby 1 preemptR3(config-if)#standby 1 time 3 10R3(config-if)#standby 1 authentication md5 key-string ciscoR3(config-if)#endR3#七、检查测试HSRPR1#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 120 Active local 192.168.13.3 192.168.13.254 R1#R3#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 100 P Standby 192.168.13.1 local 192.168.13.254 R3#八、对R1进行变动再次查看检测HSRPR1#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 120 Init unknown unknown 192.168.13.254 R1#R3#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 100 P Active local unknown 192.168.13.254 R3#九、对R1进行变动再次查看检测HSRPR1#conf tR1(config)#int e0/0R1(config-if)#standby 1 track s1/0 30R1(config-if)#exitR1(config)#int s1/0R1(config-if)#shutdownR1(config-if)#exitR1(config)#R1#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 90 Standby 192.168.13.3 local 192.168.13.254R1#R3#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 100 P Active local 192.168.13.1 192.168.13.254R3#十、创建多个HSRP组R1(config)#int e0/0R1(config-if)#standby 2 ip 192.168.13.253R1(config-if)#standby 2 preemptR1(config-if)#standby 2 authentication md5 key-string ciscoR1(config-if)#R3#conf tR3(config)#int e0/0R3(config-if)#standby 2 ip 192.168.13.253R3(config-if)#standby 2 priority 120R3(config-if)#standby 2 preemptR3(config-if)#standby 2 authentication md5 key-string ciscoR3(config-if)#standby 2 track s1/0 30R3(config-if)#exitR3(config)#十一、查看HSRPR1#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 120 P Active local 192.168.13.3 192.168.13.254 Et0/0 2 100 P Standby 192.168.13.3 local 192.168.13.253 R1#R3#sh standby briefP indicates configured to preempt.|Interface Grp Prio P State Active Standby Virtual IPEt0/0 1 100 P Standby 192.168.13.1 local 192.168.13.254 Et0/0 2 120 P Active local 192.168.13.1 192.168.13.253 R3#。
2018年10期应用科技科技创新与应用Technology Innovation and Application GLBP 协议在企业网中的应用与仿真胡,何树国(南京航空航天大学金城学院信息工程学院,江苏南京211156)1需求分析随着网络技术的快速发展,网络与人们的生活越来越贴近,人们对网络稳定性要求也越来越高。
企业网设计与架构的主要要求如下:首先,网络架构要考虑到冗余备份的放置使用;其次,企业每个部门虽然相互独立,但是需要相互进行联系;另外,核心层设备要实现快速收敛,网关快速切换,骨干区域要快速、高效转发数据流;最后,内网与外网要稳定、安全。
2企业网络整体设计2.1企业网内网分层结构一般一个企业网主要包括核心层、汇聚层以及接入层三层。
对企业来说最重要的还是核心层,核心层主要就是使网络内部数据流量能够大量并且快速的转发;就汇聚层而言,它就是相当于一座桥梁,连接到接入层跟核心层中,在这层会用到一些协议,让数据有目的的流动;接入层就是直接与用户连接,让用户能访问高层数据。
就拥有很多信息点的企业来说,考虑到安全性,不可能将整个网络处于一个VLAN 中,这样很容易受到攻击。
而传统的路由器路由能力太差,有可能会造成数据的丢失。
如果使用千兆的路由器价格又太高,还不如使用拥有千兆端口的交换机,既节省开销又能很好的解决通信问题。
核心层跟汇聚层企业一般都会选用三层交换机。
三层交换机不仅有普通路由器的路由功能还有二层交换机的交换功能,而且能分割广播域及隔离广播风暴,能进行VLAN 之间的单、双向通信,还具有列表访问的功能,能很好的将一些外网的非法网站阻止在外面以至于不能对公司内网信息进行访问窃取,从而保证了公司信息的安全性。
因此本设计在核心层上使用2台Cisco 3745三层交换机,在汇聚层上使用5台Cisco 3745三层交换机,在接入层上使用5台Cisco 二层交换机。
2.2使用协议思科公司提供的协议很多,本设计主要研究的协议是GLBP 协议,另外在设计中还增加了OSPF 协议,生成树,静态路由等相关配置。
路由冗余中心交换机是整个网络的核心和心脏,如果发生致命的故障,将导致本地网络的瘫痪,所造成的损失也是难以估计的。
因此,对碱层路由采用热备份是提高网络可靠性的必然选择。
利HSRP、VRRP、GLBP协议保证核心设备的负荷分担和热备份,在中心交换机和双汇聚交换机中某台交换机出现故障时,应能够迅速切换三层路由设备和虚拟网关,实现双线路的冗余备份,保证整网的稳定性。
1、热备份路由器协议热备份路由器协议(Hot Standby Router Protocol,HSRP)的设计目标是支持特定情况下IP流量失败转移而不会引起混乱,并允许主机使用单路由器,以及即使在实际第一跳路由器使用失败的情况下,仍能维护路由器间的连通性。
换句话说,当源主机不能动态知道第一跳路由器的IP地址时,HSRP协议能够保护第一跳路由器不出故障。
该协议中含有多种路由器,对应一个虚拟路由器。
HSRRP协议只支持一个路由器代表虚拟路由器实现数据包转发过程。
终端主机将它们各自的数据包转发到该虚拟路由器上。
负责转发数据包的路由器称之为主动路由器(Active Router)。
一旦主动路由器出现故障,HSRP将激活备份路由器(Standby Routers)取代主动路由器(如图)HSRP协议提供了一种决定使用主动路由器还是备份路由器的机制,并指定一个虚拟的IP地址作为网络系统的默认网关地址。
如果主动路由器出现故障,备份路由器将承接主动路由器的所有任务,并且不会导致主机连通中断现象。
2、虚拟路由冗余协议在网络中,一般给终端设备指定一个或者多默认网关(Default Gateway).如果作为默认网关的三层设备损坏。
那么所使用该网关主机的通信必然要中断。
即便配置了多个默认网关,如不重新启动终端设备,也不能切换到新的网关。
采用虚拟路由冗余协议(Virtual Router Redundancy Protocol,VRRP)可以很发地避免静态指定网关的缺陷。
基于双线路接入的网关冗余和负载均衡设计与实现[摘要] 各个企业为了保证企业网络的可用性和连续性,都使用了双链路的接入方式。
本文介绍在双链路接入的情况下,如何利用HSRP和DHCP技术做网关冗余和负载均衡,并详细介绍了具体的技术实现细节。
[关键字] HSRP协议DHCP协议网关冗余负载均衡[Abstract] In order to ensure all business availability and continuity of the corporate network, they always use the double-link access. This article describes the case of dual-link access, how to use HSRP and DHCP technology to do the gateway redundancy and load balancing, and details the specific technical implementation details.[Keywords] HSRP Protocol DHCP protocol load balancing Gateway Redundancy1.引言随着企业信息化、数字化建设的推进,越来越多的企业为了保证企业网络的高可用性和高连续性,大多数企业选用了双链路接入的方式,即采用多ISP接入或者是通一个ISP的双链路接入方式来保证服务的持续性,但是大多数仍旧采用了冷备份的方式。
这样做的结果:一是闲置了设备,二是遇到设备故障不能快速、自动启用备份设备,三是不能起到负载均衡的作用。
本文介绍了如何在双链路接入的情况下,如何利用HSRP协议实现双网关冗余和负载均衡以及如何利用三层交换设备动态的给用户分配IP地址,省去了静态IP分配的麻烦。
2.HSRP概述HSRP 是Cisco 的专有协议。
网关冗余和负载均衡GLBP一、配置SW1(R6)SW2(R5)R6>enableR6#conf tR6(config)#host SW1SW1 (config)#int range fa0/0 - 3SW1 (config-if-range)#no shutdownSW1#vlan databaseSW1 (vlan)#vlan 2VLAN 2 added:Name: VLAN0002SW1 (vlan)#exitSW1#conf tSW1 (config)#int range fa0/0 - 3SW1 (config-if-range)#switchport access vlan 2 SW1 (config-if-range)#exitSW1 (config)#exitSW1#R5>enableR5#conf tR5(config)#host SW2SW2(config)#int range fa0/0 - 3SW2(config-if-range)#no shutdownSW2(config-if-range)#exitSW2(config)#exitSW2#vlan databaseSW2(vlan)#vlan 2VLAN 2 added:Name: VLAN0002SW2(vlan)#exitSW2#conf tSW2(config)#int range fa0/0 -3SW2(config-if-range)#switchport access vlan 2SW2(config-if-range)#exitSW2(config)#exitSW2#二、配置PC1(R7)R7>enableR7#conf tR7(config)#host PC1PC1 (config)#no ip routingPC1 (config)#int e0/0PC1 (config-if)#ip add 192.168.1.100 255.255.255.0 PC1 (config-if)#no shutdownPC1 (config-if)#exitPC1 (config)#ip default-gateway 192.168.1.1PC1 (config)#ip default-gateway 192.168.1.2PC1 (config)#ip default-gateway 192.168.1.3PC1 (config)#exitPC1#三、配置路由器R1>enableR1#conf tR1(config)#int e0/0R1(config-if)#ip add 192.168.1.1 255.255.255.0 R1(config-if)#no shutdownR1(config-if)#exitR1(config)#int e0/1R1(config-if)#ip add 192.168.2.1 255.255.255.0 R1(config-if)#no shutdownR1(config-if)#exitR1(config)#exitR1#R2>enableR2#conf tR2(config)#int e0/0R2(config-if)#ip add 192.168.1.2 255.255.255.0 R2(config-if)#no shutdownR2(config-if)#exitR2(config)#int e0/1R2(config-if)#ip add 192.168.2.2 255.255.255.0 R2(config-if)#no shutdownR2(config-if)#exitR2(config)#exitR2#R3>enableR3#conf tR3(config)#int e0/0R3(config-if)#ip add 192.168.1.3 255.255.255.0 R3(config-if)#no shutdownR3(config-if)#exitR3(config)#int e0/1R3(config-if)#ip add 192.168.2.3 255.255.255.0 R3(config-if)#no shutdownR3(config-if)#exitR3(config)#exitR3#R4>enableR4#conf tR4(config)#int lo 0R4(config-if)#ip add 4.4.4.4 255.255.255.0R4(config-if)#exitR4(config)#int e0/0R4(config-if)#ip add 192.168.2.4 255.255.255.0 R4(config-if)#no shutdownR4(config-if)#exitR4(config)#exitR4#四、配置RIP路由协议R1#conf tR1(config)#router ripR1(config-router)#net 192.168.1.0R1(config-router)#net 192.168.2.0R1(config-router)#passive-interface e0/0R1(config-router)#exitR1(config)#exitR1#R2#conf tR2(config)#router ripR2(config-router)#net 192.168.1.0R2(config-router)#net 192.168.2.0R2(config-router)#passive-interface e0/0R2(config-router)#exitR2(config)#exitR2#R3#conf tR3(config)#router ripR3(config-router)#net 192.168.1.0R3(config-router)#net 192.168.2.0R3(config-router)#passive-interface e0/0R3(config-router)#exitR3(config)#exitR3#R4#conf tR4(config)#router ripR4(config-router)#net 192.168.2.0R4(config-router)#net 4.4.4.0R4(config-router)#passive-interface e0/0R4(config-router)#exitR4(config)#exitR4#五、查看路由表R1#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setR 4.0.0.0/8 [120/1] via 192.168.2.4, 00:00:53, Ethernet0/1C 192.168.1.0/24 is directly connected, Ethernet0/0C 192.168.2.0/24 is directly connected, Ethernet0/1R1#R2#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setR 4.0.0.0/8 [120/1] via 192.168.2.4, 00:01:04, Ethernet0/1C 192.168.1.0/24 is directly connected, Ethernet0/0C 192.168.2.0/24 is directly connected, Ethernet0/1R2#R3#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not setR 4.0.0.0/8 [120/1] via 192.168.2.4, 00:01:16, Ethernet0/1C 192.168.1.0/24 is directly connected, Ethernet0/0C 192.168.2.0/24 is directly connected, Ethernet0/1R3#R4#sh ip routeCodes: C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static routeGateway of last resort is not set4.0.0.0/24 is subnetted, 1 subnetsC 4.4.4.0 is directly connected, Loopback0R 192.168.1.0/24 [120/1] via 192.168.2.3, 00:00:01, Ethernet0/0[120/1] via 192.168.2.2, 00:00:23, Ethernet0/0[120/1] via 192.168.2.1, 00:00:23, Ethernet0/0C 192.168.2.0/24 is directly connected, Ethernet0/0R4#六、测试PC1#ping 4.4.4.4Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 92/108/136 ms PC1#R4#ping 192.168.1.100Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 192.168.1.100, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 64/87/144 ms R4#七、配置GLBPR1#conf tR1(config)#int e0/0R1(config-if)#glbp 1 ip 192.168.1.254R1(config-if)#glbp 1 priority 200R1(config-if)#glbp 1 preemptR1(config-if)#glbp 1 authentication md5 key-string cisco R1(config-if)#exitR1(config)#exitR1#R2#conf tR2(config)#int e0/0R2(config-if)#glbp 1 ip 192.168.1.254R2(config-if)#glbp 1 priority 180R2(config-if)#glbp 1 preemptR2(config-if)#glbp 1 authentication md5 key-string cisco R2(config)#exitR2#R3#conf tR3(config)#int e0/0R3(config-if)#glbp 1 ip 192.168.1.254R3(config-if)#glbp 1 priorityR3(config-if)#glbp 1 priority 160R3(config-if)#glbp 1 preemptR3(config-if)#glbp 1 authentication md5 key-string cisco R3(config-if)#exitR3(config)#exitR3#八、查看GLBPR1#sh glbpEthernet0/0 - Group 1State is Active2 state changes, last state change 00:06:16 Virtual IP address is 192.168.1.254Hello time 3 sec, hold time 10 secNext hello sent in 1.648 secsRedirect time 600 sec, forwarder time-out 14400 sec Authentication MD5, key-string "cisco"Preemption enabled, min delay 0 secActive is localStandby is 192.168.1.2, priority 180 (expires in 9.548 sec)Priority 200 (configured)Weighting 100 (default 100), thresholds: lower 1, upper 100Load balancing: round-robinGroup members:cc00.0270.0000 (192.168.1.1) localcc01.0270.0000 (192.168.1.2) authenticatedcc02.0270.0000 (192.168.1.3) authenticatedThere are 3 forwarders (1 active)Forwarder 1State is Active1 state change, last state change 00:06:06MAC address is 0007.b400.0101 (default)Owner ID is cc00.0270.0000Redirection enabled--More--*Mar 1 00:40:12.979: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on Ethernet0/1 (not full duplex), with SW2 FastEthernet0/1 (full duplex).*Mar 1 00:40:13.035: %CDP-4-DUPLEX_MISMATCH: duplex mismatch discovered on Ethernet0/0 (not full duplex), with SW1 FastEthernet0/1 (full duplex).Preemption enabled, min delay 30 secActive is local, weighting 100Forwarder 2State is ListenMAC address is 0007.b400.0102 (learnt)Owner ID is cc01.0270.0000Redirection enabled, 598.468 sec remaining (maximum 600 sec)Time to live: 14397.876 sec (maximum 14400 sec)Preemption enabled, min delay 30 secActive is 192.168.1.2 (primary), weighting 100 (expires in 7.064 sec)Forwarder 3State is ListenMAC address is 0007.b400.0103 (learnt)Owner ID is cc02.0270.0000Redirection enabled, 599.580 sec remaining (maximum 600 sec)Time to live: 14399.376 sec (maximum 14400 sec)Preemption enabled, min delay 30 secActive is 192.168.1.3 (primary), weighting 100 (expires in 8.920 sec)R1#。