实验内容及拓扑图如下:
先进行子网划分如下:
192.168.1.0/24总地址
192.168.1.0 0000000/25——192.68.1.0/25 左区域
192.168.1.0 00 00000/27——192.168.1.0/27 骨干区域网段
192.168.1.0 01 00000/27——192.168.1.32/27 AR1环回
192.168.1.0 10 00000/27——192.168.1.64/27 AR2环回
192.168.1.0 11 00000/27——192.168.1.96/27 AR3环回192.168.1.1 0000000/25——192.168.1.128/25 右区域
192.168.1.1 0 000000/26——192.168.1.128/26骨干区域网段
192.168.1.1 1 000000/26——备用
配置网关及环回地址
配置AR1 接口IP,环回地址
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ip address 192.168.1.1 27 //0/0/0IP地址
[r1-GigabitEthernet0/0/0]q
[r1]interface loopback 0
[r1-LoopBack0]ip address 192.168.1.33 27 //环回地址
[r1-LoopBack0]q
[r1]display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.1.1/27 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 192.168.1.33/27 up up(s)
NULL0 unassigned up up(s)
配置AR2 接口IP地址,环回地址
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ip address 192.168.1.2 27
[r2-GigabitEthernet0/0/0]q
[r2]interface loopback 0
[r2-LoopBack0]ip address 192.168.1.65 27
[r2-LoopBack0]q
[r2]display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.1.2/27 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 192.168.1.65/27 up up(s)
NULL0 unassigned up up(s)
配置AR3 接口IP地址,环回地址
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ip address 192.168.1.3 27
[r3-GigabitEthernet0/0/0]q
[r3]interface GigabitEthernet 0/0/1
[r3-GigabitEthernet0/0/1]ip address 192.168.1.129 26
[r3-GigabitEthernet0/0/1]q
[r3]interface loopback 0
[r3-LoopBack0]ip address 192.168.1.97 27
[r3-LoopBack0]q
[r3]display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.1.3/27 up up
GigabitEthernet0/0/1 192.168.1.129/26 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 192.168.1.97/27 up up(s)
NULL0 unassigned up up(s)
配置AR4 接口IP地址,环回地址
[r4]interface GigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ip address 192.168.1.130 26
[r4-GigabitEthernet0/0/0]q
[r4]interface loopback 0
[r4-LoopBack0]ip address 4.4.4.4 24
[r4-LoopBack0]q
[r4]display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 192.168.1.130/26 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 4.4.4.4/24 up up(s)
NULL0 unassigned up up(s)
配置AR4的缺省路由
实现AR4环回不宣告也能ping通
[r4]ospf
[r4-ospf-1]default-r
[r4-ospf-1]default-route-advertise always
将AR1和AR2的优先级设置为0
目的:不参加选举,让AR3作为DR
AR1
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospf dr-priority 0
AR2
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ospf dr-priority 0
启动OSPF——配置RID启动ospf、创建区域、宣告
AR1
[r1]ospf 1 router-id 192.168.1.33
[r1-ospf-1]area 0
[r1-ospf-1-area-0.0.0.0]network 192.168.1.1 0.0.0.0
[r1-ospf-1-area-0.0.0.0]network 192.168.1.33 0.0.0.0
AR2
[r2]ospf 1 router-id 192.168.1.65
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 192.168.1.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 192.168.1.65 0.0.0.0
AR3
[r3]ospf 1 router-id 192.168.1.97
[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 1
[r3-ospf-1-area-0.0.0.1]network 192.168.1.129 0.0.0.0
AR4
[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
设置手工认证
两边的keyid必须一样
AR1
[r1]interface GigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 9999
AR2
[r2]interface GigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 9999
AR3
[r3]interface GigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 9999
[r3]interface GigabitEthernet 0/0/1
[r3-GigabitEthernet0/0/1]ospf authentication-mode md5 1 cipher 9999
AR4
[r4]interface GigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ospf authentication-mode md5 1 cipher 9999
手工汇总
实现减少路由条目
将area0的环回192.168.1.32/27,192.168.1.64/27,192.168.1.95/27
汇总为192.168.1.0/24
[r3]ospf
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]abr-summary 192.168.1.0 255.255.255.0
配置空接口
[r3]ip route-static 192.168.1.128 25 NULL 0
[r3]ip route-static 192.168.1.0 25 NULL 0
测试
[r1]ping 192.168.1.130
PING 192.168.1.130: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.130: bytes=56 Sequence=1 ttl=254 time=40 ms
Reply from 192.168.1.130: bytes=56 Sequence=2 ttl=254 time=40 ms
Reply from 192.168.1.130: bytes=56 Sequence=3 ttl=254 time=60 ms
--- 192.168.1.130 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/46/60 ms
[r1]ping 4.4.4.4
PING 4.4.4.4: 56 data bytes, press CTRL_C to break
Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=254 time=50 ms
Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=254 time=60 ms
Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=254 time=60 ms
Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=254 time=40 ms
--- 4.4.4.4 ping statistics ---
4 packet(s) transmitted
4 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/52/60 ms
[r1]ping 192.168.1.65
PING 192.168.1.65: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.65: bytes=56 Sequence=1 ttl=255 time=60 ms
Reply from 192.168.1.65: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 192.168.1.65: bytes=56 Sequence=3 ttl=255 time=60 ms
--- 192.168.1.65 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/56/60 ms
[r2]ping 192.168.1.130
PING 192.168.1.130: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.130: bytes=56 Sequence=1 ttl=254 time=50 ms
Reply from 192.168.1.130: bytes=56 Sequence=2 ttl=254 time=50 ms
Reply from 192.168.1.130: bytes=56 Sequence=3 ttl=254 time=50 ms
--- 192.168.1.130 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/50/50 ms
[r2]ping 192.168.1.97
PING 192.168.1.97: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.97: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 192.168.1.97: bytes=56 Sequence=2 ttl=255 time=50 ms
Reply from 192.168.1.97: bytes=56 Sequence=3 ttl=255 time=80 ms
Reply from 192.168.1.97: bytes=56 Sequence=4 ttl=255 time=50 ms
Reply from 192.168.1.97: bytes=56 Sequence=5 ttl=255 time=50 ms
--- 192.168.1.97 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/56/80 ms
[r2]ping 4.4.4.4
PING 4.4.4.4: 56 data bytes, press CTRL_C to break
Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=254 time=40 ms
Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=254 time=50 ms
--- 4.4.4.4 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 30/40/50 ms
[r2]ping 192.168.1.33
PING 192.168.1.33: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.33: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 192.168.1.33: bytes=56 Sequence=2 ttl=255 time=70 ms
Reply from 192.168.1.33: bytes=56 Sequence=3 ttl=255 time=40 ms
Reply from 192.168.1.33: bytes=56 Sequence=4 ttl=255 time=50 ms
--- 192.168.1.33 ping statistics ---
4 packet(s) transmitted
4 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/52/70 m
[r3]ping 192.168.1.1
PING 192.168.1.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.1: bytes=56 Sequence=1 ttl=255 time=50 ms
Reply from 192.168.1.1: bytes=56 Sequence=2 ttl=255 time=40 ms
Reply from 192.168.1.1: bytes=56 Sequence=3 ttl=255 time=50 ms
--- 192.168.1.1 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/46/50 ms
[r3]ping 4.4.4.4
PING 4.4.4.4: 56 data bytes, press CTRL_C to break
Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=255 time=20 ms
--- 4.4.4.4 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/23/30 ms
[r3]ping 192.168.1.130
PING 192.168.1.130: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.130: bytes=56 Sequence=1 ttl=255 time=20 ms
Reply from 192.168.1.130: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.1.130: bytes=56 Sequence=3 ttl=255 time=20 ms
--- 192.168.1.130 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/20/20 ms
[r3]ping 192.168.1.65
PING 192.168.1.65: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.65: bytes=56 Sequence=1 ttl=255 time=40 ms
Reply from 192.168.1.65: bytes=56 Sequence=2 ttl=255 time=70 ms
Reply from 192.168.1.65: bytes=56 Sequence=3 ttl=255 time=50 ms
--- 192.168.1.65 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/53/70 ms
[r4]ping 192.168.1.1
PING 192.168.1.1: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.1: bytes=56 Sequence=1 ttl=254 time=40 ms
Reply from 192.168.1.1: bytes=56 Sequence=2 ttl=254 time=50 ms
Reply from 192.168.1.1: bytes=56 Sequence=3 ttl=254 time=60 ms
--- 192.168.1.1 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/50/60 ms
[r4]ping 192.168.1.65
PING 192.168.1.65: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.65: bytes=56 Sequence=1 ttl=254 time=50 ms
Reply from 192.168.1.65: bytes=56 Sequence=2 ttl=254 time=50 ms
Reply from 192.168.1.65: bytes=56 Sequence=3 ttl=254 time=60 ms
Reply from 192.168.1.65: bytes=56 Sequence=4 ttl=254 time=60 ms
--- 192.168.1.65 ping statistics ---
4 packet(s) transmitted
4 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/55/60 ms
[r4]ping 192.168.1.3
PING 192.168.1.3: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.3: bytes=56 Sequence=1 ttl=255 time=30 ms
Reply from 192.168.1.3: bytes=56 Sequence=2 ttl=255 time=20 ms
Reply from 192.168.1.3: bytes=56 Sequence=3 ttl=255 time=20 ms
--- 192.168.1.3 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/23/30 ms
[r4]ping 192.168.1.33
PING 192.168.1.33: 56 data bytes, press CTRL_C to break
Reply from 192.168.1.33: bytes=56 Sequence=1 ttl=254 time=60 ms
Reply from 192.168.1.33: bytes=56 Sequence=2 ttl=254 time=60 ms
Reply from 192.168.1.33: bytes=56 Sequence=3 ttl=254 time=50 ms
--- 192.168.1.33 ping statistics ---
3 packet(s) transmitted
3 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/56/60 ms