新浪博客

Cisco Packet Tracer试验:实现VLAN的负载均衡

2012-03-15 10:38阅读:
  以前曾经介绍过在Cisco Packet Tracer中进行Vlan负载均衡的实验。那次做的比较简单,有些地方说得不明白也不细致,今天做一补充。这次实验通过两种方法来实现Vlan的负载均衡,第一种是switchport trunk allowed vlan vlanid命令;第二种方法是利用STP(Spanning-Tree Protocol),STP不仅可以实验Vlan的负载均衡还可以实验链路冗余备份是最佳的方法。
Cisco <wbr>Packet <wbr>Tracer试验:实现VLAN的负载均衡
图一 Cisco Packet Tracer实验图
 对上图的一些说明:两个交换机通过两个GigabitEthernet端口相连。共创建两个VLAN,Vlan 100与Vlan 200。
  一、利用switchport trunk allowed vlan vlanid命令实现Vlan负载均衡
  分别在两个交换机上创建两个VLan:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(
config)#vlan 100
Switch(config-vlan)#vlan 200
Switch(config-vlan)#
查看创建的Vlan信息
Switch(config-vlan)#do show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -----------------------------
--
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gig0/1, Gig0/2
100 VLAN0100 active
200 VLAN0200 active
1002 fddi-default act/unsup
1003 token-ring-default act/unsup
1004 fddinet-default act/unsup
1005 trnet-default act/unsup
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
100 enet 100100 1500 - - - - - 0 0
200 enet 100200 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0
Remote SPAN VLANs
------------------------------------------------------------------------------
Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------
Switch(config-vlan)#
  在两个计算机上把相应的端口划到两个VLan内。
Switch(config-vlan)#int f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 100
Switch(config-if)#int fa0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 200
Switch(config-if)#
  配置trunk端口:
Switch(config-if)#int gig0/1
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed
state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed
state to up
Switch(config-if)#switchport trunk allowed vlan 100
Switch(config-if)#int gig0/2
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)#switchport mode trunk
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed
state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed
state to up
Switch(config-if)#switchport trunk allowed vlan 200
Switch(config-if)#
  为计算机配置IP地址,检查网络是否通畅:
Vlan 100的网络地址:192.168.100.0;Vlan 200的网络地址:192.168.200.0
  以上配置实现了每个Vlan一个专用链路,实现了负载均衡。当某一个链路Down掉后,
其中的一个Vlan通信将中断。
  二、利用STP实现Vlan的负载均衡及链路冗余备份
  去掉前面的一些配置:
Switch(config-if)#no switchport trunk allowed vlan 200
Switch(config-if)#int gig0/1
Switch(config-if)#no switchport trunk allowed vlan 100
Switch(config-if)#
  为Vlan配置STP:
在一个交换上配置:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#spanning-tree vlan 100 root primary
Switch(config)#
在另一个交换相配置:
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#spanning-tree vlan 200 root primary
Switch(config)#
在一个交换机查看配置:
Switch#sh spanning-tree vlan 100
VLAN0100
Spanning tree enabled protocol ieee
Root ID Priority 24676
Address 0040.0BAB.E471
Cost 4
Port 25(GigabitEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32868 (priority 32768 sys-id-ext 100)
Address 000B.BE94.BD7A
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi0/2 Altn BLK 4 128.26 P2p
Gi0/1 Root FWD 4 128.25 P2p
Fa0/1 Desg FWD 19 128.1 P2p
Switch#sh spanning-tree vlan 200
VLAN0200
Spanning tree enabled protocol ieee
Root ID Priority 24776
Address 000B.BE94.BD7A
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 24776 (priority 24576 sys-id-ext 200)
Address 000B.BE94.BD7A
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi0/2 Desg FWD 4 128.26 P2p
Gi0/1 Desg FWD 4 128.25 P2p
Fa0/2 Desg FWD 19 128.2 P2p
Switch#
  在另一个交换查看配置:
Switch#sh spanning-tree vlan 100
VLAN0100
Spanning tree enabled protocol ieee
Root ID Priority 24676
Address 0040.0BAB.E471
Cost 4
Port 25(GigabitEthernet0/1)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32868 (priority 32768 sys-id-ext 100)
Address 000B.BE94.BD7A
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi0/2 Altn BLK 4 128.26 P2p
Gi0/1 Root FWD 4 128.25 P2p
Fa0/1 Desg FWD 19 128.1 P2p
Switch#sh spanning-tree vlan 200
VLAN0200
Spanning tree enabled protocol ieee
Root ID Priority 24776
Address 000B.BE94.BD7A
This bridge is the root
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 24776 (priority 24576 sys-id-ext 200)
Address 000B.BE94.BD7A
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 20
Interface Role Sts Cost Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Gi0/2 Desg FWD 4 128.26 P2p
Gi0/1 Desg FWD 4 128.25 P2p
Fa0/2 Desg FWD 19 128.2 P2p
Switch#
 
  从上面的信息中看出来什么了吗?
Cisco <wbr>Packet <wbr>Tracer试验:实现VLAN的负载均衡
图 二 手动把一条链路Down掉,每个Vlan的计算机仍然可以互相访问。
Cisco <wbr>Packet <wbr>Tracer试验:实现VLAN的负载均衡
图三
Cisco <wbr>Packet <wbr>Tracer试验:实现VLAN的负载均衡
图四

我的更多文章

下载客户端阅读体验更佳

APP专享