单臂路由
两台PC分别属于不同的VLAN,分别有各自的网关,最后需要由路由器为两个网关增加直接路由达到通信的目的。重点是交换机1到路由器0处的链接,两台PC通信请求的包都要通过此条链接。
Swith0配置:
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname A
A(config)#vlan 20
A(config-vlan)#int f0/3
A(config-if)#sw
A(config-if)#switchport mode ac
A(config-if)#switchport mode access
A(config-if)#sw
A(config-if)#switchport ac
A(config-if)#switchport access vlan 20 //加入VLAN
A(config-if)#exit
A(config)#int rang f0/1-2
A(config-if-range)#sw
A(config-if-range)#switchport mode trunk
A(config-if-range)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/2, changed state to up
A#
%SYS-5-CONFIG_I: Configured from console by console
A#conf t
Enter configuration commands, one per line. End with CNTL/Z.
A(config)#spanning-tree mode rapid-pvst
A(config)#end
A#
%SYS-5-CONFIG_I: Configured from console by console
A#sh sp
A#sh spanning-tree
VLAN0001
Spanning tree enabled protocol rstp
Root ID Priority 32769
Address 0001.C758.46DE
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32769 (priority 32768 sys-id-ext 1)
Address 0001.C758.46DE
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
VLAN0020
Spanning tree enabled protocol rstp
Root ID Priority 32788
Address 0001.C758.46DE
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32788 (priority 32768 sys-id-ext 20)
Address 0001.C758.46DE
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/1 Desg FWD 19 128.1 P2p
Fa0/2 Desg FWD 19 128.2 P2p
Fa0/3 Desg FWD 19 128.3 P2p
A#
Swith1配置:
Switch>
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname B
B(config)#int f0/3
B(config-if)#exit
B(config)#vlan 30
B(config-vlan)#end
B#
%SYS-5-CONFIG_I: Configured from console by console
B#conf t
Enter configuration commands, one per line. End with CNTL/Z.
B(config)#int f0/3
B(config-if)#switchport mode access
B(config-if)#switchport access vlan 30 //加入VLAN
B(config-if)#end
B#
%SYS-5-CONFIG_I: Configured from console by console
B#conf t
Enter configuration commands, one per line. End with CNTL/Z.
B(config)#int rang f0/1-2
B(config-if-range)#switchport mode trunk
B(config-if-range)#end
B#
%SYS-5-CONFIG_I: Configured from console by console
B#conf t
Enter configuration commands, one per line. End with CNTL/Z.
B(config)#int f0/24
B(config-if)#switchport mode trunk
B(config-if)#end
B#
%SYS-5-CONFIG_I: Configured from console by console
B#
路由器配置,针对两个网关做出两个虚拟子接口。
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0.20
Router(config-subif)#ip address 2.2.2.22 255.0.0.0
% Configuring IP routing on a LAN subinterface is only allowed if that
subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q,
or ISL vLAN.
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 2.2.2.22 255.0.0.0
Router(config-subif)#end
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0.30
Router(config-subif)#encapsulation dot1Q 30
Router(config-subif)#ip address 3.3.3.33 255.0.0.0
Router(config-subif)#end
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router0配置:
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#no sh
Router(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
%LINK-5-CHANGED: Interface FastEthernet0/0.20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.20, changed state to up
%LINK-5-CHANGED: Interface FastEthernet0/0.30, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.30, changed state to up
Router(config-if)#
Router(config-if)#
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#
最后验证:
发现网络不通,说明生成树协议使用不正确。
把生成树协议去掉:
A#conf t
Enter configuration commands, one per line. End with CNTL/Z.
A(config)#no spanning-tree mode rapid-pvst
A(config)#
B#conf t
Enter configuration commands, one per line. End with CNTL/Z.
B(config)#
B(config)#
B(config)#no spanning-tree mode rapid-pvst
B(config)#
B#
%SYS-5-CONFIG_I: Configured from console by console
验证结果:
2.2.2.2可以ping通3.3.3.3
疑问,现在是否会有环路产生?因为f0/1-2 同时都是trunck模式。
去掉一条链接,测试发现网络还是通的,说明起到了一定的备份链路作用。