书城计算机小型局域网组建与维护
13105900000028

第28章 组建小型交换网络——配置交换机(5)

2.配置和显示交换机的IP协议(Configure and Display IP Protocol of theS witch)

下面将在交换机上配置IP协议寻址,配置IP协议的语法是:

(config)#ipaddressip_addresssubnet_mask

(config)#ipdefault-gatewaygateway’s_IP_address

1900系列交换机的IP寻址配置是在全局配置模式下完成的,其中“ipaddress”是用于分配IP地址的命令,“IP_address”是为交换机所分配的IP地址,subnet_mask是子网掩码。

(config)#ipaddress?

A.B.C.D IPaddress

<cr>

(config)#ipad dress192.168.0.1?

A.B.C.D IP subnetmask

(config)#ipaddress192.168.0.1255.255.255.0

第二条使用ip default-gateway命令用于为交换机指定网关的IP地址。例:

(config)#ip default-gateway?

A.B.C.D Default gateway

(config)#ipdefault-gateway192.168.0.254

2900系列的交换机IP地址配置是在VLAN1的接口配置模式中,网关配置是在全局配置模式中。

Switch(config)#interfacevlan1

Switch(config-vlan)#ipaddressIP_address subnet_mask

Switch(config-vlan)#exit

Switch(config)#ipdefault-gatewaygateway's_IP_address

2950交换机IP地址和默认网关的配置实例:

Switch#configureterminal

Enter configuration commands,oneperline.EndwithCNTL/Z.

Switch(config)#interfacevlan1

Switch(config-if)#ipaddress?

A.B.C.DIPaddress

Switch(config-if)#ipaddress192.168.100.1?

A.B.C.DIPsubnetmask

Switch(config-if)#ipaddress192.168.100.1255.255.255.0

Switch(config-if)#noshutdown02:47:03:%LINK-3-UPDOWN:InterfaceVlanl,changedstatetoup

02:47:04:%LINEPROTO-5-UPDOWN:Line protocol on Inter face Vlanl,changedstate

toup

Switch(config-if)#exit

Switch(config)#ipdefault-gateway?

A.B.C.DIPaddressofdefaultgateway

Switch(config)#ipdefault-gatew.ay192.165.100.254

Switch(config)#

要验证所做的IP配置,在1900系列交换机上,可以使用“showip”命令:

#showip

IP Address:192.168.0.1

Subnet Mask:255.255.255.0

Default Gateway:192.168.0.254

Management VLAN:1

Domainname:

Nameserver1:0.0.0.0

Nameserver2:0.0.0.0

HTTP server:Enabled

HTTP port:80

RIP:Enabled

#_

在2950系列交换机上,可以使用“show ip inter face brief”命令验证所做的IP配置:

Switch#show ip inter brief vlan1

Interface IP-Address OK?Method Status Protocol

Vlan1 192.168.100.1 YESmanualup up

3.基本的接口配置(Basic Interface Configuration)

(1)访问接口(Access Interface)

要配置交换机的接口,可以在全局配置模式中使用“interface”命令,此命令与在Cisco路由器上所使用的命令相同,例如:

在1900交换机中:

#configure terminal

Enterconfiguration commands,oneperline.EndwithCNTL/Z

(config)#inter face ethernet0/12

在2900交换机中:

Switch#configureterminal

Enterconfiguration commands,oneperline.EndwithCNTL/Z.

Switch(config)#inter face Fast Ethernet0/24

Switch#conft

Enter configuration commands,oneperline.EndwithCNTL/Z.

Switch(config)intfa0/24

注意,此命令将用户带入接口配置模式,其中type在1900交换机有Ethernet和Fast Eth-ernet两种接口,2900交换机只有Fast Ethernet一种接口或者某些型号Fast Ethernet和Giga-bit Ethernet两种接口。在该模式中,在某个接口上所做的任何改动只影响那个特定的接口。

此外,如果输入全局配置模式命令,交换机将通常在全局模式中执行那条命令,并且在执行完后返回接口子配置模式。

(2)配置双工模式(Configure DuplexMode)

Catalyst1900和2950系列交换机的接口,Ethernet端口默认双工配置是为半双工(half)Fast Ethernet和Gigabit Ethernet端口默认为双工和速度自动协商(Auto-duplex,AutoSpeed)。

用户可以在接口配置模式中使用“duplex”命令手动配置其双工模式。在1900系列交换机上,Ethernet只可以使用“full”或“half”命令参数设置端口,而Fast Ethernet端口可以使用全部命令中的任何一个参数。

(config)#inter face ethernet0/12

(config-if)#duplex?

auto En able auto duplexconfiguration

fullForcefullduplexoperation

full-flow-controlForcefullduplexwithflowcontrol

half Forcehalf duplexoperation

需要记住1900系列交换机上端口的默认双工设置。其中full-flow-control的双工模式,将允许此接口及与其相连的设备共享拥塞信息以实施流控制。

在2950系列交换机上,要设定双工模式,可以使用下列命令语句:

Switch(config)#inter face Fast Ethernet0/2

Switch(config-if)#duplex?

auto Enable AUTO duplexconfiguration

full Forcefull duplexoperation

half Forcehalf-duplexoperation

2950系列不支持1900系列交换机所支持的流控制配置。只支持full、half和auto三种命令参数。与1900系列不同,2950系列交换机可以自动侦测线路的速率(对于10/100Mbps端口)。对于这些端口,用户可以用下列命令语句以输入代码的形式设置其速率:

Switch(config-if)#speed?

10 Force10Mbpsoperation

100Force100Mbpsoperation

auto Enable AUTO speed configuration

建议用户不对接口使用自动检测。自动检测的问题是:自动检测功能试图协商线路的双工模式和/或速率时,在不同厂商的设备间可能产生冲突。有时,一端可能是100Mbps半双工,而另一端可能是100Mbps全双工,从而产生大量的冲突。用户需要大量的时间手动地配置其自动侦测接口的双工模式和速率。

(3)验证接口的配置(Verification Configurationofthe Interface)

配置完接口的双工模式和/或速率之后,用户就可以使用下列命令验证其配置了:

#show inter face port_type0/port_#

例:1900交换机验证接口配置命令showinterfaceethernet0/10的输出信息:

#show inter face ethernet0/10

Ethernet 0/10 is Su spended-no-linkbeat

Hard ware isBuilt-in10Base-T

Rddress is 0003.E311.C3CR

MTU1500bytes,BW10000Kbits

802.1dSTPState:Forwarding Forward Transitions:1

Portmonitoring:Disabled

Unknown uni cast flooding:Enabled

Unregister edmulti cast flooding:Enabled

Deion:

Duplexsetting:Halfduplex

Back pressure:Disabled

Receive Statistics TransmitStatistics

Total good frames 0Totalframes0

Total octets 0 Totaloctets0

Broadcast/multicastframes0 Broadcast/multicastframes0

Broadcast/multicastoctets0 Broadcast/multicastoctets0

Good frames forwarded 0 Deferrals0

Frames filtered 0 Singlecollisions0

Runt frames 0 Multiplecollisions0

Nobufferdiscards0Excessivecollisions0

Queuefulldiscards0

Errors:Errors:

FC Serrors 0 Latecollisions0

Alignment errors 0Excessivedeferrals0

Giant frames0Jabbererrors0

Address violations0Othertransmiterrors0

利用此命令,可以看到双工模式的配置,STP模式以及关于此接口的统计和错误信息。

如果在交换机接口和与其相连的设备之间存在双工不匹配的情况,用户很可能看到大量的冲突,特别是late冲突,以及大量的FCS错误。