1.分配IP地址
因为有两个区域0和1,所以先将母网段192.168.1.0/24划分成192.168.1.0/25和192.168.1.128/25分别分配给区域0和区域1;区域0中再分成192.168.1.0/27 1.32/27 1.64/27 1.96/27四个网段分别给骨干和r1 r2 r3环回。
2.配置IP地址
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 192.168.1.1 27
[r1]interface LoopBack 0
[r1-LoopBack0]ip address 192.168.1.33 27
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip address 192.168.1.2 27
[r2]interface LoopBack 0
[r2-LoopBack0]ip address 192.168.1.65 27
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ip address 192.168.1.3 27
[r3-GigabitEthernet0/0/0]int l0
[r3-LoopBack0]ip address 192.168.1.97 27
[r3]interface GigabitEthernet 0/0/1
[r3-GigabitEthernet0/0/1]ip address 192.168.1.129 25
[r4]interface GigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ip address 192.168.1.130 25
[r4]interface LoopBack 0
[r4-LoopBack0]ip address 4.4.4.1 24
3.配置OSPF
3.1区域划分和ospf宣告
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 192.168.1.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 192.168.1.97 0.0.0.0
[r3-ospf-1-area-0.0.0.0]area 1
[r3-ospf-1-area-0.0.0.1]network 192.168.1.129 0.0.0.0
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 1
[r4-ospf-1-area-0.0.0.1]network 192.168.1.130 0.0.0.0
3.2设置DR设备
因为要设置r3为DR设备,所以将竞选的r1和r2的优先级设置为0,代表放弃竞选
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospf dr-priority 0
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ospf dr-priority 0
3.3汇总,减少路由条目
[r3]ospf 1
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]abr-summary 192.168.1.0 255.255.255.128
3.4 r4设置缺省路由,全网可达
[r4]ospf 1
[r4-ospf-1]default-route-advertise always
3.5设置空接口防止环路
[r3]ip route-static 192.168.1.0 25 NULL 0
3.6手工认证保证安全
[r1-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456
[r2-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456
[r3-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456
[r3-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 123456
[r4-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 123456