R1:
给端口 (F0/0和F1/0)设置IP地址:R1#conf t
R1(config)#int f0/0
R1()#ip address 172.16.1.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#speed 100
R1(config-if)#duplex full
R1(config-if)#exit
R1(config-if)#exit
R1(config)#int f1/0
R1(config-if)#ip address 192.168.1.254 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#speed 100
R1(config-if)#duplex full
R1(config-if)#end
配置HSRP,优先级,占先权
R1#conf t
R1(config)#int f0/0
R1(config-if)#standby 17 ip 172.16.1.200 //给端口加入热组17,指定虚拟IP地址为172.16.1.200//
R1(config-if)#standby 17 priority 200 //设置HSRP优先级为200//
R1(config-if)#standby 17 preempt //设置HSRP占先权//
R1(config-if)#end
R2配置:
给端口(F0/0和F1/0)设置IP地址:
R2#conf t
R2(config)#int f0/0
R2(config-if)#ip address 172.16.1.253 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#speed 100
R2(config-if)#duplex full
R2(config-if)#exit
R2(config)#int f1/0
R2(config-if)#ip address 192.168.1.253 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#speed 100
R2(config-if)#duplex full
R2(config-if)#end
R2#conf t
R2(config)#int f0/0
R2(config-if)#standby 17 ip 172.16.1.200 //给端口加入热备份组17,指定虚拟IP为172.16.1.200//
R2(config-if)#standby 17 priority 150 //设置HSRP优先级为200//
R2(config-if)#end
在R1上查看HSRP
R1#show standby brief
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 17 200 P Active local 172.16.1.253 172.16.1.200
可以看到在热备份组17中,R1的端口优先级为200,当前活跃的路 由器是R1自己,备份的是R2(172.16.1.253),虚拟IP地址为172.16.1.200
R1#show standby
FastEthernet0/0 - Group 17
State is Active
2 state changes, last state change 00:09:28
Virtual IP address is 172.16.1.200
Active virtual MAC address is 0000.0c07.ac11
Local virtual MAC address is 0000.0c07.ac11 (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 1.704 secs
Preemption enabled
Active router is local
Standby router is 172.16.1.253, priority 150 (expires in 8.236 sec)
Priority 200 (configured 200)
IP redundancy name is "hsrp-Fa0/0-17" (default)
可以看到除了show standby brief能看到的信息外,还有虚拟路由器的MAC地址为0000.0c07.ac11,Hello时间(HelloTime)为3秒,保持时间 (HoldTime)为10秒,并且R1路由器配置了占先权。
接下来我们在路由器另一个接口配置另一个热备份组,使2台路由器实现负载均 衡
R1配 置:
R1#conf t
R1(config)#int f1/0
R1(config-if)#standby 27 ip 192.168.1.200
R1(config-if)#standby 27 priority 150
R1(config-if)#end
R2配置:
R2#conf t
R2(config)#int f1/0
R2(config-if)#standby 27 ip 192.168.1.200 //给端口加入热备份组27,指定虚拟IP地址为192.168.1.200//
R2(config-if)#standby 27 priority 200 //设置HSRP优先级为200//
R2(config-if)#standby 27 preempt //设置HSRP占先权//
R2(config-if)#end
在R2上查看HSRP
2#show standby brief
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Fa0/0 17 150 Standby 172.16.1.254 local 172.16.1.200
Fa1/0 27 200 P Active local 192.168.1.254 192.168.1.200
可以看到在热备份组27中,R2路由器的端口优先级为200,当前活跃的路 由器是R2自己,备份的路由器是R1(192.168.1.254),虚拟IP地址为192.168.1.200
R2#show standby f1/0
FastEthernet1/0 - Group 27
State is Active
1 state change, last state change 00:04:03
Virtual IP address is 192.168.1.200
Active virtual MAC address is 0000.0c07.ac1b
Local virtual MAC address is 0000.0c07.ac1b (v1 default)
Hello time 3 sec, hold time 10 sec
Next hello sent in 2.232 secs
Preemption enabled
Active router is local
Standby router is 192.168.1.254, priority 150 (expires in 7.504 sec)
Priority 200 (configured 200)
IP redundancy name is "hsrp-Fa1/0-27" (default)
可以看到除了show
standbybrief能看到的信息外,在热备份组27中,还有虚拟路由器的MAC地址为0000.0c07.ac1b,Hello时间
(HelloTime)为3秒,保持时间(HoldTime)为10秒,并且R2路由器在热备份组27中配置了占先权。
客户机的配置:
PC1:
IP:172.16.1.1/24
GW:172.168.1.200
PC2:
IP:192.168.1.1/24
GW:192.168.1.200
测试:
PC1#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 68/246/396 ms
总结:
这里我们做了2个热备份组,在R1的F0/0和R2的F0/0中我们做了热 备份组17,并且在热备份组17中,活跃的路由器是R1,因为我们配置了R1在热备份组17中的优先级为200,这样在PC1与PC2通信时,真正转发数 据的是R1路由器。
我们又在R1的F1/0和R2的F1/0中我们做了热备份组27,并且在热备份组27中,活跃的路由器是R2,因为我们配置了R2在热备份组27中的优先 级为200,这样PC2与PC1进行通信时,真正转发数据的是R2路由器。
这样,我们在热备份组17中活跃的路由器是R1,而在热备份组27中活跃的路由器是R2,所以我们也实现了路由器R1和R2的负载均衡。
阅读(570) | 评论(0) | 转发(1) |