OSPF Process 1with Router ID 2.2.2.2 Area: 0.0.0.0 Link State Database Type : Router Ls id : 2.2.2.2 Adv rtr : 2.2.2.2 Ls age : 541 Len : 48 Options : E seq# : 8000000c chksum : 0x3f96 Link count: 2 * Link ID: 172.16.12.2 Data : 172.16.12.2 Link Type: TransNet Metric : 1 * Link ID: 172.16.255.0 Data : 255.255.255.0 Link Type: StubNet Metric : 0 Priority : Low
OSPF Process 1with Router ID 1.1.1.1 Interfaces Interface: 172.16.1.254 (Ethernet0/0/0) Cost: 1 State: DR Type: Broadcast MTU: 1500 Priority: 1 Designated Router: 172.16.1.254 Backup Designated Router: 0.0.0.0 Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1 #静默接口 不再发送hello包 Silent interface, No hellos
多区域配置
在三台路由器上部署 OSPF,使得全网各个网段能够实现数据互通。
需要注意在 ABR 上正确的区域下配置network命令。
R4 配置:
1 2 3 4 5 6 7 8 9 10 11
ospf 1 router-id4.4.4.4 #宣告至骨干区域 area 0 network 172.16.0.10.0.0.0 #宣告常规区域 area 1 network 172.16.0.00.0.3.255 #配置静默接口 ospf 1 silent-interface e 0/0/0 silent-interface e 0/0/1
R5 配置:
1 2 3 4 5 6 7 8
ospf 1 router-id5.5.5.5 area 0 network 172.16.0.50.0.0.0 area 2 network 172.16.0.00.0.15.255 ospf 1 silent-interface e 0/0/0 silent-interface e 0/0/1
在 R3 上查看路由表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
[Huawei]dis ip routing-table pro ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 5 Routes : 5
[Huawei-ospf-1]dis ospf lsdb OSPF Process 1with Router ID 1.1.1.1 Link State Database Area: 0.0.0.1 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.22.2.2.259536800000071 Router 1.1.1.11.1.1.180136800000051 Network 10.1.12.11.1.1.180132800000020 Sum-Net 10.1.23.02.2.2.259028800000011 Sum-Asbr 3.3.3.32.2.2.230028800000011 AS External Database Type LinkState ID AdvRouter Age Len Sequence Metric External 10.3.1.03.3.3.330136800000011 External 10.3.2.03.3.3.330136800000011
将 Area 1 配置为 Stub 区域观察路由及 LSA 变化
将一个区域配置为特殊区域,那么在内所有的路由器都将配置 stub 区域。即 R1、R2
配置:
1 2 3 4 5 6 7 8
R1: ospf 1 area 1 stub R2: ospf 1 area 1 stub
将区域配置为Stub之后将不再学习外部路由,阻挡四类、五类 LSA 进入此区域,并且 ABR 将下发一条三类 LSA 的默认路由。
[Huawei-ospf-1]dis ip rout pro ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 2 Routes : 2
[Huawei-ospf-1]dis ospf lsdb OSPF Process 1with Router ID 1.1.1.1 Link State Database Area: 0.0.0.1 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.22.2.2.215036800000051 Router 1.1.1.11.1.1.115336800000051 Network 10.1.12.22.2.2.215032800000020 Sum-Net 0.0.0.02.2.2.219728800000011 Sum-Net 10.1.23.02.2.2.219728800000011
将Area1配置为 Totally-Stub 区域,观察路由和 LSA 的变化
在Stub配置的基础上再追加no-summary关键字即可
配置:
1 2 3 4 5 6 7 8
R1: ospf 1 area 1 stub no-summary R2: ospf 1 area 1 stub no-summary
[Huawei-ospf-1-area-0.0.0.1]dis ip routing-table pro ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 1 Routes : 1
OSPF Process 1with Router ID 1.1.1.1 Link State Database Area: 0.0.0.1 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.22.2.2.212536 8000000A 1 Router 1.1.1.11.1.1.111736 8000000A 1 Network 10.1.12.11.1.1.112132800000020 Sum-Net 0.0.0.02.2.2.266328800000011
通过配置 Stub 区域大大减少路由表条目,注意 Stub 区域不能够引入外部路由。
如果需要在特殊区域中引入少量外部路由可以将区域配置为 Nssa 区域:
将 Area1 配置为 Nssa 区域:
1 2 3 4 5 6 7 8
R1: ospf 1 area 1 nssa R2: ospf 1 area 1 nssa
R1 引入静态路由:
1 2 3
ip route-static 10.1.1.024 NULL 0 ospf 1 import-route static
R1 引入外部路由后会产生七类 LSA 用于描述外部路由在所在区域内传播;
在区域被配置为 NSSA 区域后,ABR 将向区域内下发七类 LSA 的默认路由。
1 2 3 4 5 6 7 8 9 10 11 12
R1: [Huawei]dis ospf lsdb OSPF Process 1with Router ID 1.1.1.1 Link State Database Area: 0.0.0.1 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.22.2.2.221236800000051 Router 1.1.1.11.1.1.118036800000061 Network 10.1.12.22.2.2.221232800000020 Sum-Net 10.1.23.02.2.2.225628800000011 NSSA 10.1.1.01.1.1.118036800000011 NSSA 0.0.0.02.2.2.225636800000011
ABR 在学习到 R1 产生的七类外部 LSA 后,会将其转换成五类 LSA 注入至骨干区域;
10.1.1.0 即转换后的五类 LSA,另外两条是 R3 引入的外部路由。
1 2 3 4 5 6
R2: AS External Database Type LinkState ID AdvRouter Age Len Sequence Metric External 10.1.1.02.2.2.229736800000011 External 10.3.1.03.3.3.378436800000021 External 10.3.2.03.3.3.378436800000021
将区域配置为 Totall-NSSA 区域,即在 nssa 关键字后追加no-summary
配置为 Totall-NSSA 区域后在原基础上屏蔽三类 LSA,并下发三类 LSA 的默认路由;
此时路由表中存在三类和七类两条默认路由 LSA,优先使用三类 LSA 的默认路由;
1 2 3 4 5 6 7 8 9 10 11
OSPF Process 1with Router ID 1.1.1.1 Link State Database
Area: 0.0.0.1 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.22.2.2.219436 8000000A 1 Router 1.1.1.11.1.1.118836 8000000B 1 Network 10.1.12.11.1.1.118932800000020 Sum-Net 0.0.0.02.2.2.220028800000011 NSSA 10.1.1.01.1.1.120636800000011 NSSA 0.0.0.02.2.2.278036800000011
[Huawei]dis ip routing-table pro ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 1 Routes : 1