cisco网络交换机配置手册
目 录
2、配置虚拟终端线路VTY(VirtualType Terminal)
12、将设备互联的端口设置为trunk,让其通过vlan信息
13、新建port-channel,并将多个端口划分到该port-channel
14、删除port-channel,并将该port-channel下的端口删除
参见三地网络拓扑图。
用Console线和转接头将交换机的console口与PC的串口相联,图示如下:
设置如下图(默认设置):
给交换机配置了管理地址,就可以直接采用远程telnet登陆进入交换机了,但是必须先配置line vty的密码和enable密码才能允许远程登陆。
telnet *.*.*.*
Switch > 进入用户模式
Switch >enable 从用户模式进入特权模式
Switch # configterminal 从特权模式进入全局配置模式
Switch #exit 退出所有配置模式
Switch # end 退出配置模式
Switch # wr 保存配置
Switch(config)# enablesecret cisco123 ――设置特权模式加密口令(机房使用方法)
Switch(config)# enablepassword cisco123 ――设置特权模式不加密口令
Switch(config)# service password-encryption ――将所有口令进行加密
Switch(config)# linevty 0 4
Switch(config-line)#login --让设备回显一个要求输入口令的提示
Switch(config-line)#password cisco ――Telnet统一密码
Switch(config-line)#exec-timeout 10 0 ――设备超时时间为10分钟0秒
Switch(config)# linevty 0 4
Switch#(config-line)# login local ――设置本地认证模式
Switch (config)#username zhangxy password ******
Switch (config)#no username zhangxy
Switch(config)# hostnametest-2950
test-2950(config)#no hostname
Switch(config)# snmp-servercommunity xxxxxx ro (只读)
Switch(config)# snmp-servercommunity xxxxxx rw (读写)
Switch# vlandatabase
Switch(vlan)# vlan100
Switch(vlan)# vlan100 name XX (名字一般定义为客户名称或者共享网段标识)
Switch(vlan)# novlan 100
或者
Switch# conf t
Switch(config)#vlan 100
Switch (config-vlan)#name XX (名字一般定义为客户名称或者共享网段标识)
Switch (config)#no vlan 100
Switch(config)# interfacef0/13 (进入单个端口配置模式)
Switch(config)# interfacerange f0/1-5 (进入一组端口配置模式)
Switch(config)# interfacerange f0/1-5, f0/8-10 (进入一组端口配置模式)
Switch(config-if)# (端口描述)
Description 客户名称拼音的全拼(首字母大写) ip=地址 带宽 操作日期
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 100
Switch(config-if)#no shutdown
Switch(config-if)#no switchport (删除端口相关配置)
Switch(config-if)#duplex full/auto/half [全双工|自动协商|半双工]
Switch(config-if)#speed 10/100/ auto
Switch(config)#int vlan 100
Switch(config-subif)#Description 客户名称ip=地址 带宽 操作日期 (描述)
Switch(config-subif)#ip address 192.168.2.130 255.255.255.0
Switch(config-subif)#ipaddress 192.168.3.130 255.255.255.0 secondary
Switch(config-subif)#no shutdown
配置二层交换机设备的管理地址:
Switch(config)#int vlan 1 (交换机VLAN1的网关地址就是设备的管理地址)
Switch(config-subif)#ip address 192.168.2.130 255.255.255.0
Switch(config-subif)#no shutdown
配置三层交换机的设备管理地址:
Switch(config)# intloopback0 ――loopback接口是一种逻辑接口,可以创建无数个
Switch(config-if)# ipaddress 192.168.2.130 255.255.255.0
Switch (config)# no intloopback 0
Switch(config)# interface f0/13
Switch(config-if)#ip address 192.168.1.130 255.255.255.0
Switch(config-if)#ip address 192.168.1.130 255.255.255.0 secondary
Switch(config)# int range f0/40,f0/48 (range的作用是同时对多个端口进行配置)
Switch(config-if)#switchport trunk encapsulation dot1q
Switch(config-if)# switchporttrunk allowed vlan 1-10,12-4094
(没有这句配置,则说明所有VLAN均能通过trunk)
Switch(config-if)# switchportmode trunk
(如果要增加vlan 100划分到truck时,必须把原有的vlan再都写上)
Switch(config-if)# switchporttrunk allowed vlan 1-10,100,12-4094
Switch (config)#interface port-channel 1
Switch(config)# interface f0/1
Switch(config-if)# channel-group 1 mode on
Switch(config)# interface f0/2
Switch (config-if)#channel-group 1 mode on
Switch (config)# interface f0/1
Switch(config-if)# no channel-group 1
Switch (config)#no interface port-channel 1
Switch (config)# iproute 172.16.1.0 255.255.255.0
――ip route 目标地址段 下一跳地址
将源端口的流入或流出流量镜像到目的端口以便于在目的端口接上笔记本电脑,利用anylazer软件抓包,并分析数据包是否正常。假设
IDC-BJ02-6509-1(config)#monitorsession 2 source interface g4/1 both
IDC-BJ02-6509-1(config)#monitorsession 2 destination interface g4/2
# show version 显示系统硬件配置、软件版本信息及最近一次启动以来连续运行的时间等
# show running-configuration 显示设备运行配置信息
# show running-config int f0/13 显示某个端口的配置信息
#show vlan 显示所有VLAN信息
# show interface f0/13 显示设备所有或指定接口的状态信息
# showint description 显示所有端口的描述信息
# showint status 显示所有端口的状态信息
# showip int brief 显示所有端口IP摘要
# showarp 显示所有地址解析协议信息
# show mac-address-table 显示MAC地址表内容
# show ip 显示设备上配置的IP地址、子网掩码、网关地址参数,管理VLAN号、域名解析服务器、HTTP信息及路由协议设定等(该命令不被路由器支持,只被交换机支持)
# show ip router 显示某个或所有的路由信息
# show spanning-tree 显示STP信息
# show logging 查看系统当前日志设置和缓冲区里的日志信息
# show history 查看命令缓冲区内容
#show proc cpu | exc 0.00 显示CPU占用的情况(exc表示除值为0以外的进程)
#showplatform cpu packet stat
#showmonitor session1 显示镜像端口的流量情况
下面列举常用命令:
6509-1# show interfacef0/13 显示设备所有或指定接口的状态信息
FastEthernet0/29 is up,line protocol is up (connected)
下面列出cisco二层、三层交换机端口不同显示状态的线路连接情况:
二层交换机端口状态:
Status | line protocol | 线路连接情况 |
administratively down | down | 管理员手工关闭端口 |
down | down (notconnect) | 端口己打开,但没插线(初始态) |
up | Up(connect) | 端口己打开,并且己插线 |
三层交换机端口状态:
Status | line protocol | 线路连接情况 |
administratively down | down (disabled) | 管理员手工关闭端口 |
up | down | 端口己打开,但没插线(初始态) |
up | up | 端口己打开,并且己插线 |
6509-1#ship int brief
Interface IP-Address OK? Method Status Protocol
Vlan1 unassigned YES NVRAM administratively down down
Vlan75 211.100.2.113 YES NVRAM up up
Vlan501 211.100.34.1 YES NVRAM administratively down down
GigabitEthernet1/1 unassigned YES NVRAM up down
GigabitEthernet1/2 unassigned YES NVRAM administratively down down
GigabitEthernet3/1 211.100.2.45 YES NVRAM up up
FastEthernet5/22 unassigned YES unset up up
FastEthernet5/23 unassigned YES unset up down
FastEthernet5/25 unassigned YES unset administratively down down
6509-1#shint description
Interface Status Protocol Description
Vl10 admin down down
Vl501 admin down down Share34.1
Vl583 up up DongFangWangJing1
Vl701 admin down down ChengHeWang 20041229
Gi1/2 admin down down
Gi3/1 up up ToM
Gi3/5 up down
Fa5/5 up up YiFangDaIp=***** 20060601
Fa5/11 up down TianYuanKeJiip=**** 20060525
Fa5/25 admin down down
6509-1#sharp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 192.168.10.98 35 0010.db
Internet 211.100.28.171 53 0030.
Internet 211.100.21.161 - 00d0.0106.5800 ARPA Vlan755
Internet 211.100.27.169 0
Internet 211.100.21.165 0 Incomplete ARPA
6509-1#shint status
Port Name Status Vlan Duplex SpeedType
Gi1/1 notconnect routed full 1000No GBIC
Gi1/2 disabled routed full 1000 No GBIC
Gi4/3 disabled 747 full 1000 1000BaseS
Gi3/1 To M
Gi3/3 disabled 1 full 1000
Fa5/1 To 2950-4 0/1 connected trunk full 10010/100BaseTX
cisco7507#sh version
CiscoInternetwork Operating System Software
IOS (tm) RSPSoftware (RSP-PV-M), Version 12.0(17)S, EARLY DEPLOYMENT RELEASE
――ISO版本信息
ROM: System Bootstrap,Version 11.1(8)CA1, EARLY DEPLOYMENT RELEASE SOFTWARE (fc1) ――ROM版本信息
cisco7507 uptimeis 19 weeks, 3 days, 4 hours, 6 minutes --设备开机时间
System image fileis "slot0:rsp-pv-mz.120-17.S.bin" ――Flash中的IOS映像文件名
cisco RSP4(R5000) processor with 262144K/2072K bytes of memory. ――处理器信息
1 GEIP controller(1 GigabitEthernet).
3 VIP2 R5Kcontrollers (4 FastEthernet)(2 Serial)(2 POS).
4FastEthernet/IEEE 802.3 interface(s)
1GigabitEthernet/IEEE 802.3 interface(s)
2 Serial networkinterface(s)
2 Packet overSONET network interface(s)
123K bytes ofnon-volatile configuration memory. ――NVRAM值
Configurationregister is 0x2102 ――配置存储器值
查看及修改系统当前日志设置和缓冲区里的日志信息:
cisco7507#sh logging
Syslog logging: enabled (0 messagesdropped, 0 flushes, 0 overruns)
Console logging: level debugging, 1957 messages logged ――控制台的日志信息
Monitor logging: level debugging, 73 messages logged ――Telnet客户端发送的系统日志
Buffer logging: disabled ――缓冲区日志
Logging Exception size (65536 bytes)
Trap logging:level informational, 472 message lines logg
――向SNMP管理软件发送的系统日志
cisco7507#conf t
cisco7507(config)#logging buffer
cisco7507(config)#no logging buffer
Cisco设备制定限流策略以及应用:
Switch# conf t
Switch (config)# access-list 1 permit any
Switch (config)# class-map match-all c
Switch (config-cmap)# matchaccess-group 1
Switch (config-cmap)# exit
Switch(config)# policy-map p
Switch (config-pmap)# classc
Switch (config-pmap-c)# police9000000 4096 exceed-action drop
Switch (config-pmap-c)# exit
Switch# conf t
Switch(config)# interface f0/13
Switch(config-if)# service-policyinput p
Switch(config-if)# exit
Switch(config)# interface f0/14
Switch(config-if)# service-policyinput p
Switch(config-if)# exit
Switch# wr
Switch (config)# access-list access-list-number {permit|deny}{protocol}
{sourcesource-wildcard|any}{destination destination-wildcard|any}
例1:允许北京电信IDC内部的ip地址telnet到各个网络设备
Switch (config)# access-list 101 permit tcp 218.30.26.0
Switch (config)# access-list 101 permit tcp 218.30.27.0
Switch (config)# access-list 101 permit tcp 218.30.25.0
例2:ACL限制对客户的192.168.1.119的访问
Switch (config)# access-list 130 deny ip host 192.168.1.119 any
Switch (config)# access-list 130 permit ip any any
Switch(config)# interface f0/22
Switch(config-if)# ip access-group
例3:172.21.0.0(VLAN 31)、172.22.0.0(VLAN 32)、172.23.0.0(VLAN 33)三个网段之间不能互相访问,其他网段均能访问,配置方法如下:
SS6509-1#conf t
SS6509-1(config)#access-list 101 deny ip any 172.22.0.0 0.0.255.255
SS6509-1(config)#access-list 101 deny ip any 172.23.0.0 0.0.255.255
SS6509-1(config)#access-list 101 permit ip any any
SS6509-1(config)#access-list 102 deny ip any 172.21.0.0 0.0.255.255
SS6509-1(config)#access-list 102 deny ip any 172.23.0.0 0.0.255.255
SS6509-1(config)#access-list 102 permit ip any any
SS6509-1(config)#access-list 103 deny ip any 172.21.0.0 0.0.255.255
SS6509-1(config)#access-list 103 deny ip any 172.22.0.0 0.0.255.255
SS6509-1(config)#access-list 103 permit ip any any
SS6509-1(config)#int vlan 31
SS6509-1(config-if)# ip access-group
SS6509-1(config)#int vlan 32
SS6509-1(config-if)# ipaccess-group
SS6509-1(config)#int vlan 33
SS6509-1(config-if)# ipaccess-group
将需要起HSRP的三层端口分别在两台主备6509上进行如下配置:
SS6509-1#vlan database
SS6509-1 (vlan)#vlan 31 name****
SS6509-1 (vlan)#exit
SS6509-1#conf t
SS6509-1(config)#int vlan 31
SS6509-1(config-if)#description**** ****
SS6509-1(config-if)#ipaddress 172.21.11.252 255.255.0.0
SS6509-1(config-if)#standby100 ip 172.21.11.254 (定义standby组号及虚IP地址)
SS6509-1(config-if)#standby100 priority 120
(定义该设备本standby组的优先级,优先级的值越大优先级越高)
SS6509-2#vlan database
SS6509-2 (vlan)#vlan 31 name****
SS6509-2(vlan)#exit
SS6509-2#conf t
SS6509-2(config)#int vlan 31
SS6509-2(config-if)#description**** ****
SS6509-2(config-if)#ipaddress 172.21.11.253 255.255.0.0
SS6509-2(config-if)#standby100 ip 172.21.11.254 (定义standby组号及虚IP地址)
SS6509-2(config-if)#standby100 priority 100 (定义该设备本standby组的优先级)
Switch(config)# mac access-list extended f02
Switch((config-ext-macl)#permit host 0016.d325.f
Switch(config)# interfaceFastEthernet0/2
Switch(config-if)# mac access-group f
1、更改交换机的telnet、enable密码(详见上面操作)
2、更改交换机的SNMP串(详见上面操作)
3、增加、删除VLAN(详见上面操作)
4、开、关闭端口(详见上面操作)
5、定期保存所有交换机的配置信息,遇到突发情况恢复交换机的配置
交换机的IOS保存和恢复是采用TFTP协议完成,所以首先你必须要下载一个TFTP软件,然后按照下面的步骤来进行:
① 在你的机器上启动TFTP 。
② 登陆到3500交换机,然后在enable状态下输入如下命令来完成IOS的保存:
switch# copy flash tftp
Source IP address or hostname [171.68.206.171]?
Source filename []? cat6000-sup2k8.7-1-1 .bin
Destination filename [cat6000-sup2k8.7-1-1 .binn]?
Loading cat6000-sup2k8.7-1-1 .bin to 171.68.206.171 (via VLAN1): !!!!
!!!!!!!!!!!
[OK -1125001 bytes]
③ 恢复配置时,执行如下命令:
switch# copy tftp flash
Source IP address or hostname []? 171.68.206.171
Source filename []? cat6000-sup2k8.7-1-1 .bin
Destination filename [cat6000-sup2k8.7-1-1 .bin]? y
Loading cat6000-sup2k8.7-1-1 .bin from 171.68.206.171 (via VLAN1): !!!!
!!!!!!!!!!!
[OK - 1125001bytes]
6、交换机IOS版本升级
7、恢复交换机口令(不同款交换机恢复口令的方法详见《pswdrec_3700》)
以2950为例,恢复口令的操作方法如下:
Connect a terminal orPC with terminal emulation software to the console port. For more information,
refer to the switch hardware installation guide.
Step 2 Set the line speed on the emulation software to 9600 baud.
Step 3 Unplug the switch power cord.
Step 4 Press the Mode button, and at the same time, reconnect the power cord tothe switch.
You can release the Mode button a second or two after the LED above port 1Xgoes off. Several lines of
information about the software appear, as do instructions:
The system has been interrupted prior to initializing the flash file system.These
commands will initialize the flash file system, and finish loading theoperating system
software:
flash_init
load_helper
boot
Step 5 Initialize the Flash file system:
switch: flash_init
Step 6 If you had set the console port speed to anything other than 9600, ithas been reset to that particular
speed. Change the emulation software line speed to match that of the switchconsole port.
Step 7 Load any helper files:
switch: load_helper
Step 8 Display the contents of Flash memory as in this example:
switch: dir flash:
The switch file system is displayed:
Directory of flash:/
3 drwx 10176 Mar 01 2001 00:04:34 html
6 -rwx 2343 Mar 01 2001 03:18:16 config.text
171 -rwx 1667997 Mar 01 2001 00:02:
7 -rwx 3060 Mar 01 2001 00:14:20 vlan.dat
172 -rwx 100 Mar 01 2001 00:02:54 env_vars
7741440 bytes total (3884509 bytes free)
Step 9 Rename the configuration file to config.text.old.
This file contains the password definition.
switch: rename flash:config.text flash:config.text.old
Step 10 Boot the system:
switch: boot
You are prompted to start the setup program. Enter N at the prompt:
Continue with the configuration dialog? [yes/no]: N
Step 11 At the switch prompt, change to privileged EXEC mode:
switch> enable
Step 12 Rename the configuration file to its original name:
switch# rename flas
联系客服