本部分包括以下内容: |
交换机接口的类型
|
||||||||||||||||||
交换机的每个物理接口可处于以下模式中的一种:
默认情况下,交换机所有接口都是2层的Access Port接口,所以如果一台没有经过配置的3层交换机可作为一台2层交换机直接使用。 |
交换机接口的默认配置
|
||||||||||||||||||||||
默认情况下,交换机所有接口都是2层的Access Port接口,所有接口都属于VLAN 1,所有接口默认都是激活的。 |
交换机接口配置的一般方法
|
配置接口时,可以配置单个接口,也可以成组配置多个接口。 配置单个接口: interface命令用于指定一个接口,之后的命令都是针对此接口的。 说明:interface命令可以在全局配置模式下执行,此时会进入接口配置模式,它也可以在接口配置模式下执行,所以配置完一个接口后,可直接用interface命令指定下一个接口。 参数:port-ID是接口的标识,它可以是一个物理接口,也可以是一个VLAN(此时应该把VLAN理解为一个接口),或者是一个Aggregate Port。 配置举例:配置交换机的IP地址为192.168.1.5,并把接口fastethernet0/1和fastethernet0/2设置为全双工模式。
Switch>
enable
Switch#
configure terminal
Switch(config)#
interface vlan 1
Switch(config-if)#
ip address 192.168.1.5 255.255.255.0
Switch(config-if)#
interface f0/1
Switch(config-if)#
duplex full
Switch(config-if)#
interface f0/2
Switch(config-if)#
duplex full
Switch(config-if)#
end
Switch#
说明:当交换机没有3层口时,所有接口都属于VLAN1,所以VLAN1的IP地址就是交换机的IP地址。 成组配置接口: 如果有多个接口需要配置相同的参数时,可以成组配置这些接口。 参数:port-range是接口的范围,它可以指定多个范围段,各范围段之间用逗号隔开。 说明:port-range指定接口范围可以是物理接口范围,也可以是一个VLAN范围。如:f0/1-6、vlan 2-4等。 注意:在interface range中的接口必须是相同类型的接口。 配置举例:配置交换机的接口fastethernet0/1~fastethernet0/12的速度为100Mbps,并把fastethernet0/1~fastethernet0/3和fastethernet0/7~fastethernet0/10分配给VLAN2。
Switch>
enable
Switch#
configure terminal
Switch(config)#
interface range f0/1-12
Switch(config-if)#
speed 100
Switch(config-if)#
interface range f0/1-3,0/7-10
Switch(config-if)#
switchport access vlan 2
Switch(config-if)#
end
Switch#
|
配置接口描述
|
接口描述常用于标注一个接口的功能、用途等,有利于记录和了解网络拓扑。 模式:在接口配置模式中配置。 配置命令: interface 命令用于指定要配置的接口。参数interface-ID是接口的类型和编号。 description 命令用于设置此接口的描述文字。 说明:接口描述的文字最多不得超过32个字符。 删除配置的描述: 配置举例:
Ruijie>
enable
Ruijie#
configure terminal
Ruijie(config)#
interface f0/1
Ruijie(config-if)#
description to-PC1
Ruijie(config-if)#
interface f0/2
Ruijie(config-if)#
description to-Switch1
Ruijie(config-if)#
end
Ruijie#
本例为fastethernet0/1和fastethernet0/2配置了接口描述,这样可方便了解它们所连接的设备。 配置的接口描述可以在配置文件中看到。 |
配置接口速率
|
S3550的接口都是具有多种速率的自适应接口,FastEthernet接口有10/100M两种速率,GigabitEthernet接口有10/100/1000M三种速率,默认情况下,他们用自协商方式确定他的工作速率。用配置可指定他们只使用某一个固定速率。 模式:在接口配置模式中配置。 配置命令: interface 命令用于指定要配置的接口。指定的接口可以是物理接口或Aggregate Port接口。 speed 命令用于设置此接口的速率。 参数:10——10Mbps,100——100Mbps,1000——1000Mbps(只能用于GigabitEthernet接口),auto——使用自协商模式(默认值)。 说明:当接口速率不是auto时,自协商过程被关闭,此时要求与该接口相连的设备必须支持此速率。 删除配置的速率: 删除配置的速率后,此接口的速率默认为auto。 配置举例:配置交换机的fastethernet0/1口速率为100Mbps。
Switch>
enable
Switch#
configure terminal
Switch(config)#
interface f0/1
Switch(config-if)#
speed 100
Switch(config-if)#
end
Switch#
配置的接口速率可以在配置文件中看到。 |
配置接口的双工模式
|
S3550的接口可工作于半双工模式或全双工模式,默认情况下,他们用自协商方式确定他的双工模式。用配置可指定他们只使用某一种双工模式。 模式:在接口配置模式中配置。 配置命令: interface 命令用于指定要配置的接口。指定的接口可以是物理接口或Aggregate Port接口。 duplex 命令用于设置此接口的双工模式。 参数:auto——使用自协商模式(默认值),half——半双工模式,full——全双工模式。 说明:当双工模式不是auto时,自协商过程被关闭,此时要求与该接口相连的设备必须支持此双工模式。 删除配置的双工模式: 删除配置的双工模式后,此接口的双工模式默认为auto。 配置举例:配置交换机的fastethernet0/1口双工模式为全双工模式。
Switch>
enable
Switch#
configure terminal
Switch(config)#
interface f0/1
Switch(config-if)#
duplex full
Switch(config-if)#
end
Switch#
配置的接口双工模式可以在配置文件中看到。 |
禁用/启用交换机接口
|
交换机的所有接口默认是启用的,此时接口的状态为Up。如果禁用了一个接口,则该接口不能收发任何帧,此时接口的状态为Down。 模式:在接口配置模式中配置。 禁用指定接口: 启用指定接口: 说明:interface指定的接口可以是物理接口、VLAN或Aggregate Port接口。 配置举例:禁用交换机的fastethernet0/1口。
Switch>
enable
Switch#
configure terminal
Switch(config)#
interface f0/1
Switch(config-if)#
shutdown
Switch(config-if)#
end
Switch#
|
查看交换机接口信息
|
在特权模式下,用 show interfaces 命令可查看交换机指定接口的设置和统计信息。 模式:特权模式。 命令: 参数: port-ID:可选,指定要查看的接口,可以是物理接口、VLAN或Aggregate Port接口。 counters:可选,只查看接口的统计信息。 description:可选,只查看接口的描述信息。 status:可选,查看接口的各种状态信息,包括速率、双工等。 switchport:可选,查看2层接口信息,只对2层口有效。 trunk:可选,查看接口的Trunk信息。 说明:如果未指定参数,则显示所有接口信息。 配置举例:查看交换机的fastethernet0/1口的信息。
Switch>
enable
Switch#
show interfaces f0/1
Interface : FastEthernet0/1
Description : to-PC1
AdminStatus : up
OperStatus : down
Medium-type : fiber
Hardware : GBIC
Mtu : 1500
LastChange : 0d:0h:0m:0s
AdminDuplex : Auto
OperDuplex : Unknown
AdminSpeed : Auto
OperSpeed : Unknown
FlowControlAdminStatus : Auto
FlowControlOperStatus : Off
Priority : Auto
|