拓扑图:
![多区域OSPF基本配置_第1张图片](http://img.e-com-net.com/image/info3/f273f4598dca4e448db40cdf27d745d7.jpg)
R1:
intface lo0
ip add 1.1.1.1 255.255.255.0
ip ospf network point-to-point
intface s0/0/0
ip add 192.168.12.1 255.255.255.0
no shut
router ospf 1
router-id 1.1.1.1
network 1.1.1.0 0.0.0.255 area 1
network 192.168.12.0 0.0.0.255 area 1
R2:
intface lo0
ip add 2.2.2.2 255.255.255.0
ip ospf network point-to-point
int s0/0/0
ip add 192.168.12.2 255.255.255.0
no shut
int s0/0/1
ip add 192.168.23.2 255.255.255.0
no shut
router ospf 1
router-id 2.2.2.2
network 192.168.12.0 0.0.0.255 area 1
network 192.168.23.0 0.0.0.255 area 0
network 2.2.2.0 0.0.0.255 area 0
R3:
intface lo0
ip add 3.3.3.3 255.255.255.0
ip ospf network point-to-point
int s0/0/1
ip add 192.168.23.3 255.255.255.0
no shut
int s0/0/0
ip add 192.168.34.3 255.255.255.0
no shut
router ospf 1
router-id 3.3.3.3
network 192.168.23.0 0.0.0.255 area 0
network 3.3.3.0 0.0.0.255 area 0
network 192.168.34.0 0.0.0.255 area 2
R4:
intface lo0
ip add 4.4.4.4 255.255.255.0
ip ospf network point-to-point
int s0/0/0
ip add 192.168.34.4 255.255.255.0
no shut
router ospf 1
router-id 4.4.4.4
network 192.168.34.0 0.0.0.255 area 2
redistribute connected subnets //将直连路由重发布到OSPF 中,一般将其他路由协议重发布到OSPF中都要加subnets
OSPF外部路由分为两种:
1.类型1(E1)-----外部路径成本+数据包在OSPF网络所经过的各链路成本;
2.类型2(E2)-----外部路径成本,即ASBR(自治系统边界路由器)上的默认设置,默认为20,可以修改,例:R4 redistribute connected subnets metric 50 metric-type 1