OSPF_Type5_LSA_COST

理论

  • 五类LSA默认有两种开销计算方法,(默认开销类型是tpye2)
    • type1
      • 特点开销在OSPF域内不断增加
    • type2
      • 默认开销类型是tpye2,默认就是这种的
      • 特点开销在OSPF域内会始终保持不变

当我们引入路由时,默认是tpye-2的开销类型,这种开销类型有什么特点呢?

假如说我们从路由器B2引入,那路由条目扩散到B4路由器,开销也会保持不变,即OSFP的种子开销1,如下所示:

image-20230702233927176

当我们引入路由时,如果修改开销类型为type-1,这种开销类型有什么特点呢?

如果引入时不指定开销,初始种子开销是1,但此时的开销传播时会叠加,开销的叠加与开销的计算一样,将沿途入接口的开销叠加起来,如下所示:

image-20230702233933153

PS:将ISIS引入到OSPF初始开销是1,反之也是1,这个值是初始开销值,是可以进行修改的,修改方法如下:

# B2
ospf
	import-route isis type 1 cost 10

实验验证

基础配置

# B1
sys
sysn B1
int l0
	ip add 10.0.1.1 32
int g0/0/0
	ip add 10.0.12.1 24
ospf 1 router-id 10.0.1.1
a 0
	network 10.0.1.1 0.0.0.0
	network 10.0.12.1 0.0.0.0
	quit
# B2
sys
sysn B2
int l0
	ip add 10.0.2.2 32
int g0/0/0
	ip add 10.0.12.2 24
int g0/0/1
	ip add 10.0.23.2 24
ospf 1 router-id 10.0.2.2
	a 0
		network 10.0.2.2 0.0.0.0
		network 10.0.12.2 0.0.0.0
		quit

isis 1
	network-entity 49.0001.0000.0000.0001.00
int g0/0/1
	isis enable 1
# B3
sys
sysn B3
int l0
	ip add 10.0.3.3 32
int g0/0/0
	ip add 10.0.23.3 24
	quit
isis 1
	network-entity 49.0001.0000.0000.0003.00
int g0/0/0
	isis enable 1
int l0
	isis en 1
# 在B1上校验一下
<B1>dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
         Destinations : 1        Routes : 1        

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

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

10.0.2.2/32  OSPF    10   1           D   10.0.12.2       GigabitEthernet 0/0/0

目的B1只有B2环回接口的OSPF路由条目,没错,就是这样的!

产生五类(默认开销type-2)

五类是外部路由,接下来,我们就要在B2上的OSPF进程当中引入ISIS路由,事先打开抓包工具在B1与B2的连接处进行抓包,等着ospf update报文出现。

[B2]dis ip routing-table protocol isis
10.0.3.3/32  ISIS-L1 15   10          D   10.0.23.3       GigabitEthernet 0/0/1

[B2]ospf 1 
[B2-ospf-1]import-route isis

image-20230702233944504

image-20230702233955530

注意观察上图,默认的外部路由类型是type-2,我们在B1查看发现开销就是1

<B1>dis ip routing-table protocol ospf
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
10.0.2.2/32  OSPF    10   1           D   10.0.12.2       GigabitEthernet 0/0/0
10.0.3.3/32  O_ASE   150  1           D   10.0.12.2       GigabitEthernet 0/0/0
10.0.23.0/24  O_ASE   150  1           D   10.0.12.2       GigabitEthernet 0/0/0

我们在B1的左侧再加一台路由器B4,与B1通过OSPF区域0进行连接,然后去B4上查看引入的这两条路由的开销,如下所示

image-20230702234006263

# 注意,B4开销还是1,与B1是一样的
[B4]dis ip routing-table protocol ospf
10.0.3.3/32  O_ASE   150  1           D   10.0.14.1       GigabitEthernet 0/0/0
10.0.23.0/24  O_ASE   150  1           D   10.0.14.1       GigabitEthernet 0/0/0

说明开销类型为type-2的五类LSA,开销开始保持为1不变!

修改(强制开销type-1)

image-20230702234017248

在B2的OSPF进行引入ISIS路由时,对开销的类型进行规定,强制要求是使用type-1类型,如下所示:

# B2,非常简单,默告诉你是type-2的开销类型,接下来明确要求使用tpye-1
# B2
ospf  1
	import-route isis 1 type 1

image-20230702234026529

# 我们再去B1上看开销,发现开销变为2,开销已经叠加了!
<B1>dis ip routing-table protocol ospf
10.0.3.3/32  O_ASE   150  2           D   10.0.12.2       GigabitEthernet0/0/0
10.0.23.0/24  O_ASE   150  2           D   10.0.12.2       GigabitEthernet0/0/0
# B4上看一下,发现又叠加1,2+1=3
[B4]dis ip routing-table protocol ospf
10.0.3.3/32  O_ASE   150  3           D   10.0.14.1       GigabitEthernet0/0/0
10.0.23.0/24  O_ASE   150  3           D   10.0.14.1       GigabitEthernet0/0/0

查看

# 从LSDB当中也能看到开销类型
<B1>dis ospf lsdb ase 

	 OSPF Process 1 with Router ID 10.0.1.1
		 Link State Database

  Type      : External
  Ls id     : 10.0.3.3
  Adv rtr   : 10.0.2.2  
  Ls age    : 245 
  Len       : 36 
  Options   :  E  
  seq#      : 80000002 
  chksum    : 0x9d8b
  Net mask  : 255.255.255.255 
  TOS 0  Metric: 10 
  **E type    : 1                  # 在这一行**
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Medium

  Type      : External
  Ls id     : 10.0.23.0
  Adv rtr   : 10.0.2.2  
  Ls age    : 245 
  Len       : 36 
  Options   :  E  
  seq#      : 80000002 
  chksum    : 0xde39
  Net mask  : 255.255.255.0 
  TOS 0  Metric: 10 
  **E type    : 1           # 在这一行**
  Forwarding Address : 0.0.0.0 
  Tag       : 1 
  Priority  : Low
posted @ 2023-07-02 23:41  张贺贺呀  阅读(165)  评论(0编辑  收藏  举报