《路由交换技术》第六章 RIP和OSPF配置
第六章
0. 浅浅测一下
RIP路由更新周期是?
A. 10s
B. 180s
C. 30s
D. 240s
内部网关协议有哪些?(多选)
A. RIP
B. OSPF
C. BGP
D. EIGIP
快速以太网的带宽是多少?
A. 10Mb/s
B. 100M b/s
C. 1000Mb/s
D. 1 Mb/s
- C 2. ABD 3. B
1. RIP
概述
(1)RIP属于距离向量路由选择协议。
(2)RIP消息通过广播地址255.255.255.255进行发送,使用UDP 协议的520端口。
(3)RIP以到目的网络的最小跳数作为路由选择度量标准。
(4)RIP是为小型网络设计的。它的跳数计数限制为15跳,16跳为不可到达。
(5)RIP-1是一种有类路由协议,不支持不连续子网设计。RIP-2支持CIDR及VLSM可变长子网掩码,使其支持不连续子网设计。
(6)RIP周期进行路由更新,将路由表广播给邻居路由器,广播周期默认为30秒。
(7)RIP的管理距离为120。
放止回路的方法
(1)最大跳数 16跳不可达
(2)水平分割
(3)带毒性逆转的水平分割
(4)抑制定时器
(5)触发更新
缺点
(1)只适用于较小的自治系统,不能支持超过15跳数的路由。
(2)路由表更新信息将占用较大的网络带宽。
(3)RIP的收敛速度慢。
*启用RIP(router rip)
network:指定RIP路由进程的网络列表
在连接网络10.99.0.0和192.168.7.0的所有接口定义RIP。
Router(config)# router rip
Router(config-router)# network 10.99.0.0
Router(config-router)# network 192.168.7.0
单播更新(neighbor)
neighbor:定义一个与其交换路由信息邻接路由器
RIP更新发送到网络10.108.0.0的所有接口,路由更新发送到指定邻居。
Router(config)# router rip
Router(config-router)# network 10.108.0.0
Router(config-router)# neighbor 10.108.20.4
计时器(timers basic)
RIP有如下定时器:
路由更新定时器
路由失效定时器
保持失效定时器
路由刷新定时器
调整定时器代码如下
timers basic update invalid holddown flush
no timers basic
设置每5秒广播更新。如果某台路由器在15秒内没有被得到关于它的信息,该路由被宣布为不可用。其后信息再被抑制15秒。在压制期结束时,路由从路由表中清除。
Router(config)# router rip
Router(config-router)# timers basic 5 15 15 30
最大路径数(naximum-paths)
为RIP路由进程配置并行路由最大值为16
Router(config)# router rip
Router(config-router)# maximum-paths 16
RIP版本(version)
指定RIP版本为版本2
Router(config-router)# version 2
配置接口发送RIP版本1和版本2数据包出接口
Router(config-if)# ip rip send version 1 2
Router(config-if)# ip rip send version 2	# 只发送版本2
*RIP认证(ip rip authentication)
创建密钥,以trees为例
Router(config-if)# ip rip authentication key-chain trees
设置加密类型
text 明文认证
md5 信息摘要认证
以mad5为例,在接口上配置MD5认证
Router(config-if)# ip rip authentication mode md5
启用 认证密钥组key-chain
Router(config-if)# key-chain name-of-chain
设置认证密钥
key key-id
设置认证字符串:
key-string text
设置接收认证密钥的有效时间accept-lifetime,开头必须指定
accept-lifetime start-time {infinite | end-time | duration seconds} 
no accept-lifetime start-time {infinite | end-time | duration seconds}  #恢复默认值
设置发送认证密钥的有效时间accept-lifetime,开头必须指定
send-lifetime start-time {infinite | end-time | duration seconds} 
no send-lifetime start-time {infinite | end-time | duration seconds} 
实例
配置一个chain1密钥链.
名为key1的密钥 下午1:30到3:30被接收。名为key2的密钥 下午2:30到4:30被接收,下午3:00到4:00被发送。
注:时间上的重叠是考虑到了路由器时间的差异
Router(config)# interface ethernet 0
Router(config-if)# ip rip authentication key-chain chain1
Router(config-if)# ip rip authentication mode md5
Router(config-if)# exit
Router(config)# router rip
Router(config-router)# network 172.19.0.0
Router(config-router)# version 2
Router(config-router)# exit
Router(config)# key chain chain1
Router(config-keychain)# key 1
Router(config-keychain-key)# key-string key1
Router(config-keychain-key)# accept-lifetime 13:30:00 Jan 25 1996 duration 7200
Router(config-keychain-key)# send-lifetime 14:00:00 Jan 25 1996 duration 3600
Router(config-keychain)# key 2
Router(config-keychain-key)# key-string key2
Router(config-keychain-key)# accept-lifetime 14:30:00 Jan 25 1996 duration 7200
Router(config-keychain-key)# send-lifetime 15:00:00 Jan 25 1996 duration 3600
水平分割(ip split-horizon)
在连接到帧中继网络的串行链路上禁用水平分割
Router(config)# interface serial 0
Router(config-if)# encapsulation frame-relay
Router(config-if)# no ip split-horizon
自动汇总(auto-summary)
恢复自动汇总子网路由到网络路由的默认行为
Router0的E0/0端口连到192.168.1.0,为Router0配置路由汇总地址172.16.64.0/23。
Router0(config-router)# no auto-summary
Router0(config-router)# exit
Router0(config)# interface etherent 0/0
Router0(config-if)# ip summary-address rip 172.16.64.0 255.255.254.0
监视与维护(show ip route rip)
显示路由10.11.0.0/16的汇总地址项,包括三个活动子路由。
Router# show ip rip database
10.0.0.0/8      auto-summary
10.11.11.0/24   directly connected, Ethernet2
10.1.0.0/8      auto-summary
10.11.0.0/16    int-summary
10.11.10.0/24    directly connected, Ethernet3
10.11.11.0/24    directly connected, Ethernet4
10.11.12.0/24    directly connected, Ethernet5
带有可选项的show ip rip database命令输出
Router# show ip rip database 172.19.86.0 255.255.255.0
172.19.86.0/24
[1] via 172.19.67.38, 00:00:25, Serial0
[2] via 172.19.70.36, 00:00:14, Serial1 
显示认证密钥信息
show key chain
Router# show key chain
Key-chain trees:
    key 1 -- text "chestnut"
        accept lifetime (always valid) - (always valid) [valid now]
        send lifetime (always valid) - (always valid) [valid now]
    key 2 -- text "birch"
        accept lifetime (00:00:00 Dec 5 1995) - (23:59:59 Dec 5 1995)
        send lifetime (06:00:00 Dec 5 1995) - (18:00:00 Dec 5 1995)
2. OSPF
概述
OSPF:基本上是绘出互联网络的全图,然后根据这张图选择代价最低的路径。
优点:
(1)开销减少。
(2)支持VLSM和CIDR。
(3)支持不连续网络。
(4)支持手工路由汇总。
(5)收敛时间短。
(6)无环拓扑生成。
(7)跳步数只受路由器资源使用和IP TTL的限制。
小补计网OSPF协议
-- 自治系统(AS): AS是一组使用相同路由协议交换路由信息的路由器
-- 区域:OSPF允许把自治系统划分成多个连续网络群组
路由器类型:
    -- 内部路由器(IR)
	-- 区域边界路由器(ABR)
	-- AS边界路由器(ASBR)
	-- 骨干路由器(Backbone Router)
指定路由器(DR)和备份指定路由器(BDR)
	指定路由器就是集中负责一个区域内各路由器间的链路状态更新(LSU)交换和邻接关系建立
骨干区域:
    -- 区域ID为0的区域叫骨干区域,他是分发路由信息的中心枢纽。
*启用OSPF协议(router ospf)
定义OSPF路由进程
router ospf proccess-id
运行OSPF接口和区域ID(路由器配置下)
network ip-address wildcard-mask area area-id
wildcard-mask是反向掩码
area-id:与OSPF地址范围相关联的区域ID,可以指定为一个十进制数,或者一个IP地址。如果一个区域与一个IP子网相关联,指定一个子网地址作为area-id参数。如果定义的OSPF只有单一区域,该值必须为0或0.0.0.0,即定义该区域为主干区域
使用固定路由器ID
router-id ip-address
实例
初始化OSPF路由进程109,定义4个区域:10.9.50.0、2、3和0。区域10.9.50.0、2和3掩码指定地址范围,区域0为其他所有网络启用OSPF,设置路由器ID
Router(config)# interface ethernet 0
Router(config-if)# ip address 10.108.20.1 255.255.255.0
Router(config)# router ospf 109
Router(config-router)# network 10.108.20.0 0.0.0.255 area 10.9.50.0
Router(config-router)# network 10.108.0.0 0.0.255.255 area 2
Router(config-router)# network 10.109.10.0 0.0.0.255 area 3
Router(config-router)# network 0.0.0.0 255.255.255.255 area 0
//通过环回接口设置路由器ID
Router(config)# interface loopback 0
Router(config-if)#ip address 192.168.1.1 255.255.255.255
//或者设置固定路由器ID
Router(config-router)# router-id 192.168.1.1
接口度量(cost)
OSPF使用成本的计算公式是:
成本=10^8/带宽

设置接口成本值为65
Router(config-if)# ip ospf cost 65
*OSPF认证(authentication)
分配邻居路由器在OSPF明文认证中使用的密码
ip ospf authentication-key password
no ip ospf authentication-key
在一个OSPF区域启用认证
area area-id authentication [message-digest] 
启用OSPF MD5 认证
ip ospf message-digest-key key-id encryption-type md5 key 
encryption-type:认证类型,0表示不加密
实例
为OSPF路由进程201的区域0和10.0.0.0配置明文认证。
Router(config)# interface ethernet 0
Router(config-if)# ip address 192.168.251.201 255.255.255.0
Router(config-if)# ip ospf authentication-key adcdefgh
Router(config-if)# exit
Router(config)# interface ethernet 1
Router(config-if)# ip address 10.56.0.201 255.255.0.0
Router(config-if)# ip ospf authentication-key ijklmnop
Router(config-if)# exit
Router(config)# router ospf 201
Router(config-router)# network 10.0.0.0 0.255.255.255 area 10.0.0.0
Router(config-router)# network 192.168.0.0 0.0.255.255 area 0
Router(config-router)# area 10.0.0.0 authentication
Router(config-router)# area 0 authentication
MD5认证
Router(config)# interface ethernet 0
Router(config-if)# ip address 192.168.251.201 255.255.255.0
Router(config-if)# ip ospf message-digest-key 1 md5 adcdefgh
Router(config-if)# exit
Router(config)# interface ethernet 1
Router(config-if)# ip address 10.56.0.201 255.255.0.0
Router(config-if)# ip ospf message-digest-key 1 md5 ijklmnop
Router(config-if)# exit
Router(config)# router ospf 201
Router(config-router)# network 10.0.0.0 0.255.255.255 area 10.0.0.0
Router(config-router)# network 192.168.0.0 0.0.255.255 area 0
Router(config-router)# area 10.0.0.0 authentication message-digest
Router(config-router)# area 0 authentication message-digest
为接口指定认证类型
ip ospf authentication [message-digest | null]
message-digest:消息摘要认证
null:不使用认证
为接口启用消息摘要认证。
Router(config-if)# ip ospf authentication message-digest
路由器优先级(ip ospf priority)
ip ospf priority number-value
设置路由器优先级值为4。
Router(config)# interface ethernet 0
Router(config-if)# ip ospf priority 4
监视与维护OSPF
显示路由器的定时器、过滤器、度量值、网络和其他信息等参数
Router# show ip protocols
显示路由器通过学习获得的路由和这些路由时如何学习回到的
Router# show ip route ospf
显示OSPF路由进程一般信息
Router# show ip route ospf [process-id]
显示指定路由器的OSPF相关信息列表
Router# show ip ospf [process-id area-id] database
Router# show ip ospf database 
OSPF Router with id(192.168.239.66) (Process ID 300)
                 Displaying Router Link States(Area 0.0.0.0)
Link ID     	ADV Router  	Age   	Seq#     		Checksum  	Link count
172.16.21.6   	172.16.21.6    1731  	0x80002CFB   	0x69BC       	8
172.16.21.5   	172.16.21.5    1112   0x800009D2   0xA2B8       	5
172.16.1.2    	172.16.1.2     1662   0x80000A98   0x4CB6       	9
172.16.1.1   	172.16.1.1     1115   0x800009B6   0x5F2C       	1	
172.16.1.5    	172.16.1.5     1691   0x80002BC   	0x2A1A      	5
172.16.65.6   	172.16.65.6    1395   0x80001947   	0xEEE1     	4
172.16.241.5  	172.16.241.5   1161   0x8000007C   	0x7C70      	1
172.16.27.6   	172.16.27.6    1723   0x80000548   	0x8641      	4
显示OSPF相关接口信息
show ip ospf [process-id] interface [interface-type interface-number] [brief] [multicast]
Router# show ip ospf  interface ethernet 0
显示每个接口上的OSPF邻居信息
show ip ospf neighbor [interface-type interface-number] [neighbor-id] [detail]
Router# show ip ospf neighbor 10.199.199.137
显示OSPF流量统计信息
Router# show ip ospf traffic
清除基于OSPF路由进程ID的重分发
clear ip ospf [pid] {process | redistribution | counters [neighbor [neighbor-interface] [neighbor-id]]}
清除所有OSPF进程。
Router# clear ip ospf process
清除OSPF流量统计
clear ip ospf [process-id] traffic [interface-type interface-number]
清除OSPF进程100的OSPF流量统计。
Router# clear ip ospf 100 traffic

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号