HSRP配置命令加三层交换机的实验

     热备份路由器协议(HSRP)的设计目标是支持特定情况下 IP 流量失败转移不会引起混乱、并允许主机使用单路由器,以及即使在实际第一跳路由器使用失败的情形下仍能维护路由器间的连通性。实现HSRP的条件是系统中有多台路由器,它们组成一个"热备份组",这个组形成一个虚拟路由器。换句话说,当源主机不能动态知道第一跳路由器的 IP 地址时,HSRP 协议能够保护第一跳路由器不出故障。


下面对拓扑图进行配HSRP的配置命令:


blob.png



SW的配置命令:


sw(config)#no ip routing    关闭路由功能


sw(config)#vlan 10,20   创建vlan

                     

sw(config)#int f1/0

switchport access vlan 10

sw(config)#int f1/1

sw(config-if)#switchport access vlan 20     划分vlan


sw(config)#int f1/2

sw(config-if)#switchport mode trunk

sw(config)#int f1/3

sw(config-if)#switchport mode trunk       接口改为trunk接口   



SW-3L的配置:


sw-3L(config)#vlan 10,20     创建vlan


sw-3L(config)#int f1/0

sw-3L(config-if)#switchport mode trunk  改为trunk接口


sw-3L(config)#int f1/1

sw-3L(config-if)#switchport access vlan 1    划分vlan1  vlan1是三层交换机默认的


sw-3L(config)#int vlan 1

sw-3L(config-if)#ip add 192.168.30.1 255.255.255.0

sw-3L(config-if)#no shut

sw-3L(config)#int  vlan 10

sw-3L(config-if)#ip add 192.168.10.100 255.255.255.0

sw-3L(config-if)#no shut

sw-3L(config)#int vlan 20

sw-3L(config-if)#ip add 192.168.20.100 255.255.255.0

sw-3L(config-if)#no shut                                       vlan配置网关和掩码


sw-3L(config)#int vlan 10

sw-3L(config-if)#standby 1 ip 192.168.10.1    设置虚拟HSRP的ip网关   1是分组

sw-3L(config-if)#standby 1 priority 150       配置HSRP的优先级    优先级范围是0~255    默认是100   

sw-3L(config-if)#standby 1 preempt          配置HSRP的占先权

sw-3L(config-if)#standby 1 track f1/1       跟踪端口  


sw-3L(config)#int vlan 20                      

sw-3L(config-if)#standby 2 ip 192.168.20.1 

sw-3L(config-if)#standby 2 priority 95

sw-3L(config-if)#standby 2 preempt             这是2组备份


sw-3L(config)#router ospf 110

sw-3L(config-router)#network 192.168.10.0 0.0.0.255 area 0

sw-3L(config-router)#network 192.168.20.0 0.0.0.255 area 0

sw-3L(config-router)#network 192.168.30.0 0.0.0.255 area 0   设置动态路由OSPF


R3的配置命令:


R3(config)#int f0/1

R3(config-if)#ip add 192.168.40.1 255.255.255.0

R3(config-if)#no shut                                   设置端口ip


R3(config)#int f0/0

R3(config-if)#no shut      开启端口


R3(config)#int f0/0.10

R3(config-subif)#encapsulation dot1Q 10

R3(config-subif)#ip add 192.168.10.200 255.255.255.0

R3(config-subif)#no shut                                   

R3(config)#int f0/0.20

R3(config-subif)#encapsulation dot1Q 20

R3(config-subif)#ip add 192.168.20.200 255.255.255.0

R3(config-subif)#no shut                                   设置单臂路由



R3(config)#int f0/0.10

R3(config-subif)#standby 1 ip 192.168.10.1

R3(config-subif)#standby 1 priority 145

R3(config-subif)#standby 1 preempt             设置1组备份


R3(config)#int f0/0.20

R3(config-subif)#standby 2 ip 192.168.20.1

R3(config-subif)#standby 2 preempt

R3(config-subif)#standby 2 track f0/1              创建HSRP      步骤以上有解释,不做多解释


R3(config)#router ospf 110

R3(config-router)#network 192.168.10.0 0.0.0.255 area 0

R3(config-router)#network 192.168.40.0 0.0.0.255 area 0

R3(config-router)#network 192.168.40.0 0.0.0.255 area 0    设置动态路由OSPF


R1的配置命令:

R1(config)#int f0/0

R1(config-if)#ip add 192.168.30.2 255.255.255.0

R1(config-if)#no shut

R1(config)#int f0/1

R1(config-if)#ip add 192.168.40.2 255.255.255.0

R1(config-if)#no shut

R1(config)#int f1/0

R1(config-if)#ip add 12.0.0.1 255.255.255.0

R1(config-if)#no shut                             配置端口ip



R1(config)#router ospf 110

R1(config-router)#network 192.168.30.0 0.0.0.255 area 0

R1(config-router)#network 192.168.40.0 0.0.0.255 area 0

R1(config-router)#network 12.0.0.0 0.0.0.255 area 0         设置动态路由


R5的配置命令:

R5(config)#int f0/0

R5(config-if)#ip add 12.0.0.2 255.255.255.0

R5(config-if)#no shut                           配置端口



R5(config)#router ospf 110

R5(config-router)#network 12.0.0.0 0.0.0.255 area 0    设置动态路由



VPCS设置IP,然后尝试pc1和pc2访问R5,看看通过HSRP往哪里访问:

blob.png

blob.png




blob.png

blob.png


关闭sw-3L的端口,看看pc1是否通过R3访问R5:

blob.pngblob.png

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章