路由器学习.docx
《路由器学习.docx》由会员分享,可在线阅读,更多相关《路由器学习.docx(12页珍藏版)》请在冰豆网上搜索。
路由器学习
路由器的管理方式基本分为两种:
带内管理和带外管理。
通过路由器的Console口管理交换机属于带外管理,不占用路由器的网络接口,但特点是线缆特殊,需要近距离配置。
第一次配置路由器时必须利用Console进行配置使其支持telnet远程管理。
路由器的命令行操作模式,主要包括:
用户模式、特权模式、全局配置模式、端口模式等。
用户模式 Red-Giant>
特权模式 Red-Giant#
全局配置模式 Red-Giant(config)#
端口模式 属于全局模式的下一级模式,该模式下可以对路由器的端口进行参数配置。
exit退回上一级操作模式
end 直接退回到特权模式
Red-Giant>enable14!
进入特权模式(之后要输入密码)
Red-Giant#configureterminal!
进入全局配置模式
Red-Giant(config)#interfacefastethernet0/1 !
进入路由器F0/1的接口模式
Red-Giant(config-if)
*********************************************************************************
Red-Giant>?
!
显示当前模式下所有可执行的命令
剩下同交换机的操作
*********************************************************************************
RouterA(config)#bannermotd& !
配置每日提示信息&为终止符
*********************************************************************************
锐捷路由器接口Fastethernet接口默认情况下是10M/100M自适应端口,双工模式也为自适应,并且在默认情况下路由器物理端口处于关闭状态。
路由器A的操作:
Red-Giant>enable14
(password:
b402)
Red-Giant#
Red-Giant#configureterminal
Red-Giant(config)#
Red-Giant(config)#hostnameRa
Ra(config)#interfaceserial2/0 !
进行s2/0的端口模式
Ra(config-if)#ipaddress1.1.1.1255.255.255.0 !
配置端口的IP地址
Ra(config-if)#clockrate64000 !
在DCE接口上配置时钟频率64000
Ra(config-if)#bandwidth512 !
配置端口的带宽速率为512KB
Ra(config-if)#noshutdown !
开启该端口,使端口转发数据
!
配置带宽时,以K为单位
路由器B的操作:
Red-Giant>enable14
(password:
b402)
Red-Giant#
Red-Giant#configureterminal
Red-Giant(config)#
Red-Giant(config)#hostnameRb
Rb(config)#interfaceserial2/0 !
进行s2/0的端口模式
Rb(config-if)#ipaddress1.1.1.2255.255.255.0 !
配置端口的IP地址
Rb(config-if)#clockrate64000 !
在DCE接口上配置时钟频率64000
Rb(config-if)#bandwidth512 !
配置端口的带宽速率为512KB
Rb(config-if)#noshutdown !
开启该端口,使端口转发数据
!
配置带宽时,以K为单位
查看路由器端口配置参数
Ra#showinterfaceserial2/0 !
查看Raserial2/0接口状态
Ra#showipinterfaceserial2/0 !
查看该端口的IP协议相关属性
Rb#showinterfaceserial2/0 !
查看Rbserial2/0接口状态
Rb#showipinterfaceserial2/0 !
查看该端口的IP协议相关属性
Ra#ping1.1.1.2 !
在Raping对端Rbserial1/2接口的IP
*********************************************************************************
Ra#showversion !
查看路由器的版本信息
Ra#showiproute !
查看路由器路由表信息
Ra#showrunning-config !
查看交换机当前生效的配置信息
Ra#showstartup-config !
查看保存在NVRAM里的配置文件信息
*********************************************************************************
路由器属于网络层设备,能够根据IP包头的信息,选择一条最佳路径,将数据包转发出去。
实现不同网段的主机之间互相访问。
路由表的产生方式一般有3种:
直接路由:
给路由器接口配置一个IP地址,路由器自动产生本接口IP所在网段的路由信息。
静态路由:
在拓扑结构简单的网络中,网管员通过手工的方式配置本路由器未知网段的路由信息,从而实现不同网段之间的连接。
动态路由协议学习产生的路由:
动态路由协议,路由器之间自动学习产生的路由信息。
*********************************************************************************
配置路由器1
Router1(config)#interfacefastethernet0/1
Router1(config-if)#ipaddress172.16.1.1255.255.255.0
Router1(config-if)#noshutdown
Router1(config-if)#ipaddress172.16.2.1255.255.255.0
Router1(config-if)#clockrate64000 !
配置Router1的时钟频率(DCE)
Router1(config)#noshutdown
验证测试:
Router1#showipinterfacebrief
查看接口状态:
Router1#showinterfaceserial2/0
在路由器1上配置静态路由:
Router1(config)#iproute172.16.3.0255.255.255.0172.16.2.2
或:
Router1(config)#iproute172.16.3.0255.255.255.0serial2/0
验证测试:
Router1#showiproute
配置路由器2
Router2(config)#interfacefastethernet0/1
Router2(config-if)#ipaddress172.16.3.2255.255.255.0
Router2(config-if)#noshutdown
Router2(config)#interfaceserial2/0
Router2(config-if)#ipaddress172.16.2.2255.255.255.0
Router2(config-if)#noshutdown
验证测试:
Router2#showipinterfacebrief
Router2#showinterfaceserial2/0
在路由器2上配置静态路由
Route2(config)#iproute172.16.1.0255.255.255.0172.16.2.1
或:
Route2(config)#iproute172.16.1.0255.255.255.0serial2/0
验证测试:
Route2#showiproute
测试网络的互联互通性
C:
\>ping172.16.3.22 !
从PC1ping PC2
C:
\>ping172.16.1.11 !
从PC2ping PC1
注意:
如果两台路由器通过串口直接相连,则必须在其中一端设置时钟频率(DCE)。
*********************************************************************************
RIP(RoutingInformationProtocols,路由信息协议),是较早应用,使用普遍的IGP(InteriorGatewayProtocol,内部网关协议)。
适用于小型同类网络,属于距离矢量(distance-vector)协议。
RIP协议以跳数作为衡量路径的开销,RIP协议规定最大跳数为15。
RIP协议有两个版本RIPv1和RIPv2。
RIPv1属于有类路由协议,不支持VLSM(变长子网掩码),是以广播的形式进行路由信息的更新的,更新周期30s。
RIPv2属于无类路由协议,支持VLSM(变长子网掩码),RIPv2是以组播的形式进行路由信息的更新的,组播地址是224.0.0.9。
支持基于端口的认证,能提高网络安全。
*********************************************************************************
三层交换机基本配置:
switch#configureterminal
switch(config)#hostnameS3550
S3550(config)#vlan10
S3550(config-vlan)#exit
S3550(config)#vlan50
S3550(config-vlan)#exit
S3550(config)#interfacef0/1
S3550(config-if)#switchportaccessvlan10
S3550(config-if)#exit
S3550(config)#interfacef0/5
S3550(config-if)#switchportaccessvlan50
S3550(config-if)#exit
S3550(config)#interfacevlan10 !
创建VLAN虚接口,并配置IP
S3550(config-if)#ipaddress172.16.1.2255.255.255.0
S3550(config-if)#noshutdown
S3550(config-if)#exit
S3550(config)#interfacevlan50 !
创建VLAN虚接口,并配置IP
S3550(config-if)#ipaddress172.16.5.1255.255.255.0
S3550(config-if)#noshutdown
S3550(config-if)#exit
两个路由器基本配置:
Router1(config)#interfacefastethernet0/1
Router1(config-if)#ipaddress172.16.1.1255.255.255.0
Router1(config-if)#noshutdown
Router1(config-if)#exit
Router1(config)#interfaceserial2/0
Router1(config-if)#ipaddress172.16.2.1255.255.255.0
Router1(config-if)#clockrate64000
Router1(config-if)#noshutdown
Router2(config)#interfacefastethernet0/1
Router2(config-if)#ipaddress172.16.3.1255.255.255.0
Router2(config-if)#noshutdown
Router2(config-if)#exit
Router2(config)#interfaceserial2/0
Router2(config-if)#ipaddress172.16.2.2255.255.255.0
Router2(config-if)#noshutdown
S3550配置RIP协议:
S3550(config)#routerrip !
开启RIP协议进程
S3550(config-router)#network172.16.1.0 !
申明本设备的直连网段
S3550(config-router)#network172.16.5.0
S3550(config-router)#version2
路由器1配置RIP协议:
Router1(config)#routerrip
Router1(config-router)#network172.16.1.0
Router1(config-router)#network172.16.2.0
Router1(config-router)#version2 !
定义RIP协议v2
Router1(config-router)#noauto-summary !
关闭路由信息的自动汇总功能
路由器2配置RIP协议:
Router2(config)#routerrip
Router2(config-router)#network172.16.2.0
Router2(config-router)#network172.16.3.0
Router2(config-router)#version2
Router2(config-router)#noauto-summary
验证三台路由设备的路由表是否自动学习了其他网段的路由信息:
S3550#showiproute
Router1#showiproute
Router2#showiproute
测试连通性:
C:
\>ping172.16.3.22 !
从PC1到PC2
*********************************************************************************
OSPF(OpenShortestPathFirst开放式最短路径优先)协议,是目前网络中应用最广泛的路由协议之一。
属于内部网关路由协议,能够适应各种规模的网络环境,是典型的链路状态(link-state)协议。
OSPF路由协议通过向全网扩散本设备的链路状态信息,使网络中每台设备最终同步一个具有全网链路状态的数据库(LSDB),然后采用SPF算法,以自己为根计算到达其他网络的最短路径,最终形成全网络路由信息。
OSPF属于无类路由协议,支持VLSM(变长子网掩码)。
以组播的形式进行链路状态通告。
在大规模的网络环境中,OSPF支持区域的划分,将网络进行合理规划。
划分区域时必须存在area0(骨干区域)。
其他区域和骨干区域直接相连,或通过虚链路方式连接。
*********************************************************************************
三层交换机基本配置:
switch#configureterminal
switch(config)#hostnames3550
S3550(config)#vlan10
S3550(config-vlan)#exit
S3550(config)#vlan50
S3550(config-vlan)#exit
S3550(config)#interfacef0/1
S3550(config-if)#switchportaccessvlan10
S3550(config-if)#exit
S3550(config)#interfacef0/5
S3550(config-if)#switchportaccessvlan50
S3550(config-if)#exit
S3550(config)#interfacevlan10 !
创建VLAN虚接口,并配置IP
S3550(config-if)#ipaddress172.16.1.2255.255.255.0
S3550(config-if)#noshutdown
S3550(config-if)#exit
S3550(config)#interfacevlan50 !
创建VLAN虚接口,并配置IP
S3550(config-if)#ipaddress172.16.5.1255.255.255.0
S3550(config-if)#noshutdown
S3550(config-if)#exit
两个路由器基本配置:
Router1(config)#interfacefastethernet0/1
Router1(config-if)#ipaddress172.16.1.1255.255.255.0
Router1(config-if)#noshutdown
Router1(config-if)#exit
Router1(config)#interfaceserial2/0
Router1(config-if)#ipaddress172.16.2.1255.255.255.0
Router1(config-if)#clockrate64000
Router1(config-if)#noshutdown
Router2(config)#interfacefastethernet0/1
Router2(config-if)#ipaddress172.16.3.1255.255.255.0
Router2(config-if)#noshutdown
Router2(config-if)#exit
Router2(config)#interfaceserial2/0
Router2(config-if)#ipaddress172.16.2.2255.255.255.0
Router2(config-if)#noshutdown
S3550配置OSPF路由协议:
S3550(config)#routerospf !
开启OSPF路由协议进程
S3550(config-router)#network172.16.5.00.0.0.255area0 !
申请直连网段信息,并分配区域号
S3550(config-router)#network172.16.1.00.0.0.255area0
S3550(config-router)#end
Router1配置OSPF路由协议:
Router1(config)#routerospf
Router1(config-router)#network172.16.1.00.0.0.255area0
Router1(config-router)#network172.16.2.00.0.0.255area0
Router1(config-router)#end
Router2配置OSPF路由协议:
Router2(config)#routerospf
Router2(config-router)#network172.16.2.00.0.0.255area0
Router2(config-router)#network172.16.3.00.0.0.255area0
Router2(config-router)#end
验证三台路由设备的路由表是否自动学习了其他网段的路由信息:
S3550#showiproute
Router1#showiproute
Router2#showiproute
测试网络连通性:
C:
\>ping172.16.3.22 !
从PC1pingPC2
*********************************************************************************
IPACL(IP访问控制列表或IP访问列表)是实现对流经路由器或交换机的数据包根据一定的规律进行过滤,从而提高网络可管理性和安全性。
IPACL分为两种:
标准IP访问列表和扩展IP访问列表。
标准IP访问列表可以根据数据包的源IP地址定义规则,进行数据包过滤。
扩展IP访问列表可以根据数据包的源IP地址、目的IP地址、源端口、目的端口、协议来定义规则,进行数据包过滤。
IPACL基于接口进行规则的应用,分为:
入栈应用和出栈应用。
入栈应用:
由外部经该接口进行路由器的数据包进行过滤。
出栈应用:
路由器从该接口向外转发数据时进行数据包过滤。
IPACL的配置有两种方式:
按照标号的访问列表,按照命名的访问列表。
标准IP访问列表编号范围是1~99、1300~1999,扩展IP访问列表的范围是100~199、2000~2699。
*********************************************************************************
Router1基本配置
Red-Giant>enable14
(password:
b402)
Red-Giant#configureterminal
Red-Giant(config)#hostnameRouter1
Rou