华为路由器OSPF配置
程序员文章站
2022-07-10 20:22:26
...
配置拓扑
按照拓扑图上配置ospf的三个区域,相互学习到路由并查看每个路由器的LSDB和相关LSA信息,AR4与AR6分别扮演ASBR角色并将自己的环回接口网络重分布进ospf网络中,AR6的外部路由使type1(AR4的使用默认的type2)分布进ospf,并查看LSA5。
AR1的配置
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 13.1.1.1 255.255.255.0
#
ospf 1 router-id 1.1.1.1 ospf的r-id
area 0.0.0.0 创建area0
network 12.1.1.1 0.0.0.0 在area0中宣告属于area0区域的接口(允许该接口在area0收发ospf报文)
area 0.0.0.1 创建area1
network 13.1.1.1 0.0.0.0 在area1中宣告属于area1区域的接口
#
AR2的配置
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 25.1.1.2 255.255.255.0
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 12.1.1.2 0.0.0.0
area 0.0.0.2
network 25.1.1.2 0.0.0.0
#
AR3的配置
interface GigabitEthernet0/0/0
ip address 13.1.1.3 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 34.1.1.3 255.255.255.0
#
ospf 1 router-id 3.3.3.3
area 0.0.0.1
network 13.1.1.3 0.0.0.0
network 34.1.1.3 0.0.0.0
#
AR4的配置
interface GigabitEthernet0/0/0
ip address 34.1.1.4 255.255.255.0
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
ospf 1 router-id 4.4.4.4
import-route direct 重分布直连路由到ospf中,类型为默认的type2(cost固定为1)
area 0.0.0.1
network 34.1.1.4 0.0.0.0
#
AR5的配置
interface GigabitEthernet0/0/0
ip address 25.1.1.5 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 56.1.1.5 255.255.255.0
#
ospf 1 router-id 5.5.5.5
area 0.0.0.2
network 25.1.1.5 0.0.0.0
network 56.1.1.5 0.0.0.0
#
AR6上的配置
interface GigabitEthernet0/0/0
ip address 56.1.1.6 255.255.255.0
#
interface LoopBack0
ip address 6.6.6.6 255.255.255.255
#
ospf 1 router-id 6.6.6.6
import-route direct type 1 重分布直连路由到ospf中,类型为type1(类型区别在于路由的metric不同,type1的cost大)
area 0.0.0.2
network 56.1.1.6 0.0.0.0
#
查看ospf的LSDB数据库,在AR1上查看,做为ABR应该有2个区域的lsa1-3信息以及外部重分布的lsa5和到达asbr的lsa4
[Huawei]display ospf 1 lsdb
OSPF Process 1 with Router ID 1.1.1.1
Link State Database
Area: 0.0.0.0 区域0的lsa
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 2.2.2.2 2.2.2.2 878 36 80000013 1
Router 1.1.1.1 1.1.1.1 823 36 80000015 1
Network 12.1.1.1 1.1.1.1 1565 32 8000000E 0
Sum-Net 56.1.1.0 2.2.2.2 208 28 8000000C 2
Sum-Net 34.1.1.0 1.1.1.1 634 28 8000000D 2
Sum-Net 25.1.1.0 2.2.2.2 868 28 8000000D 1
Sum-Net 13.1.1.0 1.1.1.1 803 28 8000000D 1
Sum-Asbr 34.1.1.4 1.1.1.1 611 28 8000000C 2
Sum-Asbr 6.6.6.6 2.2.2.2 208 28 8000000B 2
Area: 0.0.0.1 区域1的lsa
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 34.1.1.4 34.1.1.4 754 36 8000000F 1
Router 13.1.1.3 13.1.1.3 638 48 80000014 1
Router 1.1.1.1 1.1.1.1 716 36 80000011 1
Network 34.1.1.3 13.1.1.3 638 32 8000000E 0
Network 13.1.1.1 1.1.1.1 716 32 8000000E 0
Sum-Net 12.1.1.0 1.1.1.1 803 28 8000000D 1
Sum-Net 56.1.1.0 1.1.1.1 207 28 8000000C 3
Sum-Net 25.1.1.0 1.1.1.1 803 28 8000000D 2
Sum-Asbr 6.6.6.6 1.1.1.1 207 28 8000000B 3
AS External Database 外部重分布的lsa5和到达asbr的lsa4
Type LinkState ID AdvRouter Age Len Sequence Metric
External 6.6.6.6 6.6.6.6 235 36 8000000C 1
External 4.4.4.4 34.1.1.4 754 36 8000000C 1
External 34.1.1.0 34.1.1.4 754 36 8000000C 1
External 56.1.1.0 6.6.6.6 235 36 8000000C 1
[Huawei]
在AR4上查看lsa信息库
[Huawei]display ospf 1 lsdb
OSPF Process 1 with Router ID 34.1.1.4
Link State Database
Area: 0.0.0.1 area1的lsa信息
Type LinkState ID AdvRouter Age Len Sequence Metric
Router 34.1.1.4 34.1.1.4 1078 36 8000000F 1
Router 13.1.1.3 13.1.1.3 964 48 80000014 1
Router 1.1.1.1 1.1.1.1 1044 36 80000011 1
Network 34.1.1.3 13.1.1.3 964 32 8000000E 0
Network 13.1.1.1 1.1.1.1 1044 32 8000000E 0
Sum-Net 12.1.1.0 1.1.1.1 1132 28 8000000D 1
Sum-Net 56.1.1.0 1.1.1.1 531 28 8000000C 3
Sum-Net 25.1.1.0 1.1.1.1 1132 28 8000000D 2
Sum-Asbr 6.6.6.6 1.1.1.1 531 28 8000000B 3
AS External Database 外部lsa信息
Type LinkState ID AdvRouter Age Len Sequence Metric
External 4.4.4.4 34.1.1.4 1078 36 8000000C 1
External 34.1.1.0 34.1.1.4 1078 36 8000000C 1
External 6.6.6.6 6.6.6.6 560 36 8000000C 1
External 56.1.1.0 6.6.6.6 560 36 8000000C 1
[Huawei]
在AR1上查看AR4上重分布的type2路由和AR6上重分布的type1的路由的cost(metric)的区别
[Huawei]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
4.4.4.4/32 O_ASE 150 1 D 13.1.1.3 GigabitEthernet0/0/1 默认的type2,cost固定为1
6.6.6.6/32 O_ASE 150 4 D 12.1.1.2 GigabitEthernet0/0/0 非默认的type1真实的cost值
25.1.1.0/24 OSPF 10 2 D 12.1.1.2 GigabitEthernet0/0/0
34.1.1.0/24 OSPF 10 2 D 13.1.1.3 GigabitEthernet0/0/1
56.1.1.0/24 OSPF 10 3 D 12.1.1.2 GigabitEthernet0/0/0
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
[Huawei]
上一篇: 剑指offer 47:不用加减乘除做加法
下一篇: 剑指offer-47.不用加减乘除做加法