《路由交换技术》第二章 路由器基本配置

第二章

0. 浅测一下吧~~

image.pngimage.png

image-20220524224830381

太棒了,你已经悟了上节课的一点内容了。咱不饶弯子,直接说重点。。。

关于此节内容练习,请转战mooc平台,本文件只负责复盘课程。。

1. 接口配置

查看当前设备接口

interface ?

查看指定type类型的接口编号范围

interface type 

开启接口(一般是默认关闭,所以配置的时候必须加这句)

no shutdown

关闭接口,没有no

然后我们看看有哪些接口类型type吧~~

image.png

配置逻辑接口(interface)

  1. 环回接口 本地测试用环回接口的编号范围为0-2147483647)
Router(config)#interface loopback 0
Router(config)#no interface loopback 0
Router(config)#show interface loopback 0
  1. 空接口,到空接口的数据全被丢弃
Router(config)#interace null 0
Router(config)#ip unreachables
#允许NULL接口发送ICMP的unreachable信息
Router(config)#ip route 127.0.0.0 255.0.0.0 null 0
#将到127.0.0.0的网络数据给NULL接口
  1. 子接口,即一个物理接口上配多个逻辑接口
Router(config)#interface serial 0.1
Router(config)#ip address 202.38.161.1 255.255.255.0

接口添加注释(description)

#语法: description string
Router(config)#interface fastethernet 0/0
Router(config-if)#description link to primary fastethernet network
Router#show interfaces fastEthernet 0/0 (查看描述信息)

接口带宽(bandwidth)

Router(config)# interface serial 0
Router(config-if)# bandwidth 10000 
语法:bandwidth kbps(kbit/s)

配置ip地址,哥们儿你这个不能不会啊!(ip address)

这个必须会!

这个必须会!

这个必须会!

image.png

Router0>enable
Router0#config terminal
Router0(config)#interface fastethernet 0/0
Router0(config-if)#ip address 192.168.1.1 255.255.255.0
Router0(config-if)#no shutdown 
Router0(config-if)#interface serial 0/0
Router0(config-if)#ip address 192.168.3.1 255.255.255.0 
Router0(config-if)#clock rate 56000
Router0(config-if)#no shutdown
Router1>enable
Router1#config terminal
Router1(config)#interface fastethernet 0/0
Router1(config-if)#ip address 192.168.2.1 255.255.255.0
Router1(config-if)#no shutdown 
Router1(config-if)#interface serial 0/0
Router1(config-if)#ip address 192.168.3.2 255.255.255.0 
Router1(config-if)#no shutdown

监视与维护端口(show)

show interfaces [type number] [brief]

Router# show interfaces  # 显示路由器全部接口信息
Router# show interfaces brief

2. 系统管理

配置线路line((line vty 0 4))

aux:辅助线路,线路号line-number必须为0

console:辅助线路,线路号line-number一般为0

tty:标准异步电路

vty:虚拟终端线路

不多废话,line命令如下

line  [aux|console|tty|vty] line-number [ending-line-number]

举例,

Router(config)#line console 0
Router(config-line)#
# 进入控制台虚拟终端线路
Router(config)#line vty 0 4
Router(config-line)#
# 进入终端线路配置

配置口令

IOS五大口令。

console控制台 口令

辅助端口 口令

虚拟终端端口 口令

enable password口令

enable secret 口令

配置控制台端口 口令举例

口令是cisco。

Router(config)#line console 0
Router(config-line)#password cisco
Router(config-line)#login

配置辅助端口 口令举例

口令如上,不多赘述。

Router(config)#line aux 0
Router(config-line)#password cisco
Router(config-line)#login

配置虚拟端口 口令举例

其实已经可以看出规律了

Router(config)#line vty 0 4
Router(config-line)#password cisco
Router(config-line)#login

enable password 口令

enable password [level level]

注:enable password经过加密存储,其口令是明文(待加密)。

【level】是口令应用等级,默认15.

【encrypt-type】是cisco私有算法加密,唯一值为5

【encrypt-password】是加密口令

举例,设置进入特权模式的口令为cisco

Router(config)# enable password cisco

enable secret口令

注:这是不安全的,因为他没有经加密存储,其口令就是密文。

举例,进入特权模式口令为cisco

Router(config)# enable secret cisco

配置主机名(hostname)

全局配置模式下,hostname命令配置。

Router(config)#hostname R1
R1(config)#

3. 文件管理

image.png

仅说明两点:左边的RAM是存储器;右边的NVRAM里面的config是启动配置。

简单文件传输协议TFTP是FTP升级版协议,就是用来传输的协议。

复制配置文件(copy)

特权模式下,使用命令copy可将源文件拷贝到目标文件。

copy source-url destination-url

主要补充一下这语法里的url。

url别名

前面提到的RAM和NVRAM的URL是有简写的,请看:

system:running-config - > running-config

nvram:startup-config -> startup-config

比如说,你需要输入启动配置的路径url,直接输入startup-config即可,这是cisco他们规定的url别名。

然后其他的话浅浅看看吧~就随便列举了一些

特定文件系统url 前缀关键字

image.png

远端文件系统url 前缀关键字

image.png

本地可写存储系统url 前缀关键字

image.png

举例

远端服务器拷贝配置文件host2-confg到启动配置文件,服务器IP地址为172.16.101.101,用户名是netadmin1,密码是ftppass。

Router#copy ftp://netadmin1:ftppass@172.16.101.101/host2-confg nvram:startup-config

拷贝运行配置文件到启动配置文件

Router#copy system:running-config nvram:startup-config

复制映像

方法同样是copy

例如,从rcp服务器172.16.101.101拷贝系统映像file1到闪存。

Router# copy rcp://netadmin@172.16.101.101/file1 flash:file1 

指定启动配置文件(boot)

指定配置文件的文件名代码如下,请看。

boot config file-url

no boot config

举例,从闪存加载配置文件router-config,并复制到启动配置文件,使得重新启动后生效

Router(config)# boot config flash:router-config
Router(config)# end
Router# copy system:running-config nvram:startup-config

时间关系,其他略了,以后想起来再补充吧,,毕竟期末不考这个。

4. 故障处理

显示系统信息(show)

特权模式下,就可以show了,便于debug。。

image.png

测试网络连接(ping)

这应该dddd吧。。

语法如下

ping [protocol {hostname | system-address}]

ping 192.168.1.1

这边就提两个测试字符

'!',表示ICMP回应回答
'.',表示回应应答超时

跟踪数据包(trace)

跟ping差不多,用到的时候再研究....

trace mit.edu

连接目的主机(telnet,这个挺重要)

image.png

  1. Router1 telnet连接 Router2
Router1#telnet 192.168.1.2
Trying 192.168.1.2 ...
User Access Verification
Password: 
Router2>
  1. 挂起连接router2会话
Router2><ctrl+shift+6>x
Router1#
  1. router1 telnet router3
Router1#telnet 192.168.2.2
Trying 192.168.2.2 ...
User Access Verification
Password: 
Router3><ctrl+shift+6>x
Router1#show sessions
Conn  	Host                 Address       Byte  	Idle   	Conn Name
1	192.168.1.2    192.168.1.2    0     	8    	192.168.1.2
* 2   	192.168.2.2    192.168.2.2     0     	8    	192.168.2.2
  1. 显示活动线路用户信息
Router2#show users
  1. 恢复挂起的telnet会话

resume session-number

后面跟的是会话号

Router1#resume 1
[Resuming connection 1 to 192.168.1.2 ... ]
Router2>

后面略,以后再看吧。。


5. CDP配置(不作为重点)

CDP(cisco discovery protocol)cisco发现协议。

老师居然没有划掉这个?

我感觉不重要,毕竟是私有协议。

这里就写几个协议的应用。

指定CDP更新周期(默认60秒)

cdp timer seconds
no cdp timer

指定接收设备丢弃CDP包前保持时间

cdp holdtime seconds
no cdp holdtime

seconds就是具体的时间(单位为秒)

举例,设置CDP定时器,每隔30秒发送更新到邻居路由器。设置保持时间为90秒。

Router(config)# cdp timer 30
Router(config)# cdp holdtime 90
Router(config)# exit
Router# show cdp interface
Serial0 is up, line protocol is up
Encapsulation is HDLC
Sending CDP packets every 30 seconds
Holdtime is 90 seconds

CDP v2通告

这里还有一个CDP v2通告功能,默认是启用的

image.png

启用/禁用CDP

cdp run
no cdp run

接口上启用/禁用CDP

cdp enable
no cdp enable

显示全局CDP信息(EXEC模式)

show cdp

显示CDP接口信息

show cdp interfaces

显示cdp邻居的信息

show cdp neighbors [detail]

显示CDP流量信息

show cdp traffic

复位CDP流量计数器

clear cdp counters

清除邻居信息表格

clear cdp table

完结。。


posted @ 2022-08-08 15:10  yuezi2048  阅读(81)  评论(0)    收藏  举报