OSPF综合实验和学习笔记

1.配置IP

R1:
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 172.16.33.1 24
Apr 14 2024 21:12:39-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R1-GigabitEthernet0/0/0]
[R1]interface LoopBack 0
[R1-LoopBack0]ip address 172.16.34.1 24

R2:
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 172.16.33.2 24
Apr 14 2024 21:14:08-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R2-GigabitEthernet0/0/0]q
[R2]interface LoopBack 0
[R2-LoopBack0]ip address 172.16.35.2 24

R3:
[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ip address 172.16.33.3 24
Apr 14 2024 21:16:08-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R3-GigabitEthernet0/0/0]q
[R3]interface LoopBack 0
[R3-LoopBack0]ip address 172.16.36.3 24
[R3]interface Serial 4/0/0
[R3-Serial4/0/0]ip address 34.0.0.3 24

R4:
[R4]interface Serial 4/0/0
[R4-Serial4/0/0]ip address 34.0.0.4 24
[R4-Serial4/0/0]
Apr 14 2024 21:19:14-08:00 R4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PPP
 IPCP on the interface Serial4/0/0 has entered the UP state. 
[R4-Serial4/0/0]q
[R4]interface Serial 4/0/1
[R4-Serial4/0/1]ip address 45.0.0.4 24
[R4-Serial4/0/1]q
[R4]interface Serial 3/0/0
[R4-Serial3/0/0]ip address 46.0.0.4 24
[R4-Serial3/0/0]q
[R4]interface GigabitEthernet 0/0/0
[R4-GigabitEthernet0/0/0]ip address 47.0.0.4 24
[R4-GigabitEthernet0/0/0]
Apr 14 2024 21:21:09-08:00 R4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R4-GigabitEthernet0/0/0]q
[R4]interface l0
[R4-LoopBack0]ip address 172.16.2.4 24

R5:
[Huawei]interface Serial 4/0/0
[Huawei-Serial4/0/0]ip address 45.0.0.5 24
[Huawei-Serial4/0/0]
Apr 14 2024 21:23:08-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocol
 PPP IPCP on the interface Serial4/0/0 has entered the UP state. 
[Huawei-Serial4/0/0]q
[Huawei]int l0
[Huawei-LoopBack0]ip address 172.16.3.5 24
[Huawei-LoopBack0]q

R6:
[R6]interface Serial 4/0/0
[R6-Serial4/0/0]ip address 46.0.0.6 24
[R6-Serial4/0/0]
Apr 14 2024 21:24:58-08:00 R6 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol PPP
 IPCP on the interface Serial4/0/0 has entered the UP state. 
[R6-Serial4/0/0]q
[R6]interface GigabitEthernet 0/0/0
[R6-GigabitEthernet0/0/0]ip address 172.16.65.1 30
Apr 14 2024 21:25:20-08:00 R6 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R6-GigabitEthernet0/0/0]q
[R6]interface l0
[R6-LoopBack0]ip address 172.16.4.6 24 

R7:
[R7]interface GigabitEthernet 0/0/0
[R7-GigabitEthernet0/0/0]ip address 47.0.0.7 24
Apr 14 2024 21:27:15-08:00 R7 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R7-GigabitEthernet0/0/0]q
[R7]interface GigabitEthernet 0/0/1
[R7-GigabitEthernet0/0/1]ip address 172.16.97.1 30
Apr 14 2024 21:27:35-08:00 R7 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 
[R7-GigabitEthernet0/0/1]q
[R7]int l0
[R7-LoopBack0]ip address 172.16.5.7 24

R8:
[R8]interface GigabitEthernet 0/0/0
[R8-GigabitEthernet0/0/0]ip address 172.16.97.2 30
Apr 14 2024 21:31:09-08:00 R8 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R8-GigabitEthernet0/0/0]q
[R8]interface GigabitEthernet 0/0/1
[R8-GigabitEthernet0/0/1]ip address 172.16.97.5 30
Apr 14 2024 21:31:22-08:00 R8 %%01IFNET/4/LINK_STATE(l)[3]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 
[R8-GigabitEthernet0/0/1]q
[R8]interface l0
[R8-LoopBack0]ip address 172.16.98.8 24
[R8]display ip interface brief

R9:
[R9]interface GigabitEthernet 0/0/0
[R9-GigabitEthernet0/0/0] ip address 172.16.97.6 30
Apr 14 2024 21:33:09-08:00 R9 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R9-GigabitEthernet0/0/0]q
[R9]interface GigabitEthernet 0/0/1
[R9-GigabitEthernet0/0/1]ip address 172.16.129.1 30
Apr 14 2024 21:33:22-08:00 R9 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 
[R9-GigabitEthernet0/0/1]q
[R9]interface LoopBack 0
[R9-LoopBack0]ip address 172.16.130.9 24

R10:
[R10]interface GigabitEthernet 0/0/0
[R10-GigabitEthernet0/0/0]ip address 172.16.129.2 30
Apr 14 2024 21:36:14-08:00 R10 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
 on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R10-GigabitEthernet0/0/0]q
[R10]int l0
[R10-LoopBack0]ip address 172.16.131.10 24
[R10-LoopBack0]q
[R10]dis ip in b

R11:
[R11]interface GigabitEthernet 0/0/0
[R11-GigabitEthernet0/0/0]ip address 172.16.65.2 30
Apr 14 2024 21:37:37-08:00 R11 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
 on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R11-GigabitEthernet0/0/0]q
[R11]interface GigabitEthernet 0/0/1
[R11-GigabitEthernet0/0/1]ip address 172.16.65.5 30
Apr 14 2024 21:37:51-08:00 R11 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
 on the interface GigabitEthernet0/0/1 has entered the UP state. 
[R11-GigabitEthernet0/0/1]q
[R11]int l0
[R11-LoopBack0]ip address 172.16.66.11 24
[R11-LoopBack0]q

R12:
[R12]interface GigabitEthernet 0/0/0
[R12-GigabitEthernet0/0/0]ip address 172.16.65.6 30
Apr 14 2024 21:39:13-08:00 R12 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
 on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R12-GigabitEthernet0/0/0]q
[R12]int l0
[R12-LoopBack0]ip address 172.16.160.12 24
[R12-LoopBack0]q
[R12]int l1
[R12-LoopBack1]ip address 172.16.161.12 24
[R12-LoopBack1]q

2.宣告网段

R1:
[R1]ospf 1 router-id 1.1.1.1
[R1-ospf-1]a 1
[R1-ospf-1-area-0.0.0.1]net 172.16.33.0 0.0.0.255
[R1-ospf-1-area-0.0.0.1]net 172.16.34.0 0.0.0.255

R2:
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]a 1
[R2-ospf-1-area-0.0.0.1]network 172.16.33.0 0.0.0.255
[R2-ospf-1-area-0.0.0.1]network 172.16.35.0 0.0.0.255

R3:
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]a 1
[R3-ospf-1-area-0.0.0.1]network 172.16.33.0 0.0.0.255
[R3-ospf-1-area-0.0.0.1]network 172.16.36.0 0.0.0.255

R5:
[R5]ospf 1 router-id 5.5.5.5
[R5-ospf-1]a 0
[R5-ospf-1-area-0.0.0.0]network 172.16.3.0 0.0.0.255

R6:
[R6]ospf 1 router-id 6.6.6.6
[R6-ospf-1]a 0
[R6-ospf-1-area-0.0.0.0]network 172.16.4.0 0.0.0.255
[R6-ospf-1-area-0.0.0.0]q
[R6-ospf-1]a 2
[R6-ospf-1-area-0.0.0.2]network 172.16.65.1 0.0.0.0

R7:
[R7]ospf 1 router-id 7.7.7.7
[R7-ospf-1]a 0
[R7-ospf-1-area-0.0.0.0]network 172.16.5.0 0.0.0.255
[R7-ospf-1-area-0.0.0.0]q
[R7-ospf-1]a 3
[R7-ospf-1-area-0.0.0.3]network 172.16.97.1 0.0.0.0

R8:
[R8]ospf 1 router-id 8.8.8.8
[R8-ospf-1]a 3
[R8-ospf-1-area-0.0.0.3]network 172.16.97.2 0.0.0.0
[R8-ospf-1-area-0.0.0.3]network 172.16.97.5 0.0.0.0
[R8-ospf-1-area-0.0.0.3]network 172.16.98.0 0.0.0.255

R9:
[R9]ospf 1 router-id 9.9.9.9
[R9-ospf-1]a 3
[R9-ospf-1-area-0.0.0.3]net 172.16.97.6 0.0.0.0
[R9]ospf 2 router-id 9.9.9.9
[R9-ospf-2]a 4
[R9-ospf-2-area-0.0.0.4]net 172.16.129.1 0.0.0.0
[R9-ospf-2-area-0.0.0.4]net 172.16.130.0 0.0.0.255

[R9]ospf 1
[R9-ospf-1]import-route  ospf 2
[R9-ospf-1]q
[R9]ospf 2
[R9-ospf-2]import-route ospf 1

R10:
[R10]ospf 1 router-id 10.10.10.10
[R10-ospf-1]a 4
[R10-ospf-1-area-0.0.0.4]net 172.16.129.2 0.0.0.0
[R10-ospf-1-area-0.0.0.4]net 172.16.131.0 0.0.0.255

R11:
[R10]ospf 2 router-id 10.10.10.10
[R10-ospf-2]a 4
[R10-ospf-2-area-0.0.0.4]net 172.16.131.0 0.0.0.255
[R10-ospf-2-area-0.0.0.4]net 172.16.129.2 0.0.0.0

R12:
[R12]rip 1
[R12-rip-1]v 2
[R12-rip-1]undo summary 
[R12-rip-1]ne 172.16.0.0
[R12-rip-1]q
[R12]ospf 1
[R12-ospf-1]import-route rip


查看配置:
[R10]dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 15       Routes : 15       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
     172.16.5.7/32  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
    172.16.97.0/30  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
    172.16.97.4/30  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
    172.16.98.8/32  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
   172.16.129.0/30  Direct  0    0           D   172.16.129.2    GigabitEthernet
0/0/0
   172.16.129.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
   172.16.129.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
   172.16.130.9/32  OSPF    10   1           D   172.16.129.1    GigabitEthernet
0/0/0
   172.16.131.0/24  Direct  0    0           D   172.16.131.10   LoopBack0
  172.16.131.10/32  Direct  0    0           D   127.0.0.1       LoopBack0
 172.16.131.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

[R12]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    172.16.65.4/30  Direct  0    0           D   172.16.65.6     GigabitEthernet
0/0/0
    172.16.65.6/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
    172.16.65.7/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
   172.16.160.0/24  Direct  0    0           D   172.16.160.12   LoopBack0
  172.16.160.12/32  Direct  0    0           D   127.0.0.1       LoopBack0
 172.16.160.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
   172.16.161.0/24  Direct  0    0           D   172.16.161.12   LoopBack1
  172.16.161.12/32  Direct  0    0           D   127.0.0.1       LoopBack1
 172.16.161.255/32  Direct  0    0           D   127.0.0.1       LoopBack1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0


[R3]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 16       Routes : 16       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       34.0.0.0/24  Direct  0    0           D   34.0.0.3        Serial4/0/0
       34.0.0.3/32  Direct  0    0           D   127.0.0.1       Serial4/0/0
       34.0.0.4/32  Direct  0    0           D   34.0.0.4        Serial4/0/0
     34.0.0.255/32  Direct  0    0           D   127.0.0.1       Serial4/0/0
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
    172.16.33.0/24  Direct  0    0           D   172.16.33.3     GigabitEthernet
0/0/0
    172.16.33.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
  172.16.33.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
    172.16.34.1/32  OSPF    10   1           D   172.16.33.1     GigabitEthernet
0/0/0
    172.16.35.2/32  OSPF    10   1           D   172.16.33.2     GigabitEthernet
0/0/0
    172.16.36.0/24  Direct  0    0           D   172.16.36.3     LoopBack0
    172.16.36.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
  172.16.36.255/32  Direct  0    0           D   127.0.0.1       LoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

3.此时私网通,开始配置公网通

(私网通验证)

[R10]ping 172.16.97.1
  PING 172.16.97.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.97.1: bytes=56 Sequence=1 ttl=253 time=50 ms
    Reply from 172.16.97.1: bytes=56 Sequence=2 ttl=253 time=30 ms
    Reply from 172.16.97.1: bytes=56 Sequence=3 ttl=253 time=30 ms
    Reply from 172.16.97.1: bytes=56 Sequence=4 ttl=253 time=30 ms
    Reply from 172.16.97.1: bytes=56 Sequence=5 ttl=253 time=40 ms

  --- 172.16.97.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/36/50 ms

公网通配置

1.配置静态缺省
[R3]ip route-static 0.0.0.0 0 34.0.0.4
[R5]ip route-static 0.0.0.0 0 45.0.0.4
[R6]ip route-static 0.0.0.0 0 46.0.0.4
[R7]ip route-static 0.0.0.0 0 47.0.0.4

公网通

验证

[R7]ping -a 47.0.0.7 34.0.0.3
  PING 34.0.0.3: 56  data bytes, press CTRL_C to break
    Reply from 34.0.0.3: bytes=56 Sequence=1 ttl=254 time=60 ms
    Reply from 34.0.0.3: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 34.0.0.3: bytes=56 Sequence=3 ttl=254 time=40 ms
    Reply from 34.0.0.3: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 34.0.0.3: bytes=56 Sequence=5 ttl=254 time=20 ms

  --- 34.0.0.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/34/60 ms

[R7]ping -a 47.0.0.7 45.0.0.5
  PING 45.0.0.5: 56  data bytes, press CTRL_C to break
    Reply from 45.0.0.5: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 45.0.0.5: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 45.0.0.5: bytes=56 Sequence=3 ttl=254 time=20 ms
    Reply from 45.0.0.5: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 45.0.0.5: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 45.0.0.5 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/26/30 ms

[R7]ping -a 47.0.0.7 46.0.0.6
  PING 46.0.0.6: 56  data bytes, press CTRL_C to break
    Reply from 46.0.0.6: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 46.0.0.6: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 46.0.0.6: bytes=56 Sequence=3 ttl=254 time=20 ms
    Reply from 46.0.0.6: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 46.0.0.6: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 46.0.0.6 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/26/30 ms

4.搭建隧道

中心站点:
[R3]interface Tunnel 0/0/0
[R3-Tunnel0/0/0]ip address 172.16.6.3 24
[R3-Tunnel0/0/0]tunnel-protocol gre p2mp
[R3-Tunnel0/0/0]source Serial 4/0/0
Apr 16 2024 14:33:40-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/0 has entered the UP state. 
[R3-Tunnel0/0/0]nhrp network-id 100
[R3-Tunnel0/0/0]nhrp entry multicast dynamic 

分支站点:
[R5]interface Tunnel 0/0/0
[R5-Tunnel0/0/0]ip address 172.16.6.5 24
[R5-Tunnel0/0/0]tunnel-protocol gre p2mp
[R5-Tunnel0/0/0]source Serial 4/0/0
Apr 16 2024 14:35:46-08:00 R5 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/0 has entered the UP state. 
[R5-Tunnel0/0/0]nhrp network-id 100
[R5-Tunnel0/0/0]nhrp entry 172.16.6.3 34.0.0.3 register 

[R6]interface Tunnel 0/0/0
[R6-Tunnel0/0/0]ip address 172.16.6.6 24
[R6-Tunnel0/0/0]tunnel-protocol gre p2mp
[R6-Tunnel0/0/0]source Serial 4/0/0
Apr 16 2024 14:38:13-08:00 R6 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/0 has entered the UP state.
[R6-Tunnel0/0/0]nhrp network-id 100
[R6-Tunnel0/0/0]nhrp entry 172.16.6.3 34.0.0.3 register

[R7]interface Tunnel 0/0/0
[R7-Tunnel0/0/0]ip address 172.16.6.7 24
[R7-Tunnel0/0/0]tunnel-protocol gre p2mp	
[R7-Tunnel0/0/0]source GigabitEthernet 0/0/0
Apr 16 2024 14:39:30-08:00 R7 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface Tunnel0/0/0 has entered the UP state. 
[R7-Tunnel0/0/0]nhrp network-id 100
[R7-Tunnel0/0/0]nhrp entry 172.16.6.3 34.0.0.3 register

查看中心站点注册信息是否收到:

[R3]display nhrp peer all 
------------------------------------------------------------------------------- 
Protocol-addr   Mask  NBMA-addr       NextHop-addr    Type         Flag         
------------------------------------------------------------------------------- 
172.16.6.5      32    45.0.0.5        172.16.6.5      dynamic      route tunnel 
------------------------------------------------------------------------------- 
Tunnel interface: Tunnel0/0/0
Created time    : 00:05:24
Expire time     : 01:54:36
------------------------------------------------------------------------------- 
Protocol-addr   Mask  NBMA-addr       NextHop-addr    Type         Flag         
------------------------------------------------------------------------------- 
172.16.6.6      32    46.0.0.6        172.16.6.6      dynamic      route tunnel 
------------------------------------------------------------------------------- 
Tunnel interface: Tunnel0/0/0
Created time    : 00:03:50
Expire time     : 01:56:10
------------------------------------------------------------------------------- 
Protocol-addr   Mask  NBMA-addr       NextHop-addr    Type         Flag         
------------------------------------------------------------------------------- 
172.16.6.7      32    47.0.0.7        172.16.6.7      dynamic      route tunnel 
------------------------------------------------------------------------------- 
Tunnel interface: Tunnel0/0/0
Created time    : 00:02:09
Expire time     : 01:57:51

Number of nhrp peers: 3

5.隧道宣告

[R3]ospf 1
[R3-ospf-1]a 0
[R3-ospf-1-area-0.0.0.0]net 172.16.6.0 0.0.0.255

[R5-ospf-1]a 0
[R5-ospf-1-area-0.0.0.0]net 172.16.6.0 0.0.0.255

[R6-ospf-1]a 0
[R6-ospf-1-area-0.0.0.0]net 172.16.6.0 0.0.0.255

[R7-ospf-1]a 0
[R7-ospf-1-area-0.0.0.0]net 172.16.6.0 0.0.0.255

6.更改隧道接口类型:

[R3]interface Tunnel 0/0/0
[R3-Tunnel0/0/0]ospf network-type broadcast 

[R5]interface Tunnel 0/0/0
[R5-Tunnel0/0/0]ospf network-type broadcast 

[R6]interface Tunnel 0/0/0
[R6-Tunnel0/0/0]ospf network-type broadcast 


[R7]interface Tunnel 0/0/0
[R7-Tunnel0/0/0]ospf network-type broadcast 

7.更改隧道选举

[R5-Tunnel0/0/0]ospf dr-priority 0
[R6-Tunnel0/0/0]ospf dr-priority 0
[R7-Tunnel0/0/0]ospf dr-priority 0

查看邻居表:

[R3]display ospf peer brief 

	 OSPF Process 1 with Router ID 3.3.3.3
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          Tunnel0/0/0                      5.5.5.5          Full        
 0.0.0.0          Tunnel0/0/0                      6.6.6.6          Full        
 0.0.0.0          Tunnel0/0/0                      7.7.7.7          Full        
 0.0.0.1          GigabitEthernet0/0/0             1.1.1.1          Full        
 0.0.0.1          GigabitEthernet0/0/0             2.2.2.2          Full        
 ----------------------------------------------------------------------------


[R6]display ospf peer brief 

	 OSPF Process 1 with Router ID 6.6.6.6
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          Tunnel0/0/0                      3.3.3.3          Full        
 0.0.0.2          GigabitEthernet0/0/0             11.11.11.11      Full        
 ----------------------------------------------------------------------------

[R11]display ospf peer brief 

	 OSPF Process 1 with Router ID 11.11.11.11
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.2          GigabitEthernet0/0/0             6.6.6.6          Full        
 ----------------------------------------------------------------------------

[R7]display ospf peer brief 

	 OSPF Process 1 with Router ID 7.7.7.7
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          Tunnel0/0/0                      3.3.3.3          Full        
 0.0.0.3          GigabitEthernet0/0/1             8.8.8.8          Full        
 ----------------------------------------------------------------------------

8.让每个设备都可以访问R4的环回

[R3]acl 2000
[R3-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R3-acl-basic-2000]q
[R3]int Serial 4/0/0
[R3-Serial4/0/0]nat outbound 2000
[R3-Serial4/0/0]q


[R5]acl 2000
[R5-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R5-acl-basic-2000]q
[R5]int s 4/0/0
[R5-Serial4/0/0]nat outbound 2000

[R6]acl 2000
[R6-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R6-acl-basic-2000]q
[R6]int s 4/0/0
[R6-Serial4/0/0]nat outbound 2000

[R7]acl 2000
[R7-acl-basic-2000]rule permit source 172.16.0.0 0.0.255.255
[R7-acl-basic-2000]q
[R7]int g 0/0/0
[R7-GigabitEthernet0/0/0]nat outbound 2000

9.进行区域汇总

[R12]ospf 1
[R12-ospf-1]asbr-summary 172.16.160.0 255.255.224.0

[R9]ospf 1
[R9-ospf-1]asbr-summary 172.16.128.0 255.255.224.0

[R7-ospf-1]a 3
[R7-ospf-1-area-0.0.0.3]abr-summary 172.16.96.0 255.255.224.0

[R6]ospf 1
[R6-ospf-1]a 2
[R6-ospf-1-area-0.0.0.2]abr-summary 172.16.64.0 255.255.224.0

[R3]ospf 1
[R3-ospf-1]a 1
[R3-ospf-1-area-0.0.0.1]abr-summary 172.16.32.0 255.255.224.0


设置特殊区域
[R3-ospf-1-area-0.0.0.1]stub no-summary 
[R2-ospf-1-area-0.0.0.1]stub no-summary
[R1-ospf-1-area-0.0.0.1]stub no-summary 


[R6]ospf 1
[R6-ospf-1]a 2
[R6-ospf-1-area-0.0.0.2]nssa no-summary


[R11]ospf 1
[R11-ospf-1]a 2
[R11-ospf-1-area-0.0.0.2]nssa no-summary

[R12]ospf 1
[R12-ospf-1]a 2
[R12-ospf-1-area-0.0.0.2]nssa no-summary

[R7]ospf 1
[R7-ospf-1] a 3
[R7-ospf-1-area-0.0.0.3]nssa no-summary

[R8]ospf 1
[R8-ospf-1] a 3
[R8-ospf-1-area-0.0.0.3]nssa no-summary


[R9]ospf 1
[R9-ospf-1]a 3
[R9-ospf-1-area-0.0.0.3]nssa no-summary




验证查看配置

[R5]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 6        Routes : 6        

OSPF routing table status : <Active>
         Destinations : 6        Routes : 6

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

     172.16.4.6/32  OSPF    10   1562        D   172.16.6.6      Tunnel0/0/0
     172.16.5.7/32  OSPF    10   1562        D   172.16.6.7      Tunnel0/0/0
    172.16.32.0/19  OSPF    10   1563        D   172.16.6.3      Tunnel0/0/0
    172.16.64.0/19  OSPF    10   1564        D   172.16.6.6      Tunnel0/0/0
    172.16.96.0/19  OSPF    10   1564        D   172.16.6.7      Tunnel0/0/0
   172.16.128.0/19  O_ASE   150  2           D   172.16.6.7      Tunnel0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0


[R1]display ip routing-table protocol ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 3        Routes : 3        

OSPF routing table status : <Active>
         Destinations : 3        Routes : 3

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   2           D   172.16.33.3     GigabitEthernet
0/0/0
    172.16.35.2/32  OSPF    10   1           D   172.16.33.2     GigabitEthernet
0/0/0
    172.16.36.3/32  OSPF    10   1           D   172.16.33.3     GigabitEthernet
0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

10.给R10自动下发缺省

[R9]ospf 2
[R9-ospf-2]default-route-advertise

[R10]display ip routing-table protocol ospf 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 5        Routes : 5        

OSPF routing table status : <Active>
         Destinations : 5        Routes : 5

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
    172.16.97.0/30  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
    172.16.97.4/30  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
    172.16.98.8/32  O_ASE   150  1           D   172.16.129.1    GigabitEthernet
0/0/0
   172.16.130.9/32  OSPF    10   1           D   172.16.129.1    GigabitEthernet
0/0/0

OSPF routing table status : <Inactive>
         Destinations : 0        Routes : 0

11.加快收敛

[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ospf timer hello 5

[R3]interface GigabitEthernet 0/0/0
[R3-GigabitEthernet0/0/0]ospf timer hello 5

[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ospf timer hello 5

[R3]interface Serial 4/0/0
[R3-Serial4/0/0]ospf timer hello 5

[R4]interface Serial 4/0/0
[R4-Serial4/0/0]ospf timer hello 5
[R4-Serial4/0/0]interface Serial 4/0/1
[R4-Serial4/0/1]ospf timer hello 5
[R4-Serial4/0/1]interface Serial 3/0/0
[R4-Serial3/0/0]ospf timer hello 5
[R4-Serial3/0/0]interface g 0/0/0
[R4-GigabitEthernet0/0/0]ospf timer hello 5


[R5]interface Serial 4/0/0
[R5-Serial4/0/0]ospf timer hello 5

[R6]interface Serial 4/0/0
[R6-Serial4/0/0]ospf timer hello 5

[R7]interface GigabitEthernet 0/0/0
[R7-GigabitEthernet0/0/0]ospf timer hello 5

[R6]interface GigabitEthernet 0/0/0
[R6-GigabitEthernet0/0/0]ospf timer hello 5

[R11]interface GigabitEthernet 0/0/0
[R11-GigabitEthernet0/0/0]ospf timer hello 5
[R11-GigabitEthernet0/0/0]interface GigabitEthernet 0/0/1
[R11-GigabitEthernet0/0/1]ospf timer hello 5

[R12]interface GigabitEthernet 0/0/0
[R12-GigabitEthernet0/0/0]ospf timer hello 5

[R7-GigabitEthernet0/0/0]interface GigabitEthernet 0/0/1
[R7-GigabitEthernet0/0/1]ospf timer hello 5

[R8]interface GigabitEthernet 0/0/0
[R8-GigabitEthernet0/0/0]ospf timer hello 5
[R8-GigabitEthernet0/0/0]interface GigabitEthernet 0/0/1
[R8-GigabitEthernet0/0/1]ospf timer hello 5

[R9]interface GigabitEthernet 0/0/0
[R9-GigabitEthernet0/0/0]ospf timer hello 5
[R9-GigabitEthernet0/0/0]interface GigabitEthernet 0/0/1
[R9-GigabitEthernet0/0/1]ospf timer hello 5

[R10]interface GigabitEthernet 0/0/0
[R10-GigabitEthernet0/0/0]ospf timer hello 5

测试

[R1]ping 172.16.129.1
  PING 172.16.129.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.129.1: bytes=56 Sequence=1 ttl=252 time=90 ms
    Reply from 172.16.129.1: bytes=56 Sequence=2 ttl=252 time=60 ms
    Reply from 172.16.129.1: bytes=56 Sequence=3 ttl=252 time=70 ms
    Reply from 172.16.129.1: bytes=56 Sequence=4 ttl=252 time=60 ms
    Reply from 172.16.129.1: bytes=56 Sequence=5 ttl=252 time=80 ms

  --- 172.16.129.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 60/72/90 ms

12.进行区域认证

[R6]ospf 1
[R6-ospf-1]a 2
[R6-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 12345

[R11]ospf 1
[R11-ospf-1]a 2
[R11-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 12345

[R12]ospf 1
[R12-ospf-1]a 2
[R12-ospf-1-area-0.0.0.2]authentication-mode md5 1 cipher 12345

[R7]ospf 1
[R7-ospf-1]a 3
[R7-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 12345

[R8]ospf 1
[R8-ospf-1]a 3
[R8-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 12345

[R9]ospf 1
[R9-ospf-1]a 3
[R9-ospf-1-area-0.0.0.3]authentication-mode md5 1 cipher 12345

[R1]ospf 1
[R1-ospf-1]a 1
[R1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 12345

[R2]ospf 1
[R2-ospf-1]a 1
[R2-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 12345

[R3]ospf 1
[R3-ospf-1]a 1
[R3-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher 12345

测试

[R1]ping 172.16.97.1
  PING 172.16.97.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.97.1: bytes=56 Sequence=1 ttl=254 time=60 ms
    Reply from 172.16.97.1: bytes=56 Sequence=2 ttl=254 time=40 ms
    Reply from 172.16.97.1: bytes=56 Sequence=3 ttl=254 time=50 ms
    Reply from 172.16.97.1: bytes=56 Sequence=4 ttl=254 time=50 ms
    Reply from 172.16.97.1: bytes=56 Sequence=5 ttl=254 time=40 ms

  --- 172.16.97.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 40/48/60 ms

[R9]ping 172.16.97.1
  PING 172.16.97.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.97.1: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 172.16.97.1: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 172.16.97.1: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 172.16.97.1: bytes=56 Sequence=4 ttl=254 time=20 ms
    Reply from 172.16.97.1: bytes=56 Sequence=5 ttl=254 time=40 ms

  --- 172.16.97.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/30/40 ms

[R9]ping 172.16.34.1
  PING 172.16.34.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.34.1: bytes=56 Sequence=1 ttl=252 time=70 ms
    Reply from 172.16.34.1: bytes=56 Sequence=2 ttl=252 time=60 ms
    Reply from 172.16.34.1: bytes=56 Sequence=3 ttl=252 time=50 ms
    Reply from 172.16.34.1: bytes=56 Sequence=4 ttl=252 time=70 ms
    Reply from 172.16.34.1: bytes=56 Sequence=5 ttl=252 time=80 ms

  --- 172.16.34.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/66/80 ms

笔记

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
OSPF(开放最短路径优先)是一种用于路由的动态路由协议,它是根据路由器之间的链路状态来计算最短路径的。 在一个OSPF综合实验案例中,可以模拟一个复杂的网络拓扑,包括多个路由器和连接它们的链路。假设有5个路由器A、B、C、D和E,它们之间通过不同的链路相连。 首先,需要配置每个路由器上的OSPF进程,并为它们分配一个路由器ID。然后,在每个链路上配置正确的IP地址和子网掩码。接下来,通过在OSPF进程中启用不同的区域,将路由器分成不同的区域。 然后,需要配置每个路由器之间的OSPF邻居关系。这可以通过指定邻居的路由器ID和链路上的IP地址来完成。路由器之间的邻居关系建立后,它们将开始交换链路状态信息(LSA)。 每个路由器将根据接收到的LSA计算自己的链路状态数据库(LSDB)。然后,通过运行Dijkstra算法,每个路由器将计算出到达其他路由器的最短路径。最后,每个路由器将根据最短路径选择相应的接口进行路由。 在这个实验案例中,还可以模拟链路故障的情况,观察OSPF的快速收敛性。当某个链路出现故障时,路由器将发送通告信息给邻居,通知它们链路状态已经改变。邻居将更新自己的LSDB,并重新计算最短路径。 通过这个综合实验案例,可以深入了解OSPF协议的工作原理和功能。同时,还可以通过观察实验结果,了解OSPF在网络中的优势和效率。这些知识和经验将帮助网络工程师更好地设计、优化和故障排除复杂的网络拓扑。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值