注意事项:
第一:3层交换机要用NM-16ESW的交换模块!这样在接口配置时才支持switvhport命令!对应的端口也就是fa1/开头的!
第二:两天主机是用VPCS模拟的
第三:配置完毕后,路由器和三层交换机相连的接口会提示双工不匹配,先把路由接口的带宽改成10000KB 也就是speed 然后在设置成半双工half-duplex 如果三层交换机和路由器都用全双工,交换接口会自动变会半双工,结果双工又不匹配了!我做出来的结果是这样!所有还是用半双工吧!
R1:
R1#vlan database
R1(vlan)#vlan 10
R1(vlan)#vlan 20
R1(config)#int fa1/2
R1(config-if)#switchport trunk encapsulation dot1q //封装
R1(config-if)#switchport mode trunk //trunk模式
R1(config-if)#int fa1/1
R1(config-if)#switchport trunk encapsulation dot1q
R1(config-if)#switchport mode trunk
R1(config-if)#int fa0/1
R1(config-if)#ip add 12.1.1.1 255.255.255.252
R1(config-if)#no sh
R1(config-if)#int vlan 10
R1(config-if)#ip add 192.168.10.2 255.255.255.0 /SVI
R1(config-if)#no sh
R1(config-if)#int vlan 20
R1(config-if)#ip add 192.168.10.2 255.255.255.0
R1(config-if)#no sh
R1(config-if)#router ei 1
R1(config-router)#net 12.1.1.1
R1(config-router)#net 192.168.10.0
R1(config-router)#net 192.168.20.0
R1(config-router)#no auto-summary
R1(config)#spanning-tree vlan 10 root primary //R1是vlan10的根网桥,vlan20的备份网桥
R1(config)#spanning-tree vlan 20 root secondary
R1(config-if)#int vlan 10
R1(config-if)#standby 10 ip 192.168.10.100//虚拟网关
R1(config-if)#standby 10 priority 110//R1是vlan10的 Active路由器
R1(config-if)#standby 10 preempt
R1(config-if)#int vlan 20
R1(config-if)#standby 20 ip 192.168.20.100//R2是vlan10的 备份路由器
R1(config-if)#standby 20 preempt
R2(vlan)#vlan 10
R2(vlan)#vlan 20
R2(config)#int fa1/2
R2(config-if)#switchport trunk encapsulation dot1q //封装
R2(config-if)#switchport mode trunk //trunk模式
R2(config-if)#int fa1/1
R2(config-if)#switchport trunk encapsulation dot1q
R2(config-if)#switchport mode trunk
R2(config-if)#int fa0/1
R2(config-if)#ip add 23.1.1.1 255.255.255.252
R2(config-if)#no sh
R2(config-if)#int vlan 10
R2(config-if)#ip add 192.168.10.3 255.255.255.0 /SVI
R2(config-if)#no sh
R2(config-if)#int vlan 20
R2(config-if)#ip add 192.168.10.3 255.255.255.0
R2(config-if)#no sh
R2(config-if)#router ei 1
R2(config-router)#net 23.1.1.1
R2(config-router)#net 192.168.10.0
R2(config-router)#net 192.168.20.0
R2(config-router)#no au
R2(config-router)#no auto-summary
R2(config)#spanning-tree vlan 10 root secondary//R1是vlan20的根网桥,vlan10的备份网桥
R2(config)#spanning-tree vlan 20 root primary
R2(config-if)#int vlan 10
R2(config-if)#standby 10 ip 192.168.10.100//R2是vlan10的备份路由器
R2(config-if)#standby preempt
R2(config-if)#int vlan 20
R2(config-if)#standby 20 ip 192.168.20.100//R2是vlan20的 Active路由器
R2(config-if)#standby 20 priority 110
R2(config-if)#standby 20 preempt
R3(config)#int fa0/0
R3(config-if)#ip ad 12.1.1.2 255.255.255.252
R3(config-if)#no sh
R3(config-if)#int fa0/1
R3(config-if)#ip ad 23.1.1.2 255.255.255.252
R3(config-if)#no sh
R3(config-if)#ip ad 3.3.3.3 255.255.255.255
R3(config-if)#router ei 1
R3(config-router)#net 3.3.3.3
R3(config-router)#no au
R3(config-router)#net 12.1.1.0
R3(config-router)#net 23.1.1.0
上面的配置完成后:
R1(config-if)#do show stan bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Vl10 10 110 P Active local 192.168.10.3 192.168.10.100
Vl20 20 100 P Standby 192.168.20.3 local 192.168.20.100
VLAN10
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c200.1b68.0001
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8192
Address c200.1b68.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/1 128.42 128 19 FWD 0 8192 c200.1b68.0001 128.42
FastEthernet1/2 128.43 128 19 FWD 0 8192 c200.1b68.0001 128.43
VLAN20
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c201.1b68.0002
Cost 19
Port 42 (FastEthernet1/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 16384
Address c200.1b68.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/1 128.42 128 19 FWD 0 8192 c201.1b68.0002 128.42
FastEthernet1/2 128.43 128 19 BLK 0 8192 c201.1b68.0002 128.43
R2(config-if)#do show stan bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Vl10 10 100 P Standby 192.168.10.2 local 192.168.10.100
Vl20 20 110 P Active local 192.168.20.2 192.168.20.100
VLAN10
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c200.1b68.0001
Cost 19
Port 42 (FastEthernet1/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 16384
Address c201.1b68.0001
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/1 128.42 128 19 FWD 0 8192 c200.1b68.0001 128.42
FastEthernet1/2 128.43 128 19 BLK 0 8192 c200.1b68.0001 128.43
VLAN20
Spanning tree enabled protocol ieee
Root ID Priority 8192
Address c201.1b68.0002
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 8192
Address c201.1b68.0002
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 300
Interface Designated
Name Port ID Prio Cost Sts Cost Bridge ID Port ID
-------------------- ------- ---- ----- --- ----- -------------------- -------
FastEthernet1/1 128.42 128 19 FWD 0 8192 c201.1b68.0002 128.42
FastEthernet1/2 128.43 128 19 FWD 0 8192 c201.1b68.0002 128.43
HSRP追踪特性:
为配置前:
配置
R2(config-if)#int vlan 20
R2(config-if)#standby 20 track fa0/1 20 //如果接口fa0/1失效,组20的优先级就减少20
R2(config-if)#int fa0/1
R2(config-if)#sh
*Mar 1 01:05:25.467: %HSRP-5-STATECHANGE: Vlan20 Grp 20 state Active -> Speak
R2(config-if)#do show stan bri
P indicates configured to preempt.
|
Interface Grp Prio P State Active Standby Virtual IP
Vl10 10 100 P Standby 192.168.10.2 local 192.168.10.100
Vl20 20 90 P Standby 192.168.20.2 local 192.168.20.100
切换成功