Table of contents
1. OSPF related configuration commands
1. Cisco device configuration commands
(1) Start the OSPF routing process
(4) Configure the passive interface
(5) Configure an area as a stub area
(6) Configure an area as a completely stub area
(7) Configure a certain area as a sub-segment area
(8) Note the default route to the OSPF network
(9) Configure OSPF inter-area route summary
(10) Configure external route summary
(11) Modify the value of the reference bandwidth
(12) Modify the number of equivalent paths supported by OSFP
(13) Configure the hello sending cycle of OSPF
(14) Configure OSPF neighbor death time
(15) Configure the interface cost value
(16) Configure interface priority
(17) Configure the interface network type
(18) Configure OSPF authentication
2. Huawei device configuration commands
(2) Configure the OSFP protocol
(3) Configure the network segment
(6) Configure Hello message interval
(7) Configure the maximum number of connections allowed
(9) Configuring OSFP Adaptive Devices
(1) Configure the router interface IP address
(3) Enable the routing function of the Layer 3 switch
(5) Configure OSPF manual route summary
(6) Configure passive interface
(7) Configure a completely stubby area
(8) Configure to inject default routes into the OSPF network
1. OSPF related configuration commands
1. Cisco device configuration commands
(1) Start the OSPF routing process
Router(config)#router ospf 进程ID
(2) Activate the interface participating in the OSPF routing protocol, and notify the OSPF of which area the structure belongs to
Router(config)#network 地址通配符掩码 area 区域ID号
(3) Configure router ID
Router(config-router)# router-id a.b.c.d
(4) Configure the passive interface
Router(config-router)#passive-inteface 接口
(5) Configure an area as a stub area
Router(config-router)#area 区域ID stub
(6) Configure an area as a completely stub area
Router(config-router)#area 区域ID stub no-summary
(7) Configure a certain area as a sub-segment area
Router(config-router)#default 区域ID nssa [no-summary]
(8) Note the default route to the OSPF network
Router(config-router)#default-information originate [always]
(9) Configure OSPF inter-area route summary
Router(config-router)#area 区域ID range 地址掩码
(10) Configure external route summary
Router(config-router)#summary-address 地址掩码
(11) Modify the value of the reference bandwidth
Router(config-router)#auto-cost referrnce-bandwidth 带宽值
带宽值取值范围:1——4294967,默认100,单位兆字节
(12) Modify the number of equivalent paths supported by OSFP
Router(config-router)#maximum-paths 等价路径条数
(13) Configure the hello sending cycle of OSPF
Router(config-if)#ip osfp hello-interval 秒数
默认快速链路的hello发送周期为10s
(14) Configure OSPF neighbor death time
Router(config-if)#ip osfp dead-interval 秒数
默认死亡时间为hello周期的4倍
(15) Configure the interface cost value
Router(config-if)#ip ospf cost cost值
(16) Configure interface priority
Router(config-if)#ip ospf priority 优先级
取值范围0-255
(17) Configure the interface network type
Router(config-if)#ip ospf network 类型
(18) Configure OSPF authentication
(1)启动基于区域的验证
Router(config-router)#area 区域ID authentication [message-digest]
# message-digest是可选项,如果选择,则采用MD5验证,不采用则采用简单的口令验证
(2)设置简单口令验证密码
Router(config-if)#ip ospf authentication-key 密码
(3)设置MD5验证密码
Router(config-if)#ip ospf message-digest-key keyID MD5 密码
# keyID范围是1-255
(4)启动基于链路的简单口令验证
Router(config-router)#ip ospf authentication
(5)启动基于链路的MD5验证
Router(config-router)#ip ospf authentication message-digest
2. Huawei device configuration commands
(1) Open OSFP
>router ospf enable
(2) Configure the OSFP protocol
>router ospf (进程ID)
(3) Configure the network segment
>area (区域ID)
network (网络地址) mange (掩码)
(4) Configure router ID
>router ospf (进程ID)
>router-id (路由ID)
(5) Configuration priority
>router ospf (进程ID)
>priotity 优先级
(6) Configure Hello message interval
>router ospf (进程ID)
>hello-interval (时间间隔)
(7) Configure the maximum number of connections allowed
>router ospf (进程ID)
>max-neighors (最大连接数)
(8) Configure OSFP summary
>router osfp (进程ID)
>summary (area | abr | asbr |prefix) (网络地址) (掩码)
(9) Configuring OSFP Adaptive Devices
>router osfp (进程ID)
>adaptive (设备类型)
2. Configuration example
Cisco Configuration Example
The multi-area OSPF routing protocol is running between the Shenzhen branch of company A and the Beijing headquarters. It is required to configure OSPF routing on the routers in the two places. The topology diagram is as follows:
vlan2 (marketing department): 172.16.12.0/24
vlan3 (personnel department): 172.16.13.0/24
vlan4 (R&D department): 172.16.14.0/24
vlan5 (engineering department): 172.16.15.0/24
(1) Configure the router interface IP address
#北京1
Router1(config)# inter g0/0
Router1(config-if)# ip add 172.16.21.1 255.255.255.252
Router1(config-if)#no shu
Router1(config-if)#exit
Router1(config)#inter g0/1
Router1(config-if)#ip add 172.16.1.1 255.255.255.0
Router1(config-if)#no shu
Router1(config-if)#exit
Router1(config)#inter g0/2
Router1(config-if)#ip add 202.96.12.2 255.255.255.248
Router1(config-if)#no shu
Router1(config-if)#exit
#北京2
Router2(config)# inter g0/0
Router2(config-if)# ip add 172.16.21.2 255.255.255.252
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#inter g0/1
Router2(config-if)#ip add 172.16.23.2 255.255.255.252
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)#inter g0/2
Router2(config-if)#ip add 172.16.24.2 255.255.255.248
Router2(config-if)#no shu
Router2(config-if)#exit
Router2(config)# inter s0/1/0
Router2(config-if)# ip add 10.1.24.2 255.255.255.252
Router2(config-if)#no shu
Router2(config-if)#exit
#深圳
Router3(config)# inter g0/0
Router3(config-if)# ip add 10.1.1.1 255.255.255.0
Router3(config-if)#no shu
Router3(config-if)#exit
Router3(config)# inter s0/0/1
Router3(config-if)# ip add 10.1.24.1 255.255.255.252
Router3(config-if)#no shu
Router3(config-if)#exit
(2) Configure the IP address of the Layer 3 switch interface and the IP address of the switch virtual machine interface (SVI)
S1(config)#inter g0/1
S1(config-if)#no sw
S1(config-if)#ip add 172.16.23.1 255.255.255.252
S1(config-if)#no shu
S1(config-if)#exit
S1(config)#inter vlan 2
S1(config-if)#ip add 172.16.12.1 255.255.255.0
S1(config-if)#no shu
S1(config-if)#exit
S1(config)#inter vlan 3
S1(config-if)#ip add 172.16.13.1 255.255.255.0
S1(config-if)#no shu
S1(config-if)#exit
S1(config)#inter vlan 4
S1(config-if)#ip add 172.16.14.1 255.255.255.0
S1(config-if)#no shu
S1(config-if)#exit
S1(config)#inter vlan 5
S1(config-if)#ip add 172.16.15.1 255.255.255.0
S1(config-if)#no shu
S1(config-if)#exit
S2(config)#inter g0/2
S2(config-if)#no sw
S2(config-if)#ip add 172.16.24.1 255.255.255.252
S2(config-if)#no shu
S2(config-if)#exit
S2(config)#inter vlan 2
S2(config-if)#ip add 172.16.12.2 255.255.255.0
S2(config-if)#no shu
S2(config-if)#exit
S2(config)#inter vlan 3
S2(config-if)#ip add 172.16.13.2 255.255.255.0
S2(config-if)#no shu
S2(config-if)#exit
S2(config)#inter vlan 4
S2(config-if)#ip add 172.16.14.2 255.255.255.0
S2(config-if)#no shu
S2(config-if)#exit
S2(config)#inter vlan 5
S2(config-if)#ip add 172.16.15.2 255.255.255.0
S2(config-if)#no shu
S2(config-if)#exit
(3) Enable the routing function of the Layer 3 switch
S1(config)#ip routing
S2(config)#ip routing
(4) Configure basic OSFP
Router1(config)#router osfp 1
Router1(config-if)#network 172.16.1.1 0.0.0.0 area 0
Router1(config-if)#network 172.16.21.1 0.0.0.0 area 0
Router1(config-if)#log-adjacency-changes
Router1(config-if)#auto-cost reference-bandwidth 1000
Router2(config)#router osfp 1
Router2(config-router)#router-id 2.2.2.2
Router2(config-router)#network 10.1.24.2 0.0.0.0 area 1
Router2(config-router)#network 172.16.21.2 0.0.0.0 area 0
Router2(config-router)#network 172.16.23.2 0.0.0.0 area 2
Router2(config-router)#netwokr 172.16.24.2 0.0.0.0 area 2
Router2(config-router)#auto-cost reference-bandwidth 1000
Router3(config)#router osfp 1
Router3(config-router)#router-id 3.3.3.3
Router3(config-router)#network 10.1.1.1 0.0.0.0 area 1
Router3(config-router)#network 10.1.24.1 0.0.0.0 area 1
Router3(config-router)#auto-cost reference-bandwidth 1000
S1(config)#router osfp 1
S1(config-router)#router-id 4.4.4.4
S1(config-router)#network 172.16.12.1 0.0.0.0 area 2
S1(config-router)#network 172.16.13.1 0.0.0.0 area 2
S1(config-router)#network 172.16.14.1 0.0.0.0 area 2
S1(config-router)#network 172.16.15.1 0.0.0.0 area 2
S1(config-router)#network 172.16.23.1 0.0.0.0 area 2
S1(config-router)#auto-cost reference-bandwidth 1000
S1(config)#router osfp 1
S1(config-router)#router-id 5.5.5.5
S1(config-router)#network 172.16.12.2 0.0.0.0 area 2
S1(config-router)#network 172.16.13.2 0.0.0.0 area 2
S1(config-router)#network 172.16.14.2 0.0.0.0 area 2
S1(config-router)#network 172.16.15.2 0.0.0.0 area 2
S1(config-router)#network 172.16.24.1 0.0.0.0 area 2
S1(config-router)#auto-cost reference-bandwidth 1000
(5) Configure OSPF manual route summary
Router2(config)#router osfp 1
Router2(config-router)#area 2 range 172.16.12.0 255.255.252.0
(6) Configure passive interface
Router1(config)#router osfp 1
Router1(config-router)#passive-interface g0/1
Router3(config)#router osfp 1
Router3(config-router)#passive-interface g0/0
S1(config)#router osfp 1
S1(config-router)#passive-interface default
S1(config-router)#no passive-interface g0/1
S1(config)#router osfp 1
S1(config-router)#passive-interface default
S1(config-router)#no passive-interface g0/2
(7) Configure a completely stubby area
Router2(config)#router osfp 1
Router2(config-router)#area 2 stub no-summary
S1(config)#router osfp 1
S1(config-router)#area 2 stub
S2(config)#router osfp 1
S2(config-router)#area 2 stub
(8) Configure to inject default routes into the OSPF network
Router1(config)#ip router 0.0.0.0 0.0.0.0 g0/2 202.96.12.1
Router1(config)#router ospf 1
Router2(config-router)#default-information originate
(9) Control DR election
Router2(config)#inter range g0/0-2
Router2(config-router)#ip ospf priority 2