当前位置:文档之家› 51CTO下载-Cisco-3560配置手册

51CTO下载-Cisco-3560配置手册

51CTO下载-Cisco-3560配置手册
51CTO下载-Cisco-3560配置手册

3560客户中文配置手册

第1章概述1-1

1.1 概述1-1

1.2 初次访问设备1-2

1.2.1 通过Console口访问设备1-2

第2章命令行方式访问设备2-1

2.1.1 命令行模式2-1

2.1.2 基本设置命令2-1

2.2 通过Console口进入命令行接口2-2

2.3 通过Telnet进入命令行接口2-2

第3章接口配置3-1

3.1 概述3-1

3.2 二层口配置3-1

3.2.1 配置端口速率及双工模式3-1

3.3 配置一组端口3-2

3.4 配置三层口3-3

3.5 监控及维护端口3-5

3.5.1 监控端口和控制器的状态3-5

3.5.2 刷新、重置端口及计数器3-7

3.5.3 关闭和打开端口3-8

3.6 交换机端口镜像配置3-9

3.6.1 创建一个本地SPAN会话3-10

3.7 以太通道端口组(Ethernet Port Groups)3-11

第4章配置VLAN 4-12

4.1 简介4-12

4.2 可支持的VLAN 4-12

4.3 配置正常范围的VLAN 4-12

4.3.1 删除VLAN 4-14

4.3.2 将端口分配给一个VLAN 4-15

4.4 配置VLAN Trunks 4-16

4.5 配置VTP DOMAIN 4-18

4.6 配置VLAN接口地址4-18

第5章交换机HSRP配置5-1

第6章路由协议配置6-3

6.1.1 静态路由6-3

6.1.2 RIP路由6-3

6.1.3 OSPF路由6-5

第1章概述

1.1 概述

3560交换机是支持二层、三层功能的交换机,共分为EMI,SMI两个版本

Enhanced Multilayer Software Image增强多层软件镜像软件(EMI)

? EMI提供了一组更加丰富的企业级功能,包括基于硬件的高级IP单播和多播路由。

? 支持双机热备(HSRP),OSPF路由功能.

Standard Multilayer Software Image标准多层软件镜像软件(SMI)

? SMI功能集包括高级QoS、速率限制、访问控制列表(ACL),以及基本的静态和路由信息协议(RIP)路由功能

支持VLAN

? 到1005 个VLAN

?支持VLAN ID从1到4094(IEEE 802.1Q 标准)

?支持ISL及IEEE 802.1Q封装

安全

?支持IOS标准的密码保护

?静态MAC地址映射

? 标准及扩展的访问列表支持,对于路由端口支持入出双向的访问列表,对于二层端口支持入的访问列表

? 支持基于VLAN的访问列表

3层支持(需要多层交换的IOS)

? HSRP

?IP路由协议

o RIP versions 1 and 2

o OSPF

o IGRP及EIGRP

o BGP Version 4

支持以下SFP模块:

?1000BASE-T SFP: 铜线最长100 m

? 1000BASE-SX SFP: 光纤最长1804 feet (550 m)

? 1000BASE-LX/LH SFP: 光纤最长32,808 feet (6 miles or 10 km)

?1000BASE-ZX SFP: 光纤最长328,084 feet (62 miles or 100 km)

管理

从用户与设备交互的特点来分,访问设备的方式可以分为命令行方式和Web方式。

l 命令行方式:包括从Console口登录进行访问和通过T elnet登录进行访问;

l Web方式:包括通过HTTP进行的普通Web访问。

1.2 初次访问设备

1.2.1 通过Console口访问设备

用户接收到除去包装的新设备后一般通过Console口第一次登录设备并开始对设备进行配置,过程如下:第一步:建立本地配置环境,只需将计算机(或终端)的串口通过标准RS-232电缆与此Catalyst 3560设备的Console口连接

第二步:在计算机上运行终端仿真程序(如WinXP的超级终端等),设置终端通信参数为9600bps、8位数据位、1位停止位、无奇偶校验和无流量控制,如图1-1至图1-3所示。

图1-1 新建连接

图1-2 连接端口设置

图1-3 端口通信参数设置

第四步:Catalyst 3560设备上电自检,出现命令行提示符,如:Switch>。

此时用户已经进入到设备命令行配置接口的用户模式,从这里开始就可以参考本手册其余章节对设备进行配置。

第2章命令行方式访问设备

如果用户通过Console口登录,或者通过Telne从设备管理口登录都将进入到设备的命令行接口,对系统的配置和交互都通过命令行的方式进行。。

2.1.1 命令行模式

命令行接口提供的命令行视图和各视图的功能特性、进入各视图的命令等的细则如表2-1所示。

表2-1 命令视图功能特性列表

模式功能提示符进入命令退出命令

非特权模式查看CISCO 设备的简单运行状态Switch> 开机时自动进入

特权模式配置系统参数,升级IOS软件,备份配置文件Switch# 在非特权模式下键入ENABLE quit返回非特权模式

全局模式CISCO交换机大部分配置都是在这个模式下进行Switch(config)# 在特权模式下键入configure terminal quit返回特权模式

监控模式升级IOS系统软件Switch:开机时摁住面板上的MODE键约5秒钟

2.1.2 基本设置命令

基本设置命令

任务命令

全局设置config terminal

设置访问用户及密码Username username password password

设置特权密码enable secret password

设置路由器名Hostname name

设置静态路由ip route destination subnet-mask next-hop

启动IP路由ip routing

启动IPX路由ipx routing

端口设置interface type slot/number

设置IP地址ip address address subnet-mask

设置IPX网络ipx network network

激活端口no shutdown

物理线路设置line type number

启动登录进程login [local|tacacs server]

设置登录密码Password password

显示命令

任务命令

查看版本及引导信息show version

查看运行设置show running-config

查看开机设置show startup-config

显示端口信息show interface type slot/number

显示路由信息show ip route

2.2 通过Console口进入命令行接口

详细内容请参见?1.2.1 通过Console口访问设备?。

2.3 通过Telnet进入命令行接口

Telnet协议在TCP/IP协议族中属于应用层协议,通过网络提供远程登录和虚拟终端功能。CATALYST 3560向用户提供Telnet服务,

第一步:在计算机上运行Telnet程序,键入CATALYST 3560设备管理IP地址

Switch>enable

Switch#conf t

Switch(config)# interface vlan 1

Switch(config-if)#ip address 10.1.1.20 255.255.255.0

Switch(config-if)#no shutdown

Switch(config-if)#exit

Switch(config)#line vty 0 4

Switch(config-line)#login

Switch(config-line)#password cisco

如图2-1所示。

图2-1 与CATALYST 3560建立Telnet连接

& 说明:

图2-1中的IP地址为CATALYST 3560设备IP地址,即vlan1的接口地址

第3章接口配置

3.1 概述

Catalyst 3560支持的以太网接口说明请见下表。

表3-1 Catalyst 3560接口说明

项目说明

接口类型FE电接口:符合100Base-TX物理层规范

GE电接口:1000Base-TX物理层规范

工作速率FE电接口可以选择10Mbit/s、100Mbit/s两种速率

GE电接口可以选择10Mbit/s、100Mbit/s、1000Mbit/s三种速率

工作模式自动协商模式

3.2 二层口配置

3560的所有端口缺省的端口都是二层口,如果此端口已经配置成三层端口的话,则需要用switchport来使其成为二层端口。

3.2.1 配置端口速率及双工模式

1. 可以配置快速以太口的速率为10/100Mbps及千兆以太口的速率为10/100/1000-Mbps; 但对于SFP端

口则不能配置速率及双工模式,有时可以配置nonegotiate,当需要联接不支持自适应的其它千兆端口时

表3-2 管理口配置

命令目的

Step 1 configure terminal 进入配置状态.

Step 2 interface interface-id 进入端口配置状态.

Step 3 speed {10 | 100 | 1000 | auto | nonegotiate} 设置端口速率注 1000 只工作在千兆口. GBIC模块只工作在1000 Mbps下. nonegotiate 只能在这些GBIC上用1000BASE-SX, -LX, and -ZX GBIC.

Step 4 duplex {auto | full | half} 设置全双工或半双工.

Step 5 end 退出

Step 6 show interfaces interface-id 显示有关配置情况

Step 7 copy running-config startup-config 保存

Switch# configure terminal

Switch(config)# interface fastethernet0/3

Switch(config-if)# speed 10

Switch(config-if)# duplex half

3.3 配置一组端口

命令目的

Step 1 configure terminal 进入配置状态

Step 2 interface range {port-range} 进入组配置状态

Step 3 可以使用平时的端口配置命令进行配置

Step 4 end 退回

Step 5 show interfaces [interface-id] 验证配置

Step 6 copy running-config startup-config 保存

见以下例子:

Switch# configure terminal

Switch(config)# interface range fastethernet0/1 - 5

Switch(config-if-range)# no shutdown

Switch(config-if-range)#

*Oct 6 08:24:35: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up

*Oct 6 08:24:35: %LINK-3-UPDOWN: Interface FastEthernet0/2, changed state to up

*Oct 6 08:24:35: %LINK-3-UPDOWN: Interface FastEthernet0/3, changed state to up

*Oct 6 08:24:35: %LINK-3-UPDOWN: Interface FastEthernet0/4, changed state to up

*Oct 6 08:24:35: %LINK-3-UPDOWN: Interface FastEthernet0/5, changed state to up

*Oct 6 08:24:36: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/05,

changed state to up

*Oct 6 08:24:36: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

*Oct 6 08:24:36: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/4, changed state to up

以下的例子显示使用句号来配置不同类型端口的组:

Switch# configure terminal

Switch(config)# interface range fastethernet0/1 - 3, gigabitethernet0/1 - 2

Switch(config-if-range)# no shutdown

Switch(config-if-range)#

*Oct 6 08:29:28: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up

*Oct 6 08:29:28: %LINK-3-UPDOWN: Interface FastEthernet0/2, changed state to up

*Oct 6 08:29:28: %LINK-3-UPDOWN: Interface FastEthernet0/3, changed state to up

*Oct 6 08:29:28: %LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to up

*Oct 6 08:29:28: %LINK-3-UPDOWN: Interface GigabitEthernet0/2, changed state to up

*Oct 6 08:29:29: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/ 1,

changed state to up

*Oct 6 08:29:29: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/ 2,

changed state to up

*Oct 6 08:29:29: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/ 3,

changed state to up

3.4 配置三层口

Catalyst 3560支持三种类型的三层端口:

?SVIs: 即interface vlan

Note 当生成一个interface Vlan时,只有当把某一物理端口分配给它时才能被激活

? 三层以太网通道口(EtherChannel): :以太通道由被路由端口组成。以太通道端口接口在?配置以太通道?中被描述。

? .路由口:路由口是指某一物理端口在端口配置状态下用no switchport命令生成的端口

所有的三层都需要IP地址以实现路由交换

配置步骤如下:

命令目的

Step 1 configure terminal 进入配置状态

Step 2 interface {{fastethernet | gigabitethernet} interface-id} | {vlan vlan-id} | {port-channel port-channel-number} 进入端口配置状态

Step 3 no switchport 把物理端口变成三层口

Step 4 ip address ip_address subnet_mask 配置IP地址和掩码

Step 5 no shutdown 激活端口

Step 6 End 退出

Step 7 show interfaces [interface-id]show ip interface [interface-id]show running-config interface [interface-id] 验证配置

Step 8 copy running-config startup-config 保存配置

配置举例如下:

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)# interface gigabitethernet0/2

Switch(config-if)# no switchport

Switch(config-if)# ip address 192.20.135.21 255.255.255.0

Switch(config-if)# no shutdown

Switch(config-if)# end

3.5 监控及维护端口

3.5.1 监控端口和控制器的状态

主要命令见下表:

Show Commands for Interfaces Command 目的

show interfaces [interface-id] 显示所有端口或某一端口的状态和配置.

show interfaces interface-id status [err-disabled] 显示一系列端口的状态或错误-关闭的状态show interfaces [interface-id] switchport 显示二层端口的状态,可以用来决定此口是否为二层或三层口。

show interfaces [interface-id] description 显示端口描述

show ip interface [interface-id] 显示所有或某一端口的IP可用性状态

show running-config interface [interface-id] 显示当前配置中的端口配置情况

show version 显示软硬件等情况

举例如下:

Switch# show interfaces status

Port Name Status Vlan Duplex Speed Type

Gi0/1 connected routed a-full a-100 10/100/1000Base

TX

Gi0/2 wce server 20.20.2 disabled routed auto auto 10/100/1000Base TX

Gi0/3 ip wccp web-cache notconnect routed auto auto 10/100/1000Base TX

Gi0/4 notconnect routed auto auto 10/100/1000Base TX

Gi0/5 notconnect routed auto auto 10/100/1000Base TX

Gi0/6 disabled routed auto auto 10/100/1000Base TX

Gi0/7 disabled routed auto auto 10/100/1000Base TX

Gi0/8 disabled routed auto 100 10/100/1000Base TX

Gi0/9 notconnect routed auto auto 10/100/1000Base TX

Gi0/10 notconnect routed auto auto 10/100/1000Base TX

Gi0/11 disabled routed auto auto unknown

Gi0/12 notconnect routed auto auto unknown

Switch# show interfaces fastethernet 0/1 switchport

Name: Fa0/1

Switchport: Enabled

Administrative Mode: static access

Operational Mode: down

Administrative Trunking Encapsulation: dot1q

Negotiation of Trunking: Off

Access Mode VLAN: 1 (default)

Trunking Native Mode VLAN: 1 (default)

Trunking VLANs Enabled: ALL

Pruning VLANs Enabled: 2-1001

Protected: false

Unknown unicast blocked: disabled

Unknown multicast blocked: disabled

Voice VLAN: dot1p (Inactive)

Appliance trust: 5

Switch# show running-config interface fastethernet0/2

Building configuration...

Current configuration : 131 bytes

!

interface FastEthernet0/2

switchport mode access

switchport protected

no ip address

mls qos cos 7

mls qos cos override

end

3.5.2 刷新、重置端口及计数器

Clear命令目的

clear counters [interface-id] 清除端口计数器.

clear interface interface-id 重置某一端口的硬件逻辑

clear line [number | console 0 | vty number] 重置异步串口的硬件逻辑

Note clear counters 命令只清除用show interface所显示的计数,不影响用snmp得到的计数

举例如下:

Switch# clear counters fastethernet0/5

Clear "show interface" counters on this interface [confirm] y

Switch#

*Sep 30 08:42:55: %CLEAR-5-COUNTERS: Clear counter on interface FastEthernet0/5

by vty1 (171.69.115.10)

可使用clear interface 或clear line 命令来清除或重置某一端口或串口,在大部分情况下并不需要这样做: Switch# clear interface fastethernet0/5

3.5.3 关闭和打开端口

命令目的

Step 1 configure terminal 进入配置状态

Step 2 interface {vlan vlan-id} | {{fastethernet | gigabitethernet} interface-id} | {port-channel port-channel-number} 选择要关闭的端口

Step 3 Shutdown 关闭

Step 4 End 退出

Step 5 show running-config 验证

使用no shutdown 命令重新打开端口.

举例如下:

Switch# configure terminal

Switch(config)# interface fastethernet0/5

Switch(config-if)# shutdown

Switch(config-if)#

*Sep 30 08:33:47: %LINK-5-CHANGED: Interface FastEthernet0/5, changed state to a administratively down

Switch# configure terminal

Switch(config)# interface fastethernet0/5

Switch(config-if)# no shutdown

Switch(config-if)#

*Sep 30 08:36:00: %LINK-3-UPDOWN: Interface FastEthernet0/5, changed state to up

3.6 交换机端口镜像配置

『端口镜像的数据流程』

基于端口的镜像是把被镜像端口的进出数据报文完全拷贝一份到镜像端口,这样来进行流量观测或者故障定位。

Figure 27-1 Example of Local SPAN Configuration on a Single Switch

3.6.1 创建一个本地SPAN会话

Beginning in privileged EXEC mode, follow these steps to create a SPAN session and specify the source (monitored) ports or VLANs and the destination (monitoring) ports:

Command Purpose

Step 1 configure terminal Enter global configuration mode.

Step 2 no monitor session {session_number | all | local | remote} Remove any existing SPAN configuration for the session. For session_number, the range is 1 to 66. Specify all to remove all SPAN sessions, local to remove all local sessions, or remote to remove all remote SPAN sessions.

Step 3 monitor session session_number source {interface interface-id | vlan vlan-id} [, | -] [both | rx | tx] Specify the SPAN session and the source port (monitored port). For session_number, the range is 1 to 66. For interface-id, specify the source port or source VLAN to monitor. ? For source interface-id, specify the source port to monitor. Valid interfaces include physical interfaces and port-channel logical interfaces (port-channel port-channel-number). Valid port-channel numbers are 1 to 48. ? For vlan-id, specify the source VLAN to monitor. The range is 1 to 4094 (excluding the RSPAN VLAN). Note A single session can include multiple sources (ports or VLANs), defined in a series of commands, but you cannot combine source ports and source VLANs in one session. (Optional) [, | -] Specify a series or range of interfaces. Enter a space before and after the comma; enter a space before and after the hyphen. (Optional) Specify the direction of traffic to monitor. If you do not specify a traffic direction, the SPAN monitors both sent and received traffic. ? both?Monitor both received and sent traffic. This is the default. ? rx?Monitor received traffic. ? tx?Monitor sent traffic. Note You can use the monitor session session_number source command multiple times to configure multiple source ports.

Step 4 monitor session session_number destination {interface interface-id [, | -] [encapsulation replicate]} Specify the SPAN session and the destination port (monitoring port). For session_number, specify the session number entered in step 3. Note For local SPAN, you must use the same session number for the source and destination interfaces. For interface-id, specify the destination port. The destination interface must be a physical port; it cannot be an EtherChannel, and it cannot be a VLAN. (Optional) [, | -] Specify a series or range of interfaces. Enter a space before and after the comma; enter a space before and after the hyphen. (Optional) Enter encapsulation replicate to specify that the destination interface replicates the source interface encapsulation method. If not selected, the default is to send packets in native form (untagged). Note You can use monitor session session_number destination command multiple times to configure multiple destination ports.

Step 5 end Return to privileged EXEC mode.

Step 6 show monitor [session session_number] show running-config Verify the configuration.

Step 7 copy running-config startup-config (Optional) Save the configuration in the configuration file.

举例:通过交换机的第2号口监控第1号口的流量

Switch(config)# monitor session 1 source interface gigabitethernet0/1

Switch(config)# monitor session 1 destination interface gigabitethernet0/2

Switch(config)# end

删除一个span会话:

Switch(config)# no monitor session 1 source interface gigabitethernet0/1

Switch(config)# end

3.7 以太通道端口组(Ethernet Port Groups)

以太通道端口组提供把多个交换机端口像一个交换端口对待。这些端口组为交换机之间或交换机和服务器之间提供一条单独的高带宽连接的逻辑端口。以太通道在一个通道中提供穿越链路的负载平衡。如果以太

通道中的一个链路失效,流量会自动从失效链路转移到被用链路。你可以把多干道端口加到一个逻辑的干道端口;把多访问端口加到一个逻辑访问端口;或者多隧道端口加到一个逻辑的隧道接口。绝大多数的协议能够在单独或是集合的接口上运行,并且不会意识到在端口组中的物理端口。除了DTP、CDP和PAgP,这些协议只能在物理接口上运行。

当你配置一个以太通道,你创建一个端口通道逻辑接口,并且指派一个接口给以太通道。对于三层接口,你人工创建该逻辑接口:

Figure 33-1 Typical EtherChannel Configuration

举例:把交换机A,B的1,2号口添加到同一个组5里面

SwitchA# configure terminal

SwitchA (config)# interface range gigabitethernet0/1 -2

SwitchA (config-if-range)# switchport mode access

SwitchA (config-if-range)# switchport access vlan 10

SwitchA (config-if-range)# channel-group 5 mode ON

Switch(config-if-range)# end

SwitchB# configure terminal

SwitchB(config)# interface range gigabitethernet0/1 -2

SwitchB(config-if-range)# switchport mode access

SwitchB(config-if-range)# switchport access vlan 10

SwitchB(config-if-range)# channel-group 5 mode ON

SwitchB(config-if-range)# end

第4章配置VLAN

4.1 简介

VLAN(Virtual Local Area Network),是一种通过将局域网内的设备逻辑地而不是物理地划分成一个个网段从而实现虚拟工作组的技术。IEEE于1999年颁布了用以标准化VLAN实现方案的IEEE 802.1Q协议标准草案。

VLAN技术允许网络管理者将一个物理的LAN逻辑地划分成不同的广播域(或称虚拟LAN,即VLAN),每一个VLAN都包含一组有着相同需求的计算机,由于VLAN是逻辑地而不是物理地划分,所以同一个VLAN 内的各个计算机无须被放置在同一个物理空间里,即这些计算机不一定属于同一个物理LAN网段。

VLAN的优势在于VLAN内部的广播和单播流量不会被转发到其它VLAN中,从而有助于控制网络流量、减少设备投资、简化网络管理、提高网络安全性。

4.2 可支持的VLAN

Catalyst 3560交换机支持1005个VLAN,可以分别是VTP client, server, 及transparent modes. VLAN 号可以从1到4094. VLAN号1002到1005保留给令牌环及FDDI VLAN. VTP只能学习到普通范围的VLAN, 即从VLAN到1到1005; VLAN号大于1005属于扩展VLAN,不存在VLAN数据庫中。交换机必须配置成VTP透明模式当需要生成VLAN 号从1006到4094.

本交换机支持基于每一VLAN的生成树(PVST),最多支持128个生成树。本交换机支持ISL及IEEE 802.1Q trunk二种封装。

4.3 配置正常范围的VLAN

VLAN号1,1002到1005是自动生成的不能被去掉。

VLAN号1到1005的配置被写到文件vlan.dat 中, 可以用show vlan 命令查看,vlan.dat 文件存放在NVRAM中.

命令目的

Step 1 configure terminal 进入配置状态

Step 2 vlan vlan-id 输入一个VLAN号, 然后进入vlan配置状态,可以输入一个新的VLAN 号或旧的来进行修改。

Step 3 name vlan-name (可选)输入一个VLAN名,如果没有配置VLAN名,缺省的名字是VLAN号前面用0填满的4位数,如VLAN0004是VLAN4的缺省名字

Step 4 mtu mtu-size (可选) 改变MTU大小

Step 5 end 退出

Step 6 show vlan {name vlan-name | id vlan-id} 验证

Step 7 copy running-config startup config (可选) 保存配置

用no vlan name 或no vlan mtu 退回到缺省的vlan配置状态

举例如下:

Switch# configure terminal

Switch(config)# vlan 20

Switch(config-vlan)# name test20

Switch(config-vlan)# end

也可以在VLAN状态下,进行VLAN配置:

命令目的

Step 1 vlan database 进入VLAN配置状态

Step 2 vlan vlan-id name vlan-name 加入VLAN号及VLAN名

Step 3 vlan vlan-id mtu mtu-size (可选) 修改MTU大小

Step 4 exit 更新VLAN数据庫并退出

Step 5 show vlan {name vlan-name | id vlan-id} 验证配置

Step 6 copy running-config startup config 保存配置(可选)

举例如下:

Switch# vlan database

Switch(vlan)# vlan 20 name test20

Switch(vlan)# exit

APPLY completed.

Exiting....

Switch#

4.3.1 删除VLAN

当删除一个处于VTP服务器的交换机上删除VLAN时,则此VLAN将在所有相同VTP的交换机上删除。当在透明模式下删除时,只在当前交换机上删除。

注意当删除一个VLAN时,原来属于此VLAN的端口将处于非激活的状态,直到将其分配给某一VLAN。

命令目的

Step 1 configure terminal 进入配置状态

Step 2 no vlan vlan-id 删除某一VLAN.

Step 3 end 退出

Step 4 show vlan brief 验证

Step 5 copy running-config startup config 保存

也可用vlan database 进入VLAN配置状态,用no vlan vlan-id 来删除。

4.3.2 将端口分配给一个VLAN

命令目的

Step 1 configure terminal 进入配置状态

Step 2 interface interface-id 进入要分配的端口

Step 3 switchport mode access 定义二层口

Step 4 switchport access vlan vlan-id 把端口分配给某一VLAN

Step 5 end 退出

Step 6 show running-config interface interface-id 验证端口的VLAN号

Step 7 show interfaces interface-id switchport 验证端口的管理模式和VLAN情况

Step 8 copy running-config startup-config 保存配置

使用default interface interface-id 还原到缺省配置状态。

举例如下:

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)# interface fastethernet0/1

Switch(config-if)# switchport mode access

Switch(config-if)# switchport access vlan 2

Switch(config-if)# end

Switch#

4.4 配置VLAN Trunks

以太网端口有二种链路类型:Access和Trunk。Access类型的端口只能属于1个VLAN,一般用于连接计算机的端口;Trunk类型的端口可以属于多个VLAN,可以接收和发送多个VLAN的报文,一般用于交换机之间连接的端口;这里的trunk并不是端口干路的概念,即端口汇聚或者链路聚合,而是允许vlan透传的一个概念。

命令目的

Step 1 configure terminal 进入配置状态

Step 2 interface interface-id 进入端口配置状态

Step 3 switchport trunk encapsulation {isl | dot1q | negotiate} 配置trunk封装ISL 或802.1Q 或自动协商

Step 4 switchport mode {dynamic {auto | desirable} | trunk} 配置二层trunk模式。?dynamic auto?自动协商是否成为trunk?dynamic desirable?把端口设置为trunk如果对方端口是trunk, desirable, 或自动模式?trunk?设置端口为强制的trunk方式,而不理会对方端口是否为trunk

Step 5 switchport access vlan vlan-id (可选) 指定一个缺省VLAN, 如果此端口不再是trunk Step 6 switchport trunk native vlan vlan-id 指定802.1Q native VLAN号

Step 7 end 退出

Step 8 show interfaces interface-id switchport 显示有关switchport 的配置

Step 9 show interfaces interface-id trunk 显示有关trunk的配置

Step 10 copy running-config startup-config 保存配置

举例:

Switch# configure terminal

Enter configuration commands, one per line. End with CNTL/Z.

Switch(config)# interface fastethernet0/4

Switch(config-if)# switchport mode trunk

Switch(config-if)# switchport trunk encapsulation dot1q

Switch(config-if)# end

缺省情况下trunk允许所有的VLAN通过。可以使用switchport trunk allowed vlan remove vlan-list 来去掉某一VLAN

Command Purpose

Step 1 configure terminal 进入配置状态

Step 2 interface interface-id 进入端口配置

Step 3 switchport mode trunk 配置二层口为trunk

Step 4 switchport trunk allowed vlan {add | all | except | remove} vlan-list (可选) 配置trunk允许的VLAN. 使用add, all, except, remove关健字

Step 5 end 退出

Step 6 show interfaces interface-id switchport 验证VLAN配置情况.

Step 7 copy running-config startup-config 保存配置

回到允许所有VLAN通过时, 可用no switchport trunk allowed vlan 端口配置命令.

举例如下:

Switch(config)# interface fastethernet0/1

Switch(config-if)# switchport trunk allowed vlan remove 2

Switch(config-if)# end

4.5 配置VTP DOMAIN

VTP DOMAIN 称为管理域。交换VTP更新信息的所有交换机必须配置为相同的管理域。如果所有的交换机都以中继线相连,那么只要在核心交换机上设置一个管理域,网络上所有的交换机都加入该域,这样管理域里所有的交换机就能够了解彼此的VLAN列表。

switch#vlan database 进入VLAN配置模式

switch (vlan)#vtp domain COM 设置VTP管理域名称COM

switch (vlan)#vtp server 设置交换机为服务器模式

switch #vlan database 进入VLAN配置模式

switch (vlan)#vtp domain COM 设置VTP管理域名称COM

switch (vlan)#vtp Client 设置交换机为客户端模式

switch #vlan database 进入VLAN配置模式

switch (vlan)#vtp domain COM 设置VTP管理域名称COM

switch (vlan)#vtp Client 设置交换机为客户端模式

switch #vlan database 进入VLAN配置模式

switch (vlan)#vtp domain COM 设置VTP管理域名称COM

switch (vlan)#vtp Client 设置交换机为客户端模式

注意:这里设置核心交换机为Server模式是指允许在该交换机上创建、修改、删除VLAN及其他一些对整个VTP域的配置参数,同步本VTP域中其他交换机传递来的最新的VLAN信息;Client模式是指本交换机不能创建、删除、修改VLAN配置,也不能在NVRAM中存储VLAN配置,但可同步由本VTP域中其他交换机传递来的VLAN信息。

4.6 配置VLAN接口地址

到这里,VLAN已经基本划分完毕。但是,VLAN间如何实现三层(网络层)交换呢?这时就要给各VLAN 分配网络(IP)地址了。给VLAN分配IP地址分两种情况,其一,给VLAN所有的节点分配静态IP地址;其二,给VLAN所有的节点分配动态IP地址。下面就这两种情况分别介绍。

假设给VLAN COUNTER分配的接口Ip地址为172.16.58.1/24,网络地址为:172.16.58.0,

VLAN MARKET 分配的接口Ip地址为172.16.59.1/24,网络地址为:172.16.59.0,

VLAN MANAGING分配接口Ip地址为172.16.60.1/24,网络地址为172.16.60.0

??

(1)给VLAN所有的节点分配静态IP地址。

首先在核心交换机上分别设置各VLAN的接口IP地址。核心交换机将vlan做为一种接口对待,就象路由器上的一样,如下所示:

switch(config)#interface vlan 10

switch (config-if)#ip address 172.16.58.1 255.255.255.0 VLAN10接口IP

switch (config)#interface vlan 11

switch (config-if)#ip address 172.16.59.1 255.255.255.0 VLAN11接口IP

switch (config)#interface vlan 12

switch (config-if)#ip address 172.16.60.1 255.255.255.0 VLAN12接口IP

再在各接入VLAN的计算机上设置与所属VLAN的网络地址一致的IP地址,并且把默认网关设置为该VLAN 的接口地址。这样,所有的VLAN也可以互访了。

相关主题
文本预览
相关文档 最新文档