R1、R2、R3配置此处省略,仅展示R4配置:
R4:
interface GigabitEthernet0/0/0
ip address 10.1.34.4 255.255.255.0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
ospf 1
import-route direct type 1 route-policy 1
area 0.0.0.1
network 10.1.34.4 0.0.0.0
#
route-policy 1 permit node 10
if-match ip-prefix 1
#
ip ip-prefix 1 index 10 permit 4.4.4.4 32
#
<R1>display ospf lsdb ase 4.4.4.4
OSPF Process 1 with Router ID 10.1.12.1
Link State Database
Type : External **type 5 LSA, 由ASBR产生,除特殊区或之外,在整个AS内部泛洪**
Ls id : 4.4.4.4 **外部路由网络号**
Adv rtr : 10.1.34.4 **ASBR的router id (图中的R4)**
Ls age : 498
Len : 36
Options : E
seq# : 80000001
chksum : 0x59b6
Net mask : 255.255.255.255 **外部路由的子网掩码**
TOS 0 Metric: 1 **外部路由的默认开销**
E type : 1 **开销类型,默认为type 2,此处修改为type 1**
Forwarding Address : 0.0.0.0 **FA地址**
Tag : 1 **路由tag,默认为1,注意只有外部路由才携带tag信息**
Priority : Medium
<R1>display ospf lsdb asbr
OSPF Process 1 with Router ID 10.1.12.1
Area: 0.0.0.2
Link State Database
Type : Sum-Asbr **type 4 LSA,由ABR产生,在产生的区城内泛洪**
Ls id : 10.1.34.4 **ASBR的router id**
Adv rtr : 10.1.12.2 **ABR的router id**
Ls age : 822
Len : 28
Options : E
seq# : 80000001
chksum : 0x808f
Tos 0 metric: 2 **ABR到ASBR的开销**
开销 = 自身到ABR的开销 + ABR到 type 3 路由的开销
下一跳 = 自身到ABR的下一跳
1)以cost-type 1引入外部路由,FA地址为0.0.0.0
查看R3的路由表:
<R3>display ip routing-table 4.4.4.4
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
4.4.4.4/32 O_ASE 150 2 D 10.1.34.4 GigabitEthernet0/0/1
2)以cost-type 2引入外部路由,FA地址为0.0.0.0
在R4上修改外部路由的cost-type为 type 2:
R4:
ospf 1
import-route direct type 2 route-policy 1
#
查看R3的路由表:
<R3>display ip routing-table 4.4.4.4
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
4.4.4.4/32 O_ASE 150 1 D 10.1.34.4 GigabitEthernet0/0/1
1)以cost-type 1引入外部路由,FA地址为0.0.0.0
查看R1的路由表:
<R1>display ip routing-table 4.4.4.4
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
4.4.4.4/32 O_ASE 150 4 D 10.1.12.2 GigabitEthernet0/0/0
2)以cost-type 2引入外部路由,FA地址为0.0.0.0
在R4上修改外部路由的cost-type为 type 2:
R4:
ospf 1
import-route direct type 2 route-policy 1
#
查看R1的路由表:
<R1>display ip routing-table 4.4.4.4
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
4.4.4.4/32 O_ASE 150 1 D 10.1.12.2 GigabitEthernet0/0/0
R1如何计算出到ASBR的开销?
R1到ABR的开销 + ABR所产生这条type 4 LSA的开销
注意:type-cost 1 > type-cost 2
1、开销值小的最优
2、如果相同,则负载分担
type-cost 1 就是管理员希望按路由意义的最短路径访问外部网络。
1、引入时开销小优先,不考虑AS内部路径开销。
2、引入时开销相同,选择到ASBR的开销小的。
3、引入时开销相同,到ASBR的开销也相同,则负载分担。
type-cost 2 就是管理员希望按管理意义上最短的路径访问外部网络。