OSPF 多域之間的配置 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

拓扑图如下

IP 地址的划分

<1>RO

LO: 172.16.1.1/24   S0/0: 172.16.0.5/30

<2>R1

S0/0: 172.16.0.6/30   S0/1: 192.168.64.1/30   F1/0: 192.168.1.2/24

<3>R2

S0/0:  192.168.224.1/30  F1/0:  192.168.1.3/24

<4>R3

S0/0: 192.168.224.2/30   F1/0: 192.168.248.1/24

<5>R4

S0/0: 192.168.64.2/30    F1/0: 192.168.72.1/24 

<6>PC1:192.168.248.2/24        PC2: 192.168.72.2/24     1.先配置各台路由器且使用Ping命令确认各路由器的直连口的互通性。(注意 PC1,PC2Ping 通各自的网关)                                                                             2.划分区域分别把各自所在的网段发布出去,外网做RIP路由进来   
   R 0
  R 0 (config)#router  rip
   R 0 (config-router) #version 2<运行RIP 版本2,允许携带子网掩码>  R 0 (config-router)# network 172.16.1.0
   R 0 (config-router)#network  172.16.0.4 <根据划分子网的知识  172.16.0.5在172.16.0.4中>
   R 0 (config-router)#  exit
   R1<ASBR>
   R 1 (config)#router  rip
   R 0 (config-router) #version 2
   R 1 (config-router)#network  172.16.0.4 <根据划分子网的知识172.16.0.6在172.16.0.4中>
   R 1 (config)#router  ospf 1<OSPF进程只对本地有效>
   R 1 (config-router)# network 192.168.64.0 0.0.0.3 area 1<子网码为255.255.255.252的反码>
   R 1 (config-router)# network 192.168.1.0 0.0.0.255 area 0<加入区域0>
   R 1 (config-router)#   area  1  stub no-summary 
   R2<ABR>
   R 2 (config)#router  ospf 1
   R 2 (config-router)# network 192.168.1.0 0.0.0.255 area 0<加入区域0>
   R 2 (config-router)# network 192.168.224.0 0.0.0.3 area 2<加入区域2>
   R 2 (config-router)#   exit
   R3
   R 2 (config)#router  ospf 1
   R 2 (config-router)# network 192.168.224.0 0.0.0.3  area 2<加入区域2>
   R 2 (config-router)# network 192.168.248.0 0.0.0.255 area 2<加入区域2>
   R 2 (config-router)#   exit
   R4
   R 2 (config)#router  ospf 1
   R 2 (config-router)# network 192.168.64.0 0.0.0.3 area 1<加入区域1>
   R 2 (config-router)# network 192.168.72.0 0.0.0.255 area 1<加入区域1>
   R 2 (config-router)#   area 1 stub no-summary<把此区域配置为完全未梢区域>
   R 2 (config-router)#   exit
   配置完后可以show一下
   <1> show ip ro ute < 查看OSPF路由的生成 >
   注意R4上只有一条默认的OSPF路由,它不能学习到外部的路由
   <2>show ip  protocols <查看OSPF 区域配置情况> 
   3.在R1路由器上做路由的重分发
   R3(config)#router ospf 1
    R3(config-router)#redistribute rip metric 200 subnets 
    R3(config-router)# exit
    R3(config)#router rip
    R3(config-router)#redistribute ospf 1 metric 10 
    R3(config-router)# exit
    查看配置
   <1> show ip ro ute <在RO上的RIP路由条目,R1上的RIP和OSPF路由条目>
   <2>ping 172.16.1.1<分别用pc1,pc2 ping 外网172.16.1.1查看它的连通性>
   4.在R1和R2上做路由汇总,并且把R1配置为永久DR
   R 1 (config)#router  ospf 1<OSPF进程只对本地有效>
    R 1 (config-router)#   summary-address  172.16.0.0 255.252.0.0<把外部路由汇总>
    R 1 (config-router)# exit
    R 2 (config)#router  ospf 1
    R 2 (config-router)# area 2 range 192.168.0.0 255.252.0.0 <把区域2中的内部路由汇总>
    R 2 (config-router)# exit
    R 2 (config)# in f1/0
    R 2 (config- if )# ip ospf  priority 0 <把R2上的F1/0端口的优先级改为0>
   查看配置
   <1>show ip route <再次查看它的OSPF路由,看192.168.224.0和192.168.248.0网段中的路由有没有汇总,查看外部路由汇总为一条172.16.0.0>
   <2>show ip ospf  neighbor  <在R1和R2上查看区域0中的DR>