OSPF-缺省路由注入(default-route-advertise&default-route-advertise always)

 


关于OSPD的路由注入使用import-route命令。

import-route命令只能注入明细路由,直连路由,外部协议路由;但是不能注入缺省路由,默认路由。

AR4有一条默认路由指向外部网络,import-route不能注入缺省路由,内部路由器不能学习到默认路由,即内部网络无法访问外部网络。

我们通过default-route-advertise&default-route-advertise always其中一个命令注入缺省路由

 

一:default-route-advertise 使用

default-route-advertise:向内部路由器宣告自身的默认路由

[AR4]display ip routing-table 0.0.0.0
#目前自身没有默认路由

[AR4]ospf
[AR4-ospf-1]default-route-advertise
#进入协议,配置

  

查看内部路由器路由表,确认是否有新默认的路由

<AR1>dis ip routing-table 0.0.0.0
<AR1>
#显示没有新的默认路由

  由于AR4本身没有默认路由,所以内部路由器不会学习到新的默认路由

 

为AR4添加默认路由

[AR4]ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/1 202.102.1.1
[AR4]dis ip ro	
[AR4]dis ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   Static  60   0           D   202.102.1.1     GigabitEthernet
0/0/1

[AR4]

  

为AR4添加完默认路由后,再次查看内部路由器路由

<AR1>dis ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   10.1.13.3       GigabitEthernet
0/0/1

<AR1>dis ospf ls	
<AR1>dis ospf lsdb 

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            596  60    8000000C      10
 Router    1.1.1.1         1.1.1.1            598  60    8000000B      10
 Router    3.3.3.3         3.3.3.3            597  60    8000000D       5
 Network   10.1.23.3       3.3.3.3            601  32    80000004       0
 Network   10.1.13.3       3.3.3.3            597  32    80000004       0
 Network   10.1.12.2       2.2.2.2            596  32    80000004       0
 Sum-Net   10.1.35.0       3.3.3.3            649  28    80000003       1
 Sum-Net   10.1.34.0       3.3.3.3            649  28    80000003       1
 Sum-Net   5.5.5.5         3.3.3.3            611  28    80000003       1
 Sum-Net   4.4.4.4         3.3.3.3            604  28    80000003       1
 Sum-Net   202.102.1.0     3.3.3.3            604  28    80000003       2
 Sum-Asbr  4.4.4.4         3.3.3.3            736  28    80000002       1
 

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  0.0.0.0         4.4.4.4            181  36    80000001       1
 

<AR1>dis ospf lsdb ase 0.0.0.0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database


  Type      : External
  Ls id     : 0.0.0.0
  Adv rtr   : 4.4.4.4  
  Ls age    : 193 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x2568
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 202.102.1.1 
  Tag       : 1 
  Priority  : Low
 
<AR1>

  AR4添加完默认路由后,内部路由顺利学习到新的AR4上的默认路由。

 

二:default-route-advertise always 使用

default-route-advertise always与default-route-advertise 区别在于,如果自身没有缺省路由,设备自动生成默认路由的LSA发送内部路由器

 

 

 

 

[AR4-ospf-1]default-route-advertise always 
<AR1>dis ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   10.1.13.3       GigabitEthernet
0/0/1


<AR1>dis ospf lsdb 

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            298  60    8000000D      10
 Router    1.1.1.1         1.1.1.1            300  60    8000000C      10
 Router    3.3.3.3         3.3.3.3            300  60    8000000E       5
 Network   10.1.23.3       3.3.3.3            303  32    80000005       0
 Network   10.1.13.3       3.3.3.3            300  32    80000005       0
 Network   10.1.12.2       2.2.2.2            298  32    80000005       0
 Sum-Net   10.1.35.0       3.3.3.3            351  28    80000004       1
 Sum-Net   10.1.34.0       3.3.3.3            351  28    80000004       1
 Sum-Net   5.5.5.5         3.3.3.3            313  28    80000004       1
 Sum-Net   4.4.4.4         3.3.3.3            306  28    80000004       1
 Sum-Net   202.102.1.0     3.3.3.3            306  28    80000004       2
 Sum-Asbr  4.4.4.4         3.3.3.3           1206  28    80000001       1
 

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  0.0.0.0         4.4.4.4            644  36    80000001       1
 

<AR1>dis ospf lsdb ase 0.0.0.0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database


  Type      : External
  Ls id     : 0.0.0.0
  Adv rtr   : 4.4.4.4  
  Ls age    : 653 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x863a
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low
 
<AR1>

  通过查询OSPD数据库得知,默认网段指向AR4,但是到达AR4后不会再转发出去。所以AR4上还必须补上一条指向外部的默认路由,内部网络才能正常访问外部网络。

[AR4]ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/1 202.102.1.1

 

<AR1>dis ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   10.1.13.3       GigabitEthernet
0/0/1


<AR1>dis ospf lsdb 

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2           1176  60    8000000D      10
 Router    1.1.1.1         1.1.1.1           1178  60    8000000C      10
 Router    3.3.3.3         3.3.3.3           1178  60    8000000E       5
 Network   10.1.23.3       3.3.3.3           1181  32    80000005       0
 Network   10.1.13.3       3.3.3.3           1178  32    80000005       0
 Network   10.1.12.2       2.2.2.2           1176  32    80000005       0
 Sum-Net   10.1.35.0       3.3.3.3           1229  28    80000004       1
 Sum-Net   10.1.34.0       3.3.3.3           1229  28    80000004       1
 Sum-Net   5.5.5.5         3.3.3.3           1191  28    80000004       1
 Sum-Net   4.4.4.4         3.3.3.3           1184  28    80000004       1
 Sum-Net   202.102.1.0     3.3.3.3           1184  28    80000004       2
 Sum-Asbr  4.4.4.4         3.3.3.3            283  28    80000002       1
 

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  0.0.0.0         4.4.4.4            101  36    80000002       1
 

<AR1>dis ospf lsdb ase 0.0.0.0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database


  Type      : External
  Ls id     : 0.0.0.0
  Adv rtr   : 4.4.4.4  
  Ls age    : 109 
  Len       : 36 
  Options   :  E  
  seq#      : 80000002 
  chksum    : 0x2369
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 202.102.1.1 
  Tag       : 1 
  Priority  : Low
 
<AR1>

  

 AR4增加默认路由后,查看OSPD数据库,路由表,发现0.0.0.0到达AR4后的下一跳地址指向了外部网络互联地址

 

三:特殊区域(nssa区域)的缺省路由宣告方式:nssa default-route-advertise 

nssa区域需要ASBR宣告缺省路由,使得nssa区域的路由器学习到外部缺省路由。然后再通过ABR向内部路由器宣告缺省路由。

 

未宣告缺省路由前AR1,AR3,AR4的OSPF数据库

AR1路由器OSPF数据库中没有缺省路由

<AR1>dis ospf lsdb 

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            928  60    8000000A      10
 Router    1.1.1.1         1.1.1.1            930  60    8000000A      10
 Router    3.3.3.3         3.3.3.3            700  60    8000000D       5
 Network   10.1.23.3       3.3.3.3            939  32    80000002       0
 Network   10.1.13.3       3.3.3.3            929  32    80000003       0
 Network   10.1.12.2       2.2.2.2            928  32    80000003       0
 Sum-Net   10.1.35.0       3.3.3.3            980  28    80000002       1
 Sum-Net   10.1.34.0       3.3.3.3            700  28    80000003       1
 Sum-Net   5.5.5.5         3.3.3.3            942  28    80000002       1
 Sum-Net   4.4.4.4         3.3.3.3            660  28    80000002       1
 Sum-Net   202.102.1.0     3.3.3.3            660  28    80000002       2
 

  

AR3和AR4所属区域1  拥有sum-net和nssa的0.0.0.0 链路信息,sum-net对普通区域发送,nssa针对nssa内部路由器发送

[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb 

	 OSPF Process 1 with Router ID 3.3.3.3
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            996  60    8000000A      10
 Router    1.1.1.1         1.1.1.1            999  60    8000000A      10
 Router    3.3.3.3         3.3.3.3            767  60    8000000D       5
 Network   10.1.23.3       3.3.3.3           1005  32    80000002       0
 Network   10.1.13.3       3.3.3.3            995  32    80000003       0
 Network   10.1.12.2       2.2.2.2            996  32    80000003       0
 Sum-Net   10.1.35.0       3.3.3.3           1047  28    80000002       1
 Sum-Net   10.1.34.0       3.3.3.3            767  28    80000003       1
 Sum-Net   5.5.5.5         3.3.3.3           1008  28    80000002       1
 Sum-Net   4.4.4.4         3.3.3.3            726  28    80000002       1
 Sum-Net   202.102.1.0     3.3.3.3            726  28    80000002       2
 
		         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4             32  60    8000000A       1
 Router    3.3.3.3         3.3.3.3            726  36    80000005       1
 Network   10.1.34.4       4.4.4.4            727  32    80000002       0
 Sum-Net   0.0.0.0         3.3.3.3            767  28    80000002       1
 NSSA      0.0.0.0         3.3.3.3            767  36    80000002       1
 
		         Area: 0.0.0.2
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    5.5.5.5         5.5.5.5           1001  48    80000007       1
 Router    3.3.3.3         3.3.3.3            767  36    80000006       1
 Network   10.1.35.5       5.5.5.5           1001  32    80000003       0
 Sum-Net   10.1.23.0       3.3.3.3           1047  28    80000002       5
 Sum-Net   10.1.34.0       3.3.3.3            767  28    80000003       1
 Sum-Net   10.1.13.0       3.3.3.3           1042  28    80000002       5
 Sum-Net   3.3.3.3         3.3.3.3           1047  28    80000002       0
 Sum-Net   10.1.12.0       3.3.3.3            998  28    80000003      15
 Sum-Net   4.4.4.4         3.3.3.3            726  28    80000002       1
 Sum-Net   2.2.2.2         3.3.3.3           1006  28    80000002       5
 Sum-Net   202.102.1.0     3.3.3.3            727  28    80000002       2
 Sum-Net   1.1.1.1         3.3.3.3           1003  28    80000002       5
 
 

[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb summary 0.0.0.0

	 OSPF Process 1 with Router ID 3.3.3.3
		         Area: 0.0.0.0
		 Link State Database 

		         Area: 0.0.0.1
		 Link State Database 


  Type      : Sum-Net
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 780 
  Len       : 28 
  Options   : None 
  seq#      : 80000002 
  chksum    : 0x371a
  Net mask  : 0.0.0.0
  Tos 0  metric: 1
  Priority  : Low
		         Area: 0.0.0.2
		 Link State Database 

 

[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb nssa 0.0.0.0

	 OSPF Process 1 with Router ID 3.3.3.3
		         Area: 0.0.0.0
		 Link State Database 

		         Area: 0.0.0.1
		 Link State Database 


  Type      : NSSA
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 789 
  Len       : 36 
  Options   : None 
  seq#      : 80000002 
  chksum    : 0xa41f
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low
		         Area: 0.0.0.2
		 Link State Database 

 

[AR3-ospf-1-area-0.0.0.1]dis ip routing-table 0.0.0.0
[AR3-ospf-1-area-0.0.0.1]

  

[AR4]dis ospf lsdb 

	 OSPF Process 1 with Router ID 4.4.4.4
		 Link State Database 

		         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4           1603  60    80000009       1
 Router    3.3.3.3         3.3.3.3            501  36    80000005       1
 Network   10.1.34.4       4.4.4.4            500  32    80000002       0
 Sum-Net   0.0.0.0         3.3.3.3            542  28    80000002       1
 NSSA      0.0.0.0         3.3.3.3            542  36    80000002       1
 
[AR4]dis ospf ls	
[AR4]dis ospf lsdb ns	
[AR4]dis ospf lsdb nssa 0.0.0.0

	 OSPF Process 1 with Router ID 4.4.4.4
		         Area: 0.0.0.1
		 Link State Database 


  Type      : NSSA
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 553 
  Len       : 36 
  Options   : None 
  seq#      : 80000002 
  chksum    : 0xa41f
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low
[AR4]dis ip ro	
[AR4]dis ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   2           D   10.1.34.3       GigabitEthernet
0/0/0


[AR4]dis ospf lsdb 

	 OSPF Process 1 with Router ID 4.4.4.4
		 Link State Database 

		         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4           1724  60    80000009       1
 Router    3.3.3.3         3.3.3.3            622  36    80000005       1
 Network   10.1.34.4       4.4.4.4            621  32    80000002       0
 Sum-Net   0.0.0.0         3.3.3.3            663  28    80000002       1
 NSSA      0.0.0.0         3.3.3.3            663  36    80000002       1
 

[AR4]dis ospf lsdb summary 0.0.0.0

	 OSPF Process 1 with Router ID 4.4.4.4
		         Area: 0.0.0.1
		 Link State Database 


  Type      : Sum-Net
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 683 
  Len       : 28 
  Options   : None 
  seq#      : 80000002 
  chksum    : 0x371a
  Net mask  : 0.0.0.0
  Tos 0  metric: 1
  Priority  : Low

[AR4]dis ospf lsdb nssa 0.0.0.0

	 OSPF Process 1 with Router ID 4.4.4.4
		         Area: 0.0.0.1
		 Link State Database 


  Type      : NSSA
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 690 
  Len       : 36 
  Options   : None 
  seq#      : 80000002 
  chksum    : 0xa41f
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low
[AR4]

  

AR4,配置默认路由,宣告默认路由配置

[AR4]ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/1 202.102.1.1
[AR4]ospf 
[AR4-ospf-1]area 1
[AR4-ospf-1-area-0.0.0.1]nssa default-route-advertise 

 

查看AR4的LSDB,默认路由:

[AR4]dis ip routing-table 0.0.0.0 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   OSPF    10   2           D   10.1.34.3       GigabitEthernet
0/0/0


[AR4]dis ospf lsdb 

	 OSPF Process 1 with Router ID 4.4.4.4
		 Link State Database 

		         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4            936  60    80000006       1
 Router    3.3.3.3         3.3.3.3            937  36    80000004       1
 Network   10.1.34.4       4.4.4.4            936  32    80000001       0
 Sum-Net   0.0.0.0         3.3.3.3            976  28    80000001       1
 NSSA      0.0.0.0         3.3.3.3            976  36    80000001       1
 

AR4宣告路由后,路由表和LSDB没有变化。因为华为选路规则中,OSPF优先级为10,静态路由优先级为60;所以路由表选择优先值低的静态路由。

 

因此,为了实现路由表选择静态路由,需要手动配置默认路由优先级,使优先值小于OSPF路由的优先值

[AR4]ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/1 202.102.1.1 preference 5

  

[AR4]display ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   Static  5    0           D   202.102.1.1     GigabitEthernet
0/0/1

[AR4]dis ospf ls	
[AR4]dis ospf lsdb 

	 OSPF Process 1 with Router ID 4.4.4.4
		 Link State Database 

		         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4            460  60    80000007       1
 Router    3.3.3.3         3.3.3.3            461  36    80000005       1
 Network   10.1.34.4       4.4.4.4            460  32    80000002       0
 Sum-Net   0.0.0.0         3.3.3.3            500  28    80000002       1
 NSSA      0.0.0.0         4.4.4.4            747  36    80000001       1
 NSSA      0.0.0.0         3.3.3.3            500  36    80000002       1
 

[AR4]display ospf lsdb nssa 0.0.0.0 self-originate 

	 OSPF Process 1 with Router ID 4.4.4.4
		         Area: 0.0.0.1
		 Link State Database 


  Type      : NSSA
  Ls id     : 0.0.0.0
  Adv rtr   : 4.4.4.4  
  Ls age    : 762 
  Len       : 36 
  Options   : None 
  seq#      : 80000001 
  chksum    : 0x2766
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 202.102.1.1 
  Tag       : 1 
  Priority  : Low
[AR4]
[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb 

	 OSPF Process 1 with Router ID 3.3.3.3
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            420  60    80000009      10
 Router    1.1.1.1         1.1.1.1            424  60    80000009      10
 Router    3.3.3.3         3.3.3.3            257  60    8000000C       5
 Network   10.1.23.3       3.3.3.3            430  32    80000001       0
 Network   10.1.13.3       3.3.3.3            420  32    80000002       0
 Network   10.1.12.2       2.2.2.2            420  32    80000002       0
 Sum-Net   10.1.35.0       3.3.3.3            472  28    80000001       1
 Sum-Net   10.1.34.0       3.3.3.3            257  28    80000002       1
 Sum-Net   5.5.5.5         3.3.3.3            429  28    80000001       1
 Sum-Net   4.4.4.4         3.3.3.3            210  28    80000001       1
 Sum-Net   202.102.1.0     3.3.3.3            210  28    80000001       2
 
		         Area: 0.0.0.1
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    4.4.4.4         4.4.4.4            211  60    80000006       1
 Router    3.3.3.3         3.3.3.3            210  36    80000004       1
 Network   10.1.34.4       4.4.4.4            211  32    80000001       0
 Sum-Net   0.0.0.0         3.3.3.3            257  28    80000001       1
 NSSA      0.0.0.0         3.3.3.3            257  36    80000001       1
 NSSA      0.0.0.0         4.4.4.4            134  36    80000001       1
 
		         Area: 0.0.0.2
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    5.5.5.5         5.5.5.5            431  48    80000006       1
 Router    3.3.3.3         3.3.3.3            257  36    80000004       1
 Network   10.1.35.5       5.5.5.5            431  32    80000001       0
 Sum-Net   10.1.23.0       3.3.3.3            472  28    80000001       5
 Sum-Net   10.1.34.0       3.3.3.3            257  28    80000002       1
 Sum-Net   10.1.13.0       3.3.3.3            469  28    80000001       5
 Sum-Net   3.3.3.3         3.3.3.3            472  28    80000001       0
 Sum-Net   10.1.12.0       3.3.3.3            423  28    80000002      15
 Sum-Net   4.4.4.4         3.3.3.3            212  28    80000001       1
 Sum-Net   2.2.2.2         3.3.3.3            432  28    80000001       5
 Sum-Net   202.102.1.0     3.3.3.3            212  28    80000001       2
 Sum-Net   1.1.1.1         3.3.3.3            429  28    80000001       5
 
 
[AR3-ospf-1-area-0.0.0.1]dis ospf ls	
[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb ns	
[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb nssa 0.0.0.0 or	
[AR3-ospf-1-area-0.0.0.1]dis ospf lsdb nssa 0.0.0.0 originate-router 

	 OSPF Process 1 with Router ID 3.3.3.3
		         Area: 0.0.0.0
		 Link State Database 

		         Area: 0.0.0.1
		 Link State Database 


  Type      : NSSA
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 300 
  Len       : 36 
  Options   : None 
  seq#      : 80000001 
  chksum    : 0xa61e
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low

  Type      : NSSA
  Ls id     : 0.0.0.0
  Adv rtr   : 4.4.4.4  
  Ls age    : 177 
  Len       : 36 
  Options   : None 
  seq#      : 80000001 
  chksum    : 0x2766
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 202.102.1.1 
  Tag       : 1 
  Priority  : Low
		         Area: 0.0.0.2
		 Link State Database 

 
[AR3-ospf-1-area-0.0.0.1]dis ip ro	
[AR3-ospf-1-area-0.0.0.1]dis ip routing-table 0.0.0.0

  

此时内部路由器还没有学习到NSSA区域AR4的默认路由。原因在于NSSA区域的默认路由不会转发到内部区域
所以需要AR3配置默认路由指向AR4,通过在AR3宣告默认路由,让内部路由器默认路由指向AR3,再由AR3转发AR4

[AR3]ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet 0/0/0 10.1.34.4 

[AR3]ospf 
[AR3-ospf-1]default-route-advertise always 
<AR1>dis ospf lsdb 

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database 

		         Area: 0.0.0.0
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 Router    2.2.2.2         2.2.2.2            482  60    80000009      10
 Router    1.1.1.1         1.1.1.1            483  60    80000008      10
 Router    3.3.3.3         3.3.3.3            459  60    8000000C       5
 Network   10.1.23.3       3.3.3.3            487  32    80000001       0
 Network   10.1.13.3       3.3.3.3            479  32    80000002       0
 Network   10.1.12.2       2.2.2.2            484  32    80000001       0
 Sum-Net   10.1.35.0       3.3.3.3            529  28    80000001       1
 Sum-Net   10.1.34.0       3.3.3.3            459  28    80000002       1
 Sum-Net   5.5.5.5         3.3.3.3            485  28    80000001       1
 Sum-Net   4.4.4.4         3.3.3.3            417  28    80000001       1
 

		 AS External Database
 Type      LinkState ID    AdvRouter          Age  Len   Sequence   Metric
 External  0.0.0.0         3.3.3.3             76  36    80000001       1
 External  202.102.1.0     3.3.3.3            391  36    80000001       1
 

<AR1>dis ospf lsdb ase 0.0.0.0

	 OSPF Process 1 with Router ID 1.1.1.1
		 Link State Database


  Type      : External
  Ls id     : 0.0.0.0
  Adv rtr   : 3.3.3.3  
  Ls age    : 193 
  Len       : 36 
  Options   :  E  
  seq#      : 80000001 
  chksum    : 0x1380
  Net mask  : 0.0.0.0 
  TOS 0  Metric: 1 
  E type    : 2
  Forwarding Address : 10.1.34.4 
  Tag       : 1 
  Priority  : Low
 
<AR1>dis ip routing-table 0.0.0.0
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   O_ASE   150  1           D   10.1.13.3       GigabitEthernet
0/0/1

查询AR1的LSDB和路由表已经学习到默认路由,此时还无法访问外部网络。

<AR1>ping -a 1.1.1.1 9.9.9.9
  PING 9.9.9.9: 56  data bytes, press CTRL_C to break
    Request time out
    Request time out
    Request time out
    Request time out
    Request time out

  --- 9.9.9.9 ping statistics ---
    5 packet(s) transmitted
    0 packet(s) received
    100.00% packet loss

  此时AR4没有指向内部的路由,所以需要在AR4逐条配置指向内部网络的静态路由

[AR4]ip route-static 1.1.1.1 32 GigabitEthernet 0/0/0 10.1.34.3
<AR1>ping -a 1.1.1.1 9.9.9.9
  PING 9.9.9.9: 56  data bytes, press CTRL_C to break
    Reply from 9.9.9.9: bytes=56 Sequence=1 ttl=253 time=30 ms
    Reply from 9.9.9.9: bytes=56 Sequence=2 ttl=253 time=30 ms
    Reply from 9.9.9.9: bytes=56 Sequence=3 ttl=253 time=40 ms
    Reply from 9.9.9.9: bytes=56 Sequence=4 ttl=253 time=30 ms
    Reply from 9.9.9.9: bytes=56 Sequence=5 ttl=253 time=20 ms

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

<AR1>

 

AR4主体配置如下

interface GigabitEthernet0/0/0
 ip address 10.1.34.4 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 202.102.1.4 255.255.255.0 
#
interface GigabitEthernet0/0/2
#
interface NULL0
#
interface LoopBack0
 ip address 4.4.4.4 255.255.255.255 
#
ospf 1 router-id 4.4.4.4 
 import-route direct
 area 0.0.0.1 
  network 4.4.4.4 0.0.0.0 
  network 10.1.34.4 0.0.0.0 
  nssa default-route-advertise
#
ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/1 202.102.1.1 preference 5
ip route-static 1.1.1.1 255.255.255.255 GigabitEthernet0/0/0 10.1.34.3
#
user-interface con 0
 authentication-mode password
 idle-timeout 0 0

  

AR3主体配置如下:

interface LoopBack0
 ip address 3.3.3.3 255.255.255.255 
#
ospf 1 router-id 3.3.3.3 
 default-route-advertise always
 area 0.0.0.0 
  network 3.3.3.3 0.0.0.0 
  network 10.1.13.3 0.0.0.0 
  network 10.1.23.3 0.0.0.0 
 area 0.0.0.1 
  network 10.1.34.3 0.0.0.0 
  nssa no-summary
 area 0.0.0.2 
  network 10.1.35.3 0.0.0.0 
#
ip route-static 0.0.0.0 0.0.0.0 GigabitEthernet0/0/0 10.1.34.4
#
user-interface con 0
 authentication-mode password
 idle-timeout 0 0

  

 

posted @ 2023-07-31 11:00  广东二十一郎  阅读(6081)  评论(0编辑  收藏  举报