思智网络—旗下品牌
忘记密码
长沙云服务器,长沙服务器租用,长沙服务器托管
全国统一服务热线:88900700(7*24h)
 思智网络——专注于企业级IDC解决方案!
  • 顶级网络高速接入
  • 十年经验管理完善
  • 资质齐全放心可靠
  • 专业服务快速稳定
  • 免费备案快速高效
  • 自维机房全年无休
  • 免费测试省钱省心
  • 行业评价有口皆碑

解决方案专区 more>>

负载均衡解决方案
服务器网络安全解决方案
数据异地灾备解决方案
网络加速综合解决方案

典型客户 more>>

  • 潇湘晨报网
  • SANY
  • 盛大金禧
  • 湖南有线
  • 金杯电工
  • 长沙长海医院
  • 蝴蝶树
  • 中国人民大学
  • 湖南妈妈网
  • 美迪装饰
  • 小新星
  • 湖南武警医院
思智网络学院

长沙服务器托管中心教您配置思科交换机

发表:湖南数据中心文员   文章来源:湖南思智网络科技有限公司   
[摘要] 1.1 问题 对于思科交换机来说,主要有2种配置途径:其一,使用交换机自带的Console线缆连接到计算机的COM口,然后利用计算机的超级终端软件直接配置,首次配……


1.1 问题
对于思科交换机来说,主要有2种配置途径:其一,使用交换机自带的Console线缆连接到计算机的COM口,然后利用计算机的超级终端软件直接配置,首次配置通常使用这种方式;其二,通过telnet方式远程访问、配置交换机,这种方式要求此交换机已配置有IP地址且已接入计算机网络。
1.使用Console线将一台Cisco 2960交换机连接到计算机。
2.通过超级终端访问交换机,为此交换机配置IP地址。
3.通过Telnet方式远程管理此交换机。
1.2 方案
真实设备环境,如图-1所示。
 
图-1
本例中的配置练习可采用思科模拟器 —— Cisco Packet Tracer 6.0来实现。
1)安装Packet Tracer 6.0汉化版
双击安装包执行默认安装,然后将中文语言文件Chinese.ptl解压到安装目录下的多语言文件夹,比如C:\Program Files (x86)\Cisco Packet Tracer 6.0\languages。
双击桌面的Cisco Packet Tracer快捷方式以启动程序,打开菜单“Options”-->“Preferences”-->切换到“Interface”选项卡-->选择下方的Chinese.ptl-->单击右下角“Change Language”按钮,弹出提示时单击“OK”,如图-2所示。
 
图-2
关闭当前Packet Tracer程序,然后再重新启动此程序,可发现已经变成中文语言界面了(当前汉化的还不完整),如图-3所示。
 
图-3
2)建立实验网络拓扑
在Packet Tracer程序主窗口中,添加一台Cisco 2960交换机、一台普通PC机,并添加Console连接、直通网线连接,如图-4所示,确认完毕后将当前拓扑结构保存为c2960-pc.pkt文件。
 
图-4
其中,连接细节如下:
?    交换机的Console口 <--> PC机的RS 232串口。
?    交换机的FastEthernet0/24接口 <--> PC机的FastEthernet0网卡。
1.3 实现
1.交换机的初始化
1)配置并打开超级终端
在此前建立的Packet Tracer实验拓扑环境中,单击PC机以打开此设备,确认电源已启动(机箱示意图上的指示灯为黄绿色),切换到“桌面选项卡”,如图-5所示,找到其中的“终端”并单击打开。
 
图-5
在弹出的终端配置窗口中,如图-6所示,单击“确定”以接受默认值。
 
图-6
接下来就可以看到“终端”窗口了,其中显示了通过Console线连接的交换机初始化信息,回车后可进入交换机的“Switch>”配置系统,如图-7所示。
 
图-7
特别提示:
?    在真实环境中,可采用SecureCRT超级终端软件,配置好连接参数后,重新打开交换机电源,即可进入IOS配置环境。
?    在Packet Tracer环境中,可直接单击交换机图标,然后切换到“命令行”选项卡,也可以进入IOS配置环境。
2)切换到特权模式、进入全局配置模式
在IOS配置环境中,执行“en”(或enable)指令切换到特权模式,再执行“conf t”(或configure terminal)进入全局配置模式,如下所示:
1.    Switch> en                                      //切换为特权模式
2.    Switch# conf t                                  //进入全局配置模式
3.    Enter configuration commands, one per line.  End with CNTL/Z.
4.    Switch(config)#
2.为交换机配置主机名、IP地址
1)配置主机名(sw2960)
进入全局配置模式后,使用hostname指令可以为交换机设置主机名。例如,以下操作可以将主机名设置为sw2960:
1.    Switch(config)# hostname sw2960                     //配置主机名
2.    sw2960(config)#
2)配置IP地址(192.168.29.60/24)
执行“int vlan1”(或interface vlan1)指令进入交换机的vlan1接口配置,再执行“ip add 192.168.29.60 255.255.255.0”配置IP地址(ip add指令相当于ip address),执行“no shutdown”启用此接口,如下所示:
1.    sw2960(config)# int vlan1                                  //进入vlan1接口
2.    sw2960(config-if)# ip add 192.168.29.60 255.255.255.0          //配置IP地址
3.    sw2960(config-if)# no shutdown                              //启用接口
4.    %LINK-5-CHANGED: Interface Vlan1, changed state to up
5.    %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to up
3)确认当前的运行配置
直接执行“end”指令返回特权模式:
1.    sw2960(config-if)# end                                  //返回特权模式
2.    sw2960#
3.    %SYS-5-CONFIG_I: Configured from console by console
确认vlan1接口的IP地址信息:
1.    sw2960# show int vlan1                         //查看接口vlan1的信息
2.    Vlan1 is up, line protocol is up              //状态为up表示已激活
3.      Hardware is CPU Interface, address is 00d0.bccc.420d (bia 00d0.bccc.420d)
4.      Internet address is 192.168.29.60/24         //IP地址与配置的一致
5.      MTU 1500 bytes, BW 100000 Kbit, DLY 1000000 usec,
6.         reliability 255/255, txload 1/255, rxload 1/255
7.      Encapsulation ARPA, loopback not set
8.      ARP type: ARPA, ARP Timeout 04:00:00
9.      Last input 21:40:21, output never, output hang never
10.      Last clearing of "show interface" counters never
11.      Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
12.      Queueing strategy: fifo
13.      Output queue: 0/40 (size/max)
14.      5 minute input rate 0 bits/sec, 0 packets/sec
15.      5 minute output rate 0 bits/sec, 0 packets/sec
16.         1682 packets input, 530955 bytes, 0 no buffer
17.         Received 0 broadcasts (0 IP multicast)
18.         0 runts, 0 giants, 0 throttles
19.         0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
20.         563859 packets output, 0 bytes, 0 underruns
21.         0 output errors, 23 interface resets
22.         0 output buffer failures, 0 output buffers swapped out
查看交换机当前的运行配置(或write terminal):
1.    sw2960# show running-config                  //查看当前的运行配置
2.    Building configuration...
3.    
4.    Current configuration : 1052 bytes
5.    !
6.    version 12.2
7.    no service timestamps log datetime msec
8.    no service timestamps debug datetime msec
9.    no service password-encryption
10.    !
11.    hostname sw2960                              //已配置主机名
12.    !
13.    !
14.    !
15.    !
16.    spanning-tree mode pvst
17.    !
18.    interface FastEthernet0/1
19.    !
20.    interface FastEthernet0/2
21.    !
22.    interface FastEthernet0/3
23.    !
24.    interface FastEthernet0/4
25.    !
26.    interface FastEthernet0/5
27.    !
28.    interface FastEthernet0/6
29.    !
30.    interface FastEthernet0/7
31.    !
32.    interface FastEthernet0/8
33.    !
34.    interface FastEthernet0/9
35.    !
36.    interface FastEthernet0/10
37.    !
38.    interface FastEthernet0/11
39.    !
40.    interface FastEthernet0/12
41.    !
42.    interface FastEthernet0/13
43.    !
44.    interface FastEthernet0/14
45.    !
46.    interface FastEthernet0/15
47.    !
48.    interface FastEthernet0/16
49.    !
50.    interface FastEthernet0/17
51.    !
52.    interface FastEthernet0/18
53.    !
54.    interface FastEthernet0/19
55.    !
56.    interface FastEthernet0/20
57.    !
58.    interface FastEthernet0/21
59.    !
60.    interface FastEthernet0/22
61.    !
62.    interface FastEthernet0/23
63.    !
64.    interface FastEthernet0/24
65.    !
66.    interface GigabitEthernet1/1
67.    !
68.    interface GigabitEthernet1/2
69.    !
70.    interface Vlan1
71.     ip address 192.168.29.60 255.255.255.0             //已配置管理IP地址
72.    !
73.    !
74.    line con 0
75.    !
76.    line vty 0 4
77.     login
78.    line vty 5 15
79.     login
80.    !
81.    !
82.    end
83.    
84.    sw2960#
4)将运行配置保存为启动配置
使用copy执行拷贝,当提示指定配置文件名时,直接回车接受默认,如下所示:
1.    sw2960# copy running-config startup-config              //保存配置
2.    Destination filename [startup-config]?
3.    Building configuration...
4.    [OK]
5.    sw2960#
3.交换机的其他常见配置
1)禁止使用域名查询
建议执行“no ip domain-lookup”(全局配置模式下)禁用DNS查询,否则当输入错误的指令时,IOS会将其当成未知域名进行解析,耗时长影响终端交互。配置操作指令如下所示:
1.    sw2960(config)# no ip domain-lookup             //禁用域名查询
2.    sw2960(config)#
2)设置特权模式口令
包括两种典型的方法(任选其一):
?    方法1(明文):enable password 密码字串
?    方法2(加密):enable secret 密码字串
比如,以下操作将明文口令设为cisco、加密口令设置为cisco2960:
1.    sw2960(config)# enable password cisco
2.    sw2960(config)# enable secret cisco2960
返回全局配置模式,查看运行配置可观察两种口令设置的差异:
1.    sw2960(config)# end                          //返回特权模式
2.    sw2960#
3.    %SYS-5-CONFIG_I: Configured from console by console
4.    
5.    sw2960# show running-config                 //查看当前的运行配置
6.    .. ..
7.    !
8.    hostname sw2960
9.    !
10.    enable secret 5 $1$mERr$pUBB1obEqpmMUtC1rBieD1          //加密口令设置
11.    enable password cisco                                     //非加密的口令设置
12.    !
13.    !
14.    .. ..
执行disable切换到用户模式,再执行enable切换到特权模式,此时会要求输入正确的口令才允许进入(如果明文/密文口令都设置了,则密文口令起作用):
1.    sw2960> enable
2.    Password:                                   //尝试明文口令cisco无效
3.    Password:                                  //输入密文口令cisco2960验证成功
4.    sw2960#
4.通过Telnet方式远程管理交换机
1)在交换机上配置远程访问授权
进入交换机的全局配置模式,执行“line vty 0 1”进入第一个虚拟终端的授权配置,设置访问口令(cisco2960),并启用登录验证(login):
1.    sw2960(config)# line vty 0 1
2.    sw2960(config-line)# password cisco2960
3.    sw2960(config-line)# login
2)将PC机接入交换机同一个网络
此前的实验拓扑已经将PC与交换机的F0/24口相连,而且也为交换机配置了管理IP地址192.168.29.60/24,为了使PC机能远程访问此交换机,只需要给PC配置一个同网段的IP地址就可以了。
在Packet Tracer环境中,单击PC机图标打开此设备,切互到“配置”选项卡,将接口FastEthernet0的IP地址设置为192.168.29.70/24,如图-8所示。
 
图-8
3)在PC机上,使用telnet工具登入交换机
打开PC机的桌面,关掉“终端”、打开“命令提示符”,如图-9所示。
 
图-9
执行“telnet 192.168.29.60”连接交换机的管理IP地址,输入远程访问口令验证,成功后即可进入IOS配置环境,如下所示:
1.    PC> telnet 192.168.29.60                      //telnet交换机的管理IP地址
2.    Trying 192.168.29.60 ...Open
3.    
4.    User Access Verification
5.    
6.    Password:                                      //验证远程访问口令
7.    sw2960>                                         //成功后进入IOS配置环境
一旦进入到IOS配置环境以后,以后的操作就和Console线连超级终端一样了,比如执行“enable”并验证特权口令进入特权模式,执行“conf t”进入全局配置模式……:
1.    sw2960> enable
2.    Password:
3.    sw2960# conf t
4.    Enter configuration commands, one per line.  End with CNTL/Z.
5.    sw2960(config)#
使用Console线必须直接连接到物理设备,而telnet方式可通过以太网络来完成,只要有可用的网络连接、知道设备的管理地址即可,灵活性大大增强了。
1.4 扩展

湖南数据中心主要业务范围:湖南主机托管长沙服务器租用长沙服务器托管湖南服务器托管知名品牌,值得信赖!

收缩

  • 售前咨询
  • 技术支持
  • 备案专员
  • 24小时客服热线:
  • 88900700

微信号:hnidccn