Target:

   将计算机的Com口和路由器的Console口通过Console线缆连接起来,使用Windows提供的超级终端工具进行连接,登录路由器的命令行界面进行配置。

163811748.png

实验原理:

路由器的管理方式基本分为两种:带内管理和带外管理。通过路由器的Console口管理路由器属于带外管理,不占用路由器的网络接口,但特点是线缆特殊,需要近距离配置。第一次配置路由器时必须利用Console进行配置,使其支持telnet远程管理。

路由器的命令行操作模式,主要包括:用户模式、特权模式、全局配置模式、端口模式等等几种。

? 用户模式进入路由器后得到的第一个操作模式,该模式下可以简单查看路由器

的软、硬件版本信息,并进行简单的测试。用户模式提示符为Red-Giant>

? 特权模式由用户模式进入的下一级模式,该模式下可以对路由器的配置文件进行管理,查看路由器的配置信息,进行网络的测试和调试等。特权模式提示符为Red-Giant#

? 全局配置模式属于特权模式的下一级模式,该模式下可以配置路由器的全局性参数(如主机名、登录信息等)。在该模式下可以进入下一级的配置模式,对路由器具体的功能进行配置。全局模式提示符为Red-Giant (config)#

? 端口模式属于全局模式的下一级模式,该模式下可以对路由器的端口进行参数配置。

Exit命令是退回到上一级操作模式,

end命令是直接退回到特权模式

路由器命令行支持获取帮助信息、命令的简写、命令的自动补齐、快捷键功能。

配置路由器的设备名称和路由器的描述信息必须在全局配置模式下执行。

Hostname配置路由器的设备名称即命令提示符的前部分信息。

当用户登录路由器时,你可能需要告诉用户一些必要的信息。你可以通过设置标题来达到这个目的。你可以创建两种类型的标题:每日通知和登录标题。

Banner motd配置路由器每日提示信息motd message of the day。

Banner login配置路由器远程登录提示信息,位于每日提示信息之后。

锐捷路由器接口Fastethernet接口默认情况下是10M/100M自适应端口,双工模式也为自适应。

在路由器的物理端口可以灵活配置带宽,但最大值为该端口的实际物理带宽。

查看路由器的系统和配置信息命令要在特权模式下执行。

Show version查看路由器的版本信息,可以查看到路由器的硬件版本信息和软件版本信息,用于进行路由器操作系统升级时的依据。

Show ip route 查看路由表信息。

Show running-config查看路由器当前生效的配置信息。


Step:


第一步:路由器命令行的基本功能

RSR20>?

!使用?显示当前模式下所有可执行的命令

Exec commands:

<1-99> Session number to resume

disable Turn off privileged commands

disconnect Disconnect an existing network connection

enable Turn on privileged commands

exit Exit from the EXEC

help Description of the interactive help system

lock Lock the terminal

ping Send echo messages

ping6 ping6

show Show running system information

start-terminal-service Start terminal service

telnet Open a telnet connection

traceroute Trace route to destination

RSR20>e?

enable exit

!显示当前模式下所有以e开头的命令

RSR20>en <tab>

!按键盘的Tab键自动补齐命令,路由器支持命令的自动补齐

RSR20>enable

!使用enable命令从用户模式进入特权模式

RSR20#copy ?

!显示copy命令后可执行的参数

flash: Copy from flash: file system

running-config Copy from current system configuration

startup-config Copy from startup configuration

tftp: Copy from tftp: file system

xmodem: Copy from xmodem: file system

RSR20#copy

% Incomplete command.

!提示命令未完,必须附带可执行的参数

RSR20#conf t

!路由器支持命令的简写,该命令代表configure terminal

!进入路由器的全局配置模式

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

RSR20(config)#interface fastEthernet 0/0

!进入路由器端口Fa0/0的接口配置模式

RSR20(config-if)#

RSR20(config-if)#exit

!使用exit命令返回上一级的操作模式

RSR20(config)#interface fastEthernet 0/0

RSR20(config-if)#end

!使用end命令直接返回特权模式

RSR20#

RSR20(config)#interface fastEthernet 0/0

RSR20(config-if)#^Z

!使用快捷键ctrl+Z直接退回到特权模式

RSR20#

RSR20#ping 1.1.1.1

Sending 5, 100-byte ICMP Echoes to 1.1.1.1, timeout is 2 seconds:

< press Ctrl+C to break >

..^C

Success rate is 0 percent (0/3)

!在路由器特权模式下执行ping 1.1.1.1命令,发现不能ping通目标地址,路由器默认情况下需要发送5个数据包,若不想等到5个数据包均不能ping通目标地址时才认为目的地址不可到达,可在数据包未发出5个之前通过快捷键Ctrl+C终止当前操作。

第二步:配置路由器的名称和每日提示信息

RSR20>enable

RSR20#configure terminal

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

RSR20(config)#hostname RouterA

!将路由器的名称设置为RouterA

RouterA(config)#

RouterA(config)#banner motd &

!设置路由器的每日提示信息,motd后面的参数为设置的终止符

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

Welcome to RouterA, if you are admin, you can config it.

If you are not admin, please EXIT.

&

RouterA(config)#

验证测试:

RouterA#exit

RouterA CON0 is now available

Press RETURN to get started

Welcome to RouterA, if you are admin, you can config it.

If you are not admin, please EXIT.

RouterA>

第三步:配置路由器的接口并查看接口配置

RouterA#configure terminal

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

RouterA(config)#interface fastEthernet 0/0

!进入端口Fa0/0的接口配置模式

RouterA(config-if)#ip address 192.168.1.1 255.255.255.0

!配置接口的IP地址

RouterA(config-if)#no shutdown

!开启该端口

RouterA(config-if)#end

RouterA#show interfaces fastEthernet 0/0

!查看端口Fa0/0的状态是否为UP,地址配置和流量统计等信息

Index(dec):1 (hex):1

FastEthernet 0/0 is UP , line protocol is UP

Hardware is MPC8248 FCC FAST ETHERNET CONTROLLER FastEthernet, address is 00d0.f86b.3832 (bia 00d0.f86b.3832)

Interface address is: 192.168.1.1/24

ARP type: ARPA,ARP Timeout: 3600 seconds

MTU 1500 bytes, BW 100000 Kbit

Encapsulation protocol is Ethernet-II, loopback not set

Keepalive interval is 10 sec , set

Carrier delay is 2 sec

RXload is 1 ,Txload is 1

Queueing strategy: FIFO

Output queue 0/40, 0 drops;

Input queue 0/75, 0 drops

Link Mode: 100M/Full-Duplex

5 minutes input rate 1 bits/sec, 0 packets/sec

5 minutes output rate 1 bits/sec, 0 packets/sec

1 packets input, 60 bytes, 0 no buffer, 0 dropped

Received 1 broadcasts, 0 runts, 0 giants

0 input errors, 0 CRC, 0 frame, 0 overrun, 0 abort

1 packets output, 42 bytes, 0 underruns , 0 dropped

0 output errors, 0 collisions, 2 interface resets

第四步:查看路由器的配置

RouterA#show version

!查看路由器的版本信息

System description : Ruijie Router(RSR20-04) by Ruijie Network

System start time : 2009-8-16 5:37:38

System hardware version : 1.01

!硬件版本号

System software version : RGNOS 10.1.00(4), Release(18443)

!软件版本号

System boot version : 10.2.24515

System serial number : 1234942570135

RouterA#show ip route

!查看路由表信息

Codes: C - connected, S - static, R - RIP B - BGP

O - OSPF, IA - OSPF inter area

N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

E1 - OSPF external type 1, E2 - OSPF external type 2

i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area

* - candidate default

Gateway of last resort is no set

C 192.168.1.0/24 is directly connected, FastEthernet 0/0

C 192.168.1.1/32 is local host.

RouterA#show running-config

!查看路由器当前生效的配置信息

Building configuration...

Current configuration : 540 bytes

!

version RGNOS 10.1.00(4), Release(18443)(Tue Jul 17 20:50:30 CST 2007 -ubu1server)

hostname RouterA

!

!

interface FastEthernet 0/0

ip address 192.168.1.1 255.255.255.0

duplex auto

speed auto

!

interface FastEthernet 0/1

duplex auto

speed auto

!

line con 0

line aux 0

line vty 0 4

login

!

banner motd ^C

Welcome to RouterA, if you are admin, you can config it.

If you are not admin, please EXIT.

^C

!

end

【注意事项】

1、命令行操作进行自动补齐或命令简写时,要求所简写的字母必须能够唯一区别该命令。如Red-Giant# conf可以代表configure,但Red-Giant#co 无法代表configure,因为co开头的命令有两个copy和configure,设备无法区别。

2、注意区别每个操作模式下可执行的命令种类。路由器不可以跨模式执行命令。

3、配置设备名称的有效字符是22个字节。

4、配置每日提示信息时,注意终止符不能在描述文本中出现。如果键入结束的终止符后仍然输入字符,则这些字符将被系统丢弃。

5、Serial接口正常的端口速率最大是2.048M(2000K)。

6、Show interface和show ip interface之间的区别。

7、Show running-config是查看当前生效的配置信息。Show startup-config是查看保

存在NVRAM里的配置文件信息。

8、路由器的配置信息全部加载在RAM里生效。路由器在启动过程中是将NVRAM里的配置文件加载到RAM里生效的。