交换机配置如下,(红色字体为配置内容)
SW1
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host sw1
定义交换机名称
sw1(config)#exit
sw1#vlan database
sw1(vlan)#vlan 2 name v2
为
vlan
设置名称
VLAN 2 added:
Name: v2
sw1(vlan)#vlan 3 name v3
VLAN 3 added:
Name: v3
sw1(vlan)#exit
sw1#conf tleted.Exiting....
Enter configuration commands, one per line. End with CNTL/Z.
sw1(config)#int f0/2
把交换机端口分配到
vlan
sw1(config-if)#switchport mode access
定义
VLAN
端口的成员关系
sw1(config-if)#switchport access vlan 2
sw1(config-if)#exit
sw1(config)#int f0/3
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 3
sw1(config-if)#exit
sw1(config)#int f0/1
sw1(config-if)#switchport trunk encapsulation dot1q
定义干线封装协议标示
sw1(config-if)#switchport mode trunk
定义干线
sw1(config-if)#switchport trunk allowed vlan all
SW2
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host sw2
sw2(config)#exit
sw2#vlan database
sw2(vlan)#vlan 2 name v2
VLAN 2 added:
Name: v2
sw2(vlan)#vlan 3 name v3
VLAN 3 added:
Name: v3
sw2(vlan)#exit
APPLY completed.
Exiting....
sw2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
sw2(config)#int f0/3
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 2
sw2(config-if)#exit
sw2(config)#int f0/5
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 3
sw2(config-if)#exit
sw2(config)#int f0/1
sw2(config-if)#switchport trunk encapsulation dot1q
sw2(config-if)#switchport mode trunk
sw2(config-if)#switchport trunk allowed vlan all
sw2(config-if)#exit
show vlan-switch brief
查看
vlan
信息。
SW1
sw1#show vlan-switch brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15
2 v2 active Fa0/2
3 v3 active Fa0/3
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
SW2
sw2#show vlan-switch brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/0, Fa0/2, Fa0/4, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15
2 v2 active Fa0/3
3 v3 active Fa0/5
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
如上内容显示
vlan2
(
v2
)
vlan3 (v3)
为
active
状态。
试验成功!