[ZT]《让我们一起CCNA吧》系列文章四:CISCO IOS介绍

现在是介绍思科网络操作系统的时候了,Cisco Internetwork Operating
System简称IOS,它在思科的路由器和交换机上运行,它还能让你在上面执行配置操作。在本章你将能够学习到怎样通过初始安装模式和Cisco IOS command-line interface (CLI)来配置思科的路由器。这里是一些本章我们要达到的目标:
·关于IOS的介绍和配置
·连接一个路由器
·启动路由器
·登陆路由器
·弄明白路由器的提示符
·弄明白CLI的提示符
·执行编辑和帮助功能
·搜集基本的路由器信息
·设置管理功能
·设置名称
·设置标识
·设置密码
·设置接口描述
·进行接口配置
·显示,保存,删除配置文件
·确认路由器配置。


The Cisco Router User Interface

Cisco Internetwork Operating System (IOS)思科网络操作系统是思科路由器和交换机的内核。内核是一个操作系统最基本的,不可缺少的部分。它分配资源和管理底层硬件。思科创建了一种叫做CiscoFusion的东西,目标是使得所有的思科设备都运行同样的操作系统,可惜,目前还没有完全实现。通常所有的思科路由器都运行同样的IOS,相对比的是只有半数的交换机运行IOS,不过这个数字增长得很快。
下面,我们将学习怎么样使用安装模式来一步步地配置路由器。再下一个部分我们则使用命令行接口模式来完成同样的任务。

Cisco Router IOS

IOS被用来提供网络服务和启用网络应用程序。它包括了一些重要的功能如下:
·支持网络协议和功能
·在高速数据流量的设备间提供连接
·增加访问控制的安全性并使未被授权的网络停止运行
·提供可伸缩性使网络增长或冗余变的更容易
·为访问网络资源提供可靠性
你可以通过路由器的控制台接口来访问IOS,或者从辅助端口通过一个modem来访问,甚至通过telnet。访问IOS命令行被叫做EXEC会话。


Connecting to a Cisco Router

有三种不同的方法连接路由器,首先你需要连接到控制台接口(console port)
,console port通常位于路由器的背面,是一个RJ-45(8针的模块)接口。默认情况下,console port上没有设置密码。
其次,你也能够通过辅助接口(auxiliary port)来连接路由器。辅助接口能够允许你配置modem命令来支持modem连接到路由器。这是一个非常棒的特性,当路由器出现问题时它能够让你拨号登陆到一个远程的路由器上而不必跑老远的地方。
最后,你能够在网络内通过Telnet来连接路由器任何一个使用中的接口。Telnet是一个终端仿真程序。


Bringing Up a Router

当你第一次启动一个路由器的时候,首先执行power-on self-test (POST)自检,如果自检通过那么从flash存储器中寻找并加载IOS----如果IOS文件存在的话(flash存储器是一种电子可擦写可编程的只读存储器,也叫做EEPROM)。然后IOS寻找并加载有效的配置文件----startup-config,默认情况下配置文件都存放在非易失性内存(NVRAM)里。
当你第一次启动或者重启路由器的时候会出现以下信息:
System Bootstrap, Version 12.2(13)T, RELEASE SOFTWARE (fc1)
Copyright (c) 2000 by cisco Systems, Inc.
C2600 platform with 32768 Kbytes of main memory
这是路由器启动过程第一个部分的输出。当POST开始的时候bootstrap程序的这些信息告诉路由器该怎么加载IOS,默认情况下是在flash存储器里寻找。
找到IOS后把它解压缩到内存里,当解压缩完毕后,IOS开始运行,象下面的显示(注意这里的IOS版本是12.2[13]):
Cisco Internetwork Operating System Software
IOS (tm) C2600 Software (C2600-I-M), Version 12.2(13),
RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2001 by cisco Systems, Inc.
Compiled Tue 17-Dec-03 04:55 by kellythw
Image text-base: 0x80008088, data-base: 0x8080853C

一旦IOS加载完毕并开始运行,接下来将在NVRAM里加载一个有效的配置文件。
如果在NVRAM里没有配置文件,那么路由器将进入安装模式(setup mode),安装模式是一个逐步的过程,来帮助你配置路由器。你也可以在任何时候在特权模式下输入setup命令来进入安装模式。虽然安装模式只有一部分全局命令,但当你不知道怎么去配置一个确定的协议如桥接啊,DECnet啊时会很有用的。



Setup Mode
有两种不同情况的安装模式:基本管理和扩展安装。
基本管理仅仅给你足够的配置以允许路由器的连通性。
扩展安装则给你配置一些全局参数如配置接口参数的能力。
如果想进入安装模式,只需要在下面的情况下回答yes或者y就可以了:
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog?
[yes/no]:y
At any point you may enter a question mark '?' for help.
Use ctrl-c to abort configuration dialog at any prompt.
Default settings are in square brackets '[]'.

这里告诉了我们如果使用Ctrl+C来退出配置会话,[]里括住的是默认设置。
我们一般选择扩展安装的模式:
Would you like to enter basic management setup?[yes/no]:n

First, would you like to see the current interface
summary? [yes]:[Enter]
Any interface listed with OK? value "NO" does not have a
valid configuration
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned NO unset up up
FastEthernet0/1 unassigned NO unset up up
Configuring global parameters:
Enter host name [Router]:bogy
The enable secret is a password used to protect access
to privileged EXEC and configuration modes. This
password, after entered, becomes encrypted in the
configuration. Enter enable secret:bogy
The enable password is used when you do not specify an
enable secret password, with some older software
versions, and some boot images.
Enter enable password:bogy
% Please choose a password that is different from the
enable secret
Enter enable password:bogy1

这里有一些东西你要注意一下,刚才我们输入了两个密码,它们的作用是不同的,等下我们再详细说。但你要知道的是两个密码中我们只用到了enable secret password。虽然如此你在安装模式中你依然要把两个密码都配了,而且它们不能够一样。
默认情况下enable secret password是用MD5加密的,而enable password是明文显示的。
下面是配置telnet会话密码,因为如果你没有配置这个密码,你将不能够通过telnet来登陆路由器。
The virtual terminal password is used to protect
access to the router over a network interface.
Enter virtual terminal password:bogy
Configure SNMP Network Management? [yes]:[Enter] or [no]
Community string [public]:[no]
Configure DECnet? [no]:[Enter]
Configure AppleTalk? [no]:[Enter]
Configure IP? [yes]:[Enter]
Configure IGRP routing? [yes]:no
Configure RIP routing? [no]:[Enter]
Configure bridging? [no]:[Enter]
Configure IPX? [no]:[Enter]

如果你不知道要使用什么命令来配置协议的时候,上面的命令能够帮助你完成配置。但是如果你在命令行接口下配置,你将获得更多的灵活性。
如果你的路由器上有一个异步信号的modem卡,你也可以配置一下:
Async lines accept incoming modems calls. If you will
have users dialing in via modems, configure these lines.
Configure Async lines? [yes]:n
如果你有一个ISDN BRI的接口,你将被提示配置ISDN的交换类型:
BRI interface needs isdn switch-type to be configured
Valid switch types are:
[0] none..........Only if you don't want to configure BRI
[1] basic-1tr6....1TR6 switch type for Germany
[2] basic-5ess....AT&T 5ESS switch type for the US/Canada
[3] basic-dms100..Northern DMS-100 switch type for US/Canada
[4] basic-net3....NET3 switch type for UK and Europe
[5] basic-ni......National ISDN switch type
[6] basic-ts013...TS013 switch type for Australia
[7] ntt...........NTT switch type for Japan
[8] vn3...........VN3 and VN4 switch types for France
Choose ISDN BRI Switch Type [2]:2

因为这里我们的路由器上只有两个接口:FastEthernet 0/0和FastEthernet 0/1
Configuring interface parameters:
Do you want to configure FastEthernet0/0 interface? [yes]:[Enter]
Use the 100 Base-TX (RJ-45) connector? [yes]:[Enter]
Operate in full-duplex mode? [no]: y and [Enter]
Configure IP on this interface? [yes]:[Enter]
IP address for this interface: 1.1.1.1
Subnet mask for this interface [255.0.0.0]: 255.255.0.0
Class A network is 1.0.0.0, 16 subnet bits; mask is /16
Do you want to configure FastEthernet0/1 interface? [yes]:[Enter]
Use the 100 Base-TX (RJ-45) connector? [yes]:[Enter]
Operate in full-duplex mode? [no]:y and [Enter]
Configure IP on this interface? [yes]:[Enter]
IP address for this interface: 2.2.2.2
Subnet mask for this interface [255.0.0.0]: 255.255.0.0
Class A network is 2.0.0.0, 16 subnet bits; mask is /16

我知道,这些配置都是非常基本的,但它能够帮助你使一个路由器启动并很快运行。配置完成了,现在将显示你刚才创建的运行配置信息:
The following configuration command script was created:
hostname bogy
enable secret 5 $1$B0wu$5F0m/EDdtRkQ4vy4a8qwC/
enable password bogy1
line vty 0 4
password bogy
snmp-server community public
!
no decnet routing
no appletalk routing
ip routing
no bridge 1
no ipx routing
!
interface FastEthernet0/0
media-type 100BaseX
full-duplex
ip address 1.1.1.1 255.255.0.0
no mop enabled
!
interface FastEthernet0/1
media-type 100BaseX
full-duplex
ip address 2.2.2.2 255.255.0.0
no mop enabled
dialer-list 1 protocol ip permit
dialer-list 1 protocol ipx permit
!
end
[0] Go to the IOS command prompt without saving this config.
[1] Return back to the setup without saving this config.
[2] Save this configuration to nvram and exit.
Enter your selection [2]:0

这里有一个有趣的地方,那就是你能够选择进入命令行接口模式并放弃刚才的配置(0),你也能够回头重新再设置一遍(1),也能够保存配置到NVRAM中并退出重启(2)。这里我选择的是0,我们将不保存刚才的配置并进入命令行接口模式(CLI)。接下来我们将介绍CLI。再重复一次,你可以在任何时候按下Ctrl+C来退出安装模式。



Command-Line Interface

因为命令行接口模式(command-line interface CLI)能够提供给我们更多的灵活性,所以当配置一个路由器的时候我们一般都是使用CLI。有时候我把CLI也称为“Cash Line Interface”,如果你能够在CLI下创建一个好的路由器或者交换机的配置,那么你就能拿到现金,嘿嘿。

当问你是否进入setup模式时,选择no,即进入命令行接口模式。
Would you like to enter the initial configuration dialog? [yes]:n
Would you like to terminate autoinstall? [yes]:[Enter]



Logging into the Router

在接口信息出现后你可以按下回车键,现在出现的是Router>提示符。这个也叫做用户模式操作提示符(user mode),一般在这个提示符下看一些基础的统计信息。
在用户模式下使用enable命令来进入特权模式(privileged mode),在特权模式下你可以查看和修改路由器的配置信息。
进入特权模式后提示符变成了Router#,从特权模式退出到用户模式可以使用disable命令,也可以使用exit命令。如果使用logout命令的话则退出控制台会话。


Overview of Router Modes

在特权模式下进入全局配置模式(global configuration mode)则使用configure terminal命令,也可以使用config t缩写,也可以只输入config回车后选择进入全局配置模式,在全局配置模式下你输入的命令对整个路由器都产生作用。所以才叫做全局模式嘛。



CLI Prompts

当配置路由器的时候你要分清各种不同的提示符,这是非常重要的。当你看到提示符的时候你要知道你现在是处在什么模式下。我不会详细介绍各种不同类型的提示符,如果这样做的话不仅浪费了时间而且这也超出了CCNA的考试范围,我们只需要在学习中不断的留意各种提示符出现的位置和

你可能感兴趣的:(系统运维)