附录A 思科互联网络操作系统(IOS)

思科互联网络操作系统(IOS

要点

实现IP编址方案和IP服务,以满足中型企业分支机构网络的网络需求

口在路由器上配置和验证 DHCPDNS 以及排除其故障(包括 CLI/SDM )

口配置和验证思科设备的基本运行方式和路由选择以及排除这些方面的故障。

口描述思科路由器的工作原理,包括路由器的启动过程、 POST 和路由器组件。

口访问路由器并设置基本参数(包括 CLII/SDM)

口连接和配置设备接口以及查看其运行情况。

口使用 ping traceroute Telnet SSH 或其他实用工具验证设备的配置和网络连接性。

口使用 ping traceroute 以及 Telnet SSH 验证网络连接性。

口排除路由选择故障。

口使用 show 命令和 debug 命令验证路由器硬件和软件的运行情况。

现在该介绍思科 IOS (Internetwork Operating System ,互联网络操作系统) IOS 运行在思科路由器和思科交换机上,让你能够对设备进行配置。

在本章中,你将学习 IOS 。我将演示如何使用思科 IOS 命令行界面 (CLI )配置运行思科 IOS路由器 熟悉该界面后,你将能够使用思科 IOS 配置主机名、旗标 (banner) 、密码等,还能够用它排除故障。

本章内容还将帮助你快速掌握路由器配置和验证命令的重要基本知识,下面是本章将讨论的主题:

口理解并配置思科IOS;

口连接路由器;

口启动路由器;

口登录路由器;

口理解路由器提示符;

口理解 CLI 提示符;

口使用编辑和帮助功能;

口收集基本的路由选择信息;

口设置管理功能;

口设置主机名

口设置旗标;

口设置密码;

口设置接口描述:

口配置接口;

口查看、保存和删除配置;

口验证路由选择配置。

 

1.IOS用户界面

1.1思科路由器IOS

路由器控制台端口、通过调制解调器连接辅助(Aux)端口或通过Telnet访问思科IOS

1.2 连接思科路由器

1.3 启动路由器

启动思科路由器时,它将执行加电自检(POST)。通过加电自检后,它将在闪存中查找思科IOS,如果找到IOS文件,将把它加载到内存(RAM)中。(注意,闪存是电可檫写可编程只读存储器,即EEPROM)。IOS加载后,它将寻找有效配置(启动配置),这种配置存储在非易失RAM(NVRAM)中。IOS加载并正常运行后,NVRAM中的预配置(也叫启动配置)将被复制到内存(RAM)中。该文件的副本被复制到内存(RAM)中,并被称为运行配置。

进入设置模式:setup

 

2.命令行界面(CLI

2.1进入CLI

R1>用户EXEC模式

R1#特权EXEC模式

返回到用户模式

R1#disable

R1>

退出控制台

R1>logout

 

R1 con0 is now available

Press RETURN to get started.

 

2.2 路由器模式概述

特权模式进入全局模式

R1#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#

 

2.3 CLI提示符

1.接口

R1(config)#interface ?

  Async              Async interface

  BVI                Bridge-Group Virtual Interface

  CDMA-Ix            CDMA Ix interface

  CTunnel            CTunnel interface

  Dialer             Dialer interface

FastEthernet       FastEthernet IEEE

R1(config)#interface fastEthernet 0/0

R1(config-if)#

2.子接口

R1(config)#interface fastEthernet 0/0

R1(config-if)#

3.line命令

R1(config-subif)#end

R1#

R1#configure terminal

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#

R1(config)#line console 0

R1(config-line)#

4.配置路由选择协议

R1(config)#router rip

R1(config-router)#versi

R1(config-router)#version 2

R1(config-router)#

5.定义路由器术语

用户EXEC模式:只能执行基本的监视命令

特权EXEC模式:让你能够访问其他所有的路由器命令

全局配置模式:可执行影响整个系统的命令

具体的配置模式:可执行只影响接口/进程的命令

设置模式:交互式配置对话

2.4编辑和帮助功能

R1#?

Exec commands:

access-enable    Create a temporary Access-List entry

access-profile   Apply user-profile to interface

access-template  Create a temporary Access-List entry

  alps             ALPS exec commands

  archive          manage archive files

  audio-prompt     load ivr prompt

  auto             Exec level Automation

  bfe              For manual emergency modes setting

  calendar         Manage the hardware calendar

  call             Voice call

  cd               Change current directory

--More--

空格下一页,回车显示一个,q返回提示符

R1#c?

calendarcall    cd         clear

clock     cns     configureconnect

copycrypto  ct-isdn

设置时间:

R1#clock set 15:21:36 15 november 2015

R1#

*Nov 15 15:21:36.000: %SYS-6-CLOCKUPDATE: System clock has been updated from 15:22:35 UTC Sun Nov 15 2015 to 15:21:36 UTC Sun Nov 15 2015, configured from console by console.

命令不完整

R1#clock

% Incomplete command.

命令出错,小脱字符(^),准确指出命令不对的地方。

R1#clock jdf

         ^

% Invalid input detected at '^' marker.

 

R1#sh serial 0/0/0

        ^

% Invalid input detected at '^' marker.

正确命令

R1#sh interfaces f0/0

FastEthernet0/0 is administratively down, line protocol is down

多个命令以你输入的内容打头,因此含义不明确。要获悉你需要的命令,使用问号。

R1#sh ru?

rudpv1running-config 

 

高级编辑命令

Ctrl+A:将光标移到行首

Ctrl+E:将光标移到行尾

Esc+B:将光标左移一个字

Ctrl+B:将光标左移一个字符

Ctrl+F:将光标右移一个字符

Esc+F:将光标右移一个字

Ctrl+D:删除一个字符

Backspace:删除一个字符

Ctrl+R:重新显示一行

Ctrl+U:删除一行

Ctrl+W:删除一个字

Ctrl+Z:退出配置模式,返回到EXEC模式

Tab:帮你完成命令的输入

 

在命令行太长的情况下自动向左滚动

R1#$data you are hahaha too young too simple is a good idea must know me   

 

查看路由器命令历史记录

Ctrl+P或上箭头:显示最后一次输入的命令

Ctrl+N或下箭头:显示以前输入的命令

show history:默认显示最近输入的20个命令

show terminal:显示终端配置和历史记录缓冲区的大小

terminal history size:修改缓冲区的大小(最大为256

R1#show history

  configure terminal

  config t

  clock set 15:21:36 november 2015

  clock set 15:21:36 15 november 2015

  clock

  jddl

  clock jdf

  sh serial 0/0/0

  sh interface serial 0/0/0

  sh interfaces f0/0

R1#show terminal

Line 0, Location: "", Type:

History is enabled, history size is 20.

R1#terminal history size 256

R1#

R1#show terminal

History is enabled, history size is 256.

 

2.5 收集基本的路由选择信息

R1#show version

Cisco IOS Software, 7200 Software (C7200-IK9S-M), Version 12.4(13b), RELEASE SOFTWARE (fc3)

Technical Support: http://www.cisco.com/techsupport

Copyright (c) 1986-2007 by Cisco Systems, Inc.

Compiled Wed 25-Apr-07 03:18 by prod_rel_team

 

ROM: ROMMON Emulation Microcode

BOOTLDR: 7200 Software (C7200-IK9S-M), Version 12.4(13b), RELEASE SOFTWARE (fc3)

 

R1 uptime is 43 minutes

System returned to ROM by unknown reload cause - suspect boot_data[BOOT_COUNT] 0x0, BOOT_COUNT 0, BOOTDATA 19

System restarted at 15:00:34 UTC Sun Nov 15 2015

1 FastEthernet interface

125K bytes of NVRAM.

 

65536K bytes of ATA PCMCIA card at slot 0 (Sector size 512 bytes).

8192K bytes of Flash internal SIMM (Sector size 256K).

Configuration register is 0x2102

R1#show interfaces

FastEthernet0/0 is administratively down, line protocol is down

R1#show ip interface brief

Interface                  IP-Address      OK? Method Status                Protocol

FastEthernet0/0            unassigned      YES unsetadministratively down down   

FastEthernet0/0.1          unassigned      YES unsetadministratively down down   

R1#

 

3.路由器和交换机的管理配置

在路由器和交换机上,可配置的管理功能如下:

主机名;

旗标;

密码;

接口描述。

3.1 主机名

R1#config t

Enter configuration commands, one per line.  End with CNTL/Z.

R1(config)#hostname sanyuan

sanyuan(config)#

3.2 旗标

创建一个旗标,向任何登录到路由器的人显示你想告诉他的信息。

4种类型的旗标:

sanyuan(config)#banner ?

  exec            Set EXEC process creation banner

  incoming        Set incoming terminal line banner

  login           Set login banner

  motd            Set Message of the Day banner

MOTD是最常用的旗标。它向任何拨号或通过Telnet、辅助端口甚至控制台端口连接路由器的人显示一条消息

sanyuan(config)#banner motd #

Enter TEXT message.End with the character '#'.

hahaha

#

 

hahaha

 

sanyuan#

在一行中设置旗标:

sanyuan(config)#banner motd x wawawa x

 

 wawawa

sanyuan#

 

EXEC旗标 可配置线路激活(EXEC)旗标,这种旗标在创建EXEC进程(如线路激活或有到来的VTY线路连接)时显示。通过控制台端口建立用户EXEC会话时,我们将激活EXEC旗标。

入站旗标 可配置一个这样的旗标,即在连到到反向Telnet线路的终端上显示。这种旗标可用于给使用反向Telnet的用户提供操作说明。

登录旗标 可配置在所有连接的终端上显示的登录旗标。这种旗标在MOTD旗标之后显示,并在登录提示出现前显示。我们不能基于线路禁用登录旗标,而必须全局禁用它,为此必须使用命令no banner login将其删除。

 

3.3 设置密码

1.启用密码

sanyuan(config)#enable ?

  last-resort  Define enable action if no TACACS servers respond

  password     Assign the privileged level password

  secret       Assign the privileged level secret

  use-tacacs   Use TACACS to check enable passwords

sanyuan(config)#enable secret yanjin

sanyuan(config)#enable pas

sanyuan(config)#enable password yanjin

The enable password you have chosen is the same as your enable secret.

This is not recommended.Re-enter the enable password.

sanyuan(config)#line ?

  <0-6>    First Line number

  aux      Auxiliary line

  console  Primary terminal line

  vty      Virtual terminal

2.辅助端口密码

sanyuan(config)#line aux ?

  <0-0>  First Line number

 

sanyuan(config)#line aux 0

sanyuan(config-line)#login

% Login disabled on line 1, until 'password' is set

sanyuan(config-line)#pass

sanyuan(config-line)#password aux

sanyuan(config-line)#login

sanyuan(config-line)#

请别忘了执行命令login,否则辅助端口将不进行身份验证。

给线路设置密码前,思科不允许执行命令login,因为如果执行命令login后没有设置密码,该线路将不可用——它将提示用户输入根本不存在的密码。

3.控制台端口密码

sanyuan(config-line)#line console ?

% Unrecognized command

sanyuan(config)#line console ?

  <0-0>First Line number

 

sanyuan(config)#line console 0

sanyuan(config-line)#pas

sanyuan(config-line)#password console

sanyuan(config-line)#login

 

命令exec-timeout 0 0将控制台EXEC会话的超时时间设置为0,这意味着永远不超时。

Logging synchronous,它可避免因不断出现控制台消息影响你的输入。配置该命令后,这些消息仍会出现,但会等到返回到路由器提示符后再出现,不会中断你的输入。这样,输入信息将更容易阅读。

sanyuan(config-line)#line con 0

sanyuan(config-line)#exec-

sanyuan(config-line)#exec-t

sanyuan(config-line)#exec-timeout 0 0

sanyuan(config-line)#login

sanyuan(config-line)#loggi

sanyuan(config-line)#logging sy

sanyuan(config-line)#logging synchronous

sanyuan(config-line)#

4.Telnet密码

sanyuan(config-line)#line vty 0 ?

% Unrecognized command

sanyuan(config-line)#line vty 0

sanyuan(config-line)#exit

sanyuan(config)#line vty 0 ?

<1-15>  Last Line number

  <cr>

 

sanyuan(config)#line vty 0 15

sanyuan(config-line)#passwo

sanyuan(config-line)#password telnet

sanyuan(config-line)#login

sanyuan(config-line)#

 

让路由器在没有设置Telnet密码也允许建立Telnet连接,我们可以使用no login命令:

sanyuan(config)#line vty 0 4

sanyuan(config-line)#no login

sanyuan(config-line)#

5.设置SSH

sanyuan(config)#hostname yanjin

yanjin(config)#ip dom

yanjin(config)#ip domain-nam

yanjin(config)#ip domain-name sanyuanempire.com

yanjin(config)#username yanjin password sanyuanempire

yanjin(config)#cry

yanjin(config)#crypto ke

yanjin(config)#crypto keyg

yanjin(config)#crypto key g

yanjin(config)#crypto key generate rs

yanjin(config)#crypto key generate rsa gen

yanjin(config)#crypto key generate rsa general-keys mo

yanjin(config)#crypto key generate rsa general-keys modulus ?

  <360-2048>  size of the key modulus [360-2048]

 

yanjin(config)#crypto key generate rsa general-keys modulus 1024

The name for the keys will be: yanjin.sanyuanempire.com

 

% The key modulus size is 1024 bits

% Generating 1024 bit RSA keys, keys will be non-exportable...[OK]

 

yanjin(config)#

Nov 15 16:44:09.707: %SSH-5-ENABLED: SSH 1.99 has been enabled

yanjin(config)#ssh ver

yanjin(config)#ssh versio

yanjin(config)#ssh version 2

                 ^

% Invalid input detected at '^' marker.

 

yanjin(config)#ssh ?

% Unrecognized command

yanjin(config)#line vty 0 ?

<1-15>  Last Line number

  <cr>

 

yanjin(config)#line vty 0 15

yanjin(config-line)#transpo

yanjin(config-line)#transport inp

yanjin(config-line)#transport input ssh telnet

yanjin(config-line)#

 

3.4 对密码进行加密

yanjin#sh running-config

Building configuration...

!

enable secret 5 $1$EtCD$nQpPMpOe/eSWrH9DptcoR1

enable password yanjin

yanjin#config t

Enter configuration commands, one per line.  End with CNTL/Z.

yanjin(config)#servi

yanjin(config)#service pas

yanjin(config)#service password-encryption

yanjin(config)#exit

yanjin#sh running-config

enable secret 5 $1$EtCD$nQpPMpOe/eSWrH9DptcoR1

enable password 7 105708170F1E1C

仅当路由器的CPU使用率很高时,才需禁用加密服务。如果在设置密码前就启用了加密服务,则即使不查看密码,它们也会被加密。

yanjin#configure t

Enter configuration commands, one per line.  End with CNTL/Z.

yanjin(config)#no ser

yanjin(config)#no service pa

yanjin(config)#no service pass

yanjin(config)#no service password-encryption

 

3.5 描述

 



来自为知笔记(Wiz)


posted on 2016-12-09 13:41  sanyuanyanjin  阅读(1329)  评论(0编辑  收藏  举报