重拾CCNA,持续更新ing......(8)

OSPF及OSPF的CCNA级别的综合实验(8)

2011.10.11
OSPF 区域范围0-65535
OSPF是基于路由器划分区域的,为什么呢?OSPF划分区域。层次化结构的优缺点?

        随着网络规模日益扩大,网络中的路由器数量不断增加。当一个巨型网络中的路由器都运行OSPF路由协议时,就会遇到如下问题:
        1.每台路由器都保留着整个网络中其他所有路由器生成的LSA,这些LSA的集合组成LSDB,路由器数量的增多会导致LSDB非常庞大,这会占用大量的存储空间。
        2.LSDB的庞大会增加运行SPF算法的复杂度,导致CPU负担很重。
由于LSDB很大,两台路由器之间达到LSDB同步会需要很长时间。
        3.网络规模增大之后,拓扑结构发生变化的概率也增大,网络会经常处于“动荡”之中,为了同步这种变化,网络中会有大量的OSPF协议报文在传递,降低了网络的带宽利用率。更糟糕的是:每一次变化都会导致网络中所有的路由器重新进行路由计算。 
        解决上述问题的关键主要有两点:减少LSA的数量;屏蔽网络变化波及的范围。
          OSPF 协议通过将自治系统划分成不同的区域(Area)来解决上述问题。区域是在逻辑上将路由器划分为不同的组。区域的边界是路由器,这样会有一些路由器属于不同的区域,(这样的路由器称作区域边界路由器——ABR),而一个网段只能属于一个区域。
        划分成区域之后,给OSPF协议的处理带来了很大的变化。

不与骨干区域直连采用虚拟隧道技术(虚链路)
OSPF的网络类型
LSA flooding stops at the area boundary

AS:autonomous system,自制系统
Point-to-point WAN 连接:串行链路
LAN  links:
邻居不一定是邻接,但邻接必是邻居
路由的更新和拓扑信息只在邻接路由器之间传播
OSPF包类型:
1hello
2date  description
3LSR
4LSU
5LSack
 

 

OSPF网络类型,各自用途??

OSPF的3个网络类型
P2P:串口(PPP,HDLC,SLIP)
Broadcast: 以太网
NBMA: FR,ATM,X.25

P2P
-通常是串行接口
-可以是FR的点对点方式接口
-没有DR/BDR选举
-OSPF自动检测此接口类型,串口上开启OSPF不用配置网络类型
-使用224.0.0.5
-Hello/Dead interval是10s/40s

Multiaccess Broadcast
-以太网或者Token Ring
-进行DR/BDR选举
-所有邻居路由器都只和DR/BDR形成邻接关系
-发给DR/BDR的包使用224.0.0.6
-DR发出给所有其他的路由器的包使用224.0.0.5

DR选举
-通过组播地址交换hello包
-最高priority者当选DR,次高者成为BDR。priority默认为1,取值范围0-255,越大越好,如果设置为0,则此路由器自动成为DROTHER
-priority相同时使用RouterID比较
-DR选举是non preemptive
-可以使用router-id命令指定router id,用ip ospf priority命令在接口上指定优先级,但是只有在router或ospf进程重启后,DR才会重新选举生效。

OSPF over NBMA Topology modes of operation
RFC标准
-NBMA
-Point to Multipoint
Cisco 私有标准
-Point to Multipoint nonbroadcast
-Broadcast
-Point-to-point

命令
在接口上配置:
ip ospf network [broadcast/point-to-multipoint/...]

***NBMA模式***
NBMA模式通常是在FR的静态配置模式下,此模式会产生以下三个问题

问题1.因为此类型虽是多路访问,但是因为默认网络中不发送广播或组播,所以OSPF不能自动形成邻居关系。
解决:使用neighbor命令指定邻居。注意neighbor命令中所跟的IP地址,是对端在和本身相连的接口的IP,而不是对端的RouterID

问题2.因为FR通常是星型(Hub and Spoke)拓扑,而不是全互联,所以此模式下不能自动选DR。
解决:在Spoke的接口上配置priority 0,使之只能成为DROther;让DR产生在HUB端。

问题3.Spoke端学到的路由下一跳是源Spoke端的IP地址,而在FR静态配置模式下,Spoke无法封装去该源Spoke的包。
解决:在Spoke端配置dlci map映射路径。


Point to Multipoint模式
1.不是默认的FR中的网络类型,但是RFC中标准的OSPF的网络类型
2.不是一个多路访问,而是看成多个P2P链路,不进行DR/BDR选举
3.Hello/Dead Interval和NBMA相同,为30/120秒
4.支持广播和组播,故OSPF可以自动建立邻居,不用neighbor命令
5.当HUB端学到SPOKE端的路由时,会把下一跳改成自己的IP再转发给其他的SPOKE,这样SPOKE之间不用配置FR MAP命令就可以互通
6.会产生Host Route
*注意,如果用静态方式,一定要加Broadcast参数,否则不能建邻居
 

 


RouterID:指定的方式
1,手工配置,权限最高,两种方式:物理接口IP,loopback  ip地址
2.路由协议自动选择:最优的首先看环回接口ip最大的,其次比较物理接口IP大的
RouterID作用:DR与BDR选举:先找优先级0-255(0不参与选举,1默认,255最大),后看RID
hellopacket,hello/dead时间为4倍关系
广播与点到点是hello时间10s
常规区域
末节区域
完全末节区域
NSSA
完全NSSA
OSPF jianli连接的七种状态:state
1down state
2init     state
3two way  state
4exstart   state
5exchange state
6loading state
7full    state
OSPF更新组播:224.0.0.6,回复组播224.0.0.5,
默认组播地址DR224.0.0.5,BDR224.0.0.6
OSPF中各种链路的COST值:

OSPF的开销(cost)是路由穿越的那些中间网络的开销的累加,其默认公式为开销=10的8次方除以带宽(带宽单位是b/s),也即100M除以带宽。
在局域网中:
100M的COST是1而不是19。
令牌环网有1M,4M,16M,100M之分,相应的COST是100,25,6.25,1。
T1链路是1.544M,相应的COST是64。
T3链路是45M,相应的COST是2。

CCNA级别的OSPF综合实验:

实验拓扑如下图:

 

 

R1配置如下:

R1#show run
Building configuration...

Current configuration : 809 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R1
!
!
ip subnet-zero
!
!
no ip domain-lookup
!
!
!
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
 ip address 192.168.1.1 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key cisco
 half-duplex
!
interface Ethernet0/1
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
router ospf 1
 log-adjacency-changes
 area 0 authentication
 network 1.1.1.1 0.0.0.0 area 0
 network 192.168.1.1 0.0.0.0 area 0
!
ip classless
no ip http server
!
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
!
end

R2配置如下:

R2#show run
Building configuration...

Current configuration : 916 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R2
!
!
ip subnet-zero
!
!
no ip domain-lookup
!
!
!
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
 ip address 192.168.1.2 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key 1 md5 cisco
 half-duplex
!        
interface Ethernet0/1
 ip address 192.168.2.1 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key 1 cisco
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
router ospf 1
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.1.2 0.0.0.0 area 0
 network 192.168.2.1 0.0.0.0 area 0
!
ip classless
no ip http server
!
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
!
end

R2#show run
Building configuration...

Current configuration : 916 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R2
!
!
ip subnet-zero
!
!
no ip domain-lookup
!
!
!
!
interface Loopback0
 ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
 ip address 192.168.1.2 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key 1 md5 cisco
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.2.1 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key 1 cisco
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
router ospf 1
 log-adjacency-changes
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.1.2 0.0.0.0 area 0
 network 192.168.2.1 0.0.0.0 area 0
!
ip classless
no ip http server
!
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
!
end

R3配置如下:

R3#show run
Building configuration...

Current configuration : 788 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname R3
!
!
ip subnet-zero
!
!
no ip domain-lookup
!
!
!
!
interface Loopback0
 ip address 3.3.3.3 255.255.255.0
!
interface Ethernet0/0
 ip address 192.168.2.2 255.255.255.0
 ip ospf authentication message-digest
 ip ospf authentication-key 1 cisco
 half-duplex
!
interface Ethernet0/1
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
router ospf 1
 log-adjacency-changes
 network 3.3.3.3 0.0.0.0 area 0
 network 192.168.2.2 0.0.0.0 area 0
!
ip classless
no ip http server
!
!
line con 0
 exec-timeout 0 0
 logging synchronous
line aux 0
line vty 0 4
!
end