拓扑图:
要实现全网互通
配置文件:
R1:
#
sysname r1
#
interface GigabitEthernet0/0/0
ip address 10.1.0.1 255.255.0.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
ospf 1 router-id 1.1.1.1
area 0.0.0.3
network 1.1.1.1 0.0.0.0
network 10.1.0.0 0.0.255.255
R2:
#
sysname r2
#
interface GigabitEthernet0/0/0
ip address 10.1.0.2 255.255.0.0
#
interface GigabitEthernet0/0/1
ip address 10.0.0.2 255.255.0.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
ospf 1 router-id 2.2.2.2
area 0.0.0.1
network 10.0.0.0 0.0.255.255
vlink-peer 3.3.3.3
area 0.0.0.3
network 2.2.2.2 0.0.0.0
network 10.1.0.0 0.0.255.255
R3:
#
sysname r3
#
interface GigabitEthernet0/0/0
ip address 10.0.0.3 255.255.0.0
#
interface GigabitEthernet0/0/1
ip address 10.56.0.3 255.255.0.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
interface LoopBack1
ip address 100.100.100.100 255.255.255.255
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 10.56.0.0 0.0.255.255
area 0.0.0.1
network 3.3.3.3 0.0.0.0
network 10.0.0.0 0.0.255.255
network 100.100.100.100 0.0.0.0
vlink-peer 2.2.2.2
R4:
#
sysname r4
#
interface GigabitEthernet0/0/0
ip address 10.56.0.4 255.255.0.0
#
interface GigabitEthernet0/0/1
ip address 10.2.0.4 255.255.0.0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 10.56.0.0 0.0.255.255
area 0.0.0.2
network 10.2.0.0 0.0.255.255
R5:
#
sysname r5
#
interface GigabitEthernet0/0/0
ip address 10.2.0.5 255.255.0.0
#
interface GigabitEthernet0/0/1
ip address 172.16.24.5 255.255.255.0
#
ospf 1 router-id 5.5.5.5
import-route rip 1 cost 100
area 0.0.0.2
network 5.5.5.5 0.0.0.0
network 10.2.0.0 0.0.255.255
#
rip 1
undo summary
default-route originate
version 2
network 5.0.0.0
network 172.16.0.0
import-route ospf 1 cost 0
R6:
#
sysname r6
#
interface GigabitEthernet0/0/0
ip address 172.16.24.6 255.255.255.0
interface LoopBack0
ip address 6.6.6.6 255.255.255.255
#
ospf 1 router-id 6.6.6.6
import-route rip 1 cost 100
#
rip 1
undo summary
version 2
network 6.0.0.0
network 172.16.0.0
import-route ospf 1 cost 0
注意:在R2和R3之间做虚链路,在R5和R6之间做重分发
每个路由器可以学习到的IP地址如下:
我们把area3做成完全末梢区域,配置文件如下:
R1:
[r1]ospf 1
[r1-ospf-1]area 3
[r1-ospf-1-area-0.0.0.3]stub
R2:
[r2]ospf 1
[r2-ospf-1]area 3
[r2-ospf-1-area-0.0.0.3]stub no-summary
R1的路由表变成如下图所示:
把area 2 做成完全次末节,配置文件如下:
R4:
[r4]ospf 1
[r4-ospf-1]area 2
[r4-ospf-1-area-0.0.0.2]nssa no-summary
R5:
[r5]ospf 1
[r5-ospf-1]area 2
[r5-ospf-1-area-0.0.0.2]nssa
在R5上查看路由表,变成如下图所示: