思科设备三层交换机的vlan间通信配置
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
本次主要讲解三层交换实现vlan间的相互通信:
本例配置模型图
命令行:
swA配置命令:
Switch>enable
Switch#vlan database //进入vlan配置模式
% Warning: It is recommended to configure VLAN from config mode, as VLAN database mode is being deprecated. Please consult user documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2 name TztA //在swA上创建vlan 2 名为TztA VLAN 2 added:
Name: TztA
Switch(vlan)#vlan 3 name TztB //在swA上创建vlan 3 名为TztB VLAN 3 added:
Name: TztB
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#int f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2 //将f0/2划分给vlan 2
Switch(config-if)#exit
Switch(config)#int f0/3
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 3 //将f0/3划分给vlan 3
Switch(config-if)#exit
Switch(config)#int f0/1
Switch(config-if)#switchport mode trunk //配置与三层设备连接的f0/1为trunk模式
%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
Switch(config-if)#switchport trunk allowed vlan all //允许所有vlan通过f0/1端口Switch(config-if)#exit
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#wr
Building configuration...
[OK]
Switch#
(三层交换机)M sw命令配置:
Switch>
Switch>enable
Switch#vlan database //进入vlan配置模式
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2 name TztA //在Msw上创建vlan 2 名为TztA
VLAN 2 added:
Name: TztA
Switch(vlan)#vlan 3 name TztB //在Msw上创建vlan 2 名为TztA
VLAN 3 added:
Name: TztB
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/1
Switch(config-if)#switchport mode trunk //配置三层设备与二层设备连接的f0/1为trunk模式
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Switch(config-if)#switchport trunk allowed vlan all //允许所有vlan通过f0/1端口Switch(config-if)#no shutdown //激活端口
Switch(config-if)#exit
Switch(config)#ip routing //使用三层设备的路由功能
Switch(config)#int vlan 2 //进入vlan 2配置模式虚拟端口
%LINK-5-CHANGED: Interface Vlan2, changed state to up
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to up
Switch(config-if)#ip address 192.168.1.1 255.255.255.0 //配置vlan 2的ip地址Switch(config-if)#no shutdown //激活端口
Switch(config-if)#exit
Switch(config)#int vlan 3 //配置vlan 3虚拟端口
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#do show ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2