OSPF knowledge summary and configuration-super detailed! !

1. Overview of OSPF routing protocol

1. Interior gateway protocol and exterior gateway protocol

  • Autonomous System (AS)
  • Interior Gateway Protocol (IGP): rip, ospf, etc.
  • External Gateway Protocol (EGP): bgp, etc.

2. The working process of OSPF

  • Neighbor list
  • Link state database
  • Routing table
    Insert picture description here

2. OSPF application environment

1. Consider the use of OSPF from the following aspects

  1. Network size
  2. Network topology
  3. Other special requirements
  4. Router requirements

2. Features of OSPF

  1. Adaptable to large-scale networks
  2. Fast convergence of route changes
  3. No routing loop
  4. Support variable length subnet mask VLSM
  5. Support area division
  6. Supports sending protocol messages with multicast addresses

Insert picture description here

Three, OSPF basic concepts

OSPF area

  • In order to adapt to large-scale networks, OSPF divides multiple areas within the AS
  • Each OSPF router only maintains the complete link state information of the area where it is located
  1. Area ID
  • The area ID can be expressed as a decimal number
  • It can also be expressed as an IP
  1. Backbone area Area 0
  • Responsible for the dissemination of routing information between regions
  1. Non-backbone area
  • Intercommunication between non-mainland areas must pass through the backbone area
    -standard area
    -peripheral area stub
    -completely peripheral area total stub
    -non-pure remote area nssa

Insert picture description here
Insert picture description here

OSPF routing type

  • Inter-area router: ABR
  • Homemade system border router: ASBR
    Insert picture description here

Reasons for generating OSPF multi-area

  • Improve network scalability
  • Fast convergence

Router ID

The IP address that uniquely identifies the router in the OSPF area

Router ID selection rules

  1. Select the IP address with the highest value on the router loopback interface
  2. If there is no loopback interface, select the physical port with the highest IP address
  3. You can also use the router-id command to specify the Router ID
  4. DR and BDR election methods

Election of DR and BDR

1. Automatic election of DR and BDR

  • The router with the largest Router lID on the network segment will be elected as the DR, and the second largest router will be elected as the BDR

2. Manually select DR and BDR

  • The priority range is 0~255, the larger the value, the higher the priority, the default is 1
  • If the priority is the same, you need to compare the Router ID
  • If the priority of the router is set to 0, it will not participate in the election of DR and DBR

3. The election process of DR and BDR

  • The priority of a router can affect an election process, but it cannot force an existing DR or BDR router to be replaced
    Insert picture description here

Insert picture description here

OSPF multicast address

224.0.0.5
224.0.0.6

  1. When DRothers sends DBD, LASR or Lsu to DR/BDR, the target address is 224.0.0.6 (AllDRouter); or understood as: DR/BDR detection 224.0.0.6
  2. When DR/BDR sends updated DBD, LSR or Lsu to DRothers, the target address is 224.0.0.5 (AllSPFRouter), or understood as: DRothers listens to 224.0.0.5

metric

  • OSPF metric cost (cost) = 10OM/BW (port bandwidth)
    -The shortest path is calculated based on the generation (cost path cost) specified by the interface
  • R and P is the number of hops

OSPF packet types

Carried in lIP data packet, using protocol number 89

OSPF packet types:

OSPF packet type description
Hello bag Used to discover and maintain neighbor relationships, elect DR and BDR
Database Description Package (DBD) Used to send summary information to neighbors to synchronize the link state database
Link State Request Packet (LSR) After the router receives the DBD containing new information, it is sent to request more detailed information
Link State Update Package (LsU) Send link state advertisement (LSA) after receiving LSR, one LSU packet may contain several LSAs
Link status confirmation packet (LSAck) Confirm that the DBD/LSU has been received, and each LSA needs to be confirmed separately

Analysis of 7 states of OSPF protocol

  1. The first stage of OSPF startup is the process of establishing two-way communication using Hello packets
    Insert picture description here
  2. The second stage of OSPF startup is to establish a complete adjacency
    Insert picture description here

Analysis of 6 LSAs of OSPF Protocol

LSA type description
Class 1 All OSPF routers will be generated, only spread in the area
Type 2 DR is generated and only spread within the area
Class 3 ABR is generated and spreads in two adjacent areas
Type 4 ABR is generated and spread to other areas that are not in the same area as ASBR, used to represent ASBR
Category 5 The ASBR is generated and propagated to the entire OSPF protocol area to describe the routing information of another protocol domain
Category 7 The ASBR in the NSSA area is generated to advertise external routes to the NSSA area

LSAs that allow flooding in each area

Area type 1&2 3 4&5 7
Backbone area (area O) allow allow allow Not allowed
Non-backbone area, non-peripheral allow allow allow Not allowed
Peripheral area allow allow Not allowed Not allowed
Complete peripheral area allow Not allowed* (except for a default route) Not allowed Not allowed
NSSA area allow allow Not allowed allow

The role of OSPF address summary

  • Address aggregation also saves resources by reducing the number of flooded LSAs
  • You can save resources by shielding some details of unstable network
  • Reduce routing entries in the routing table

Four, OSPF configuration command example

1. General arrangement

[R1]int g0/0/0     ###记置接口ip地址
[R1-GigabitEthernet0/0/0]ip add 11.0.0.2 24
[Rl-GigabitEthernet0/0/o]un sh
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/1]un sh
[R1-GigabitEthernet0/0/1]int lo o
[R1-LoopBack0]ip add 1.1.1.1 32
[R1-LoopBack0]ospf 1 router-id 1.1.1.1     ###创建OSPF进程,配置路由ID
[R1-ospf-1]area 1     ###进入区域1,区域ID可以用数字表示,也可以用IP表示,若区域o则是骨干区域
[R1-ospf-1-area-0.0.0.1]network 12.0.0.0 0.255.255.255   ## 宣告直连
[R1-ospf-1-area-0.0.0.1]network 1.1.1.1 0.0.0.0    ##宣告oSPF区域内的直连网段,使用反掩码
------------------------------------------------------------------------
<Huawei>reset ospf process    ###重置oSPF进程

2. Optimize configuration

The function of the stub area and the complete stub area is to reduce the LSa entries and routing entries in the area, and reduce the occupation of CPu and memory of the device; the
ABR in the stub area and the complete stub area will automatically generate a default route and advertise to the stub area Or completely in the peripheral area.

———–——–Stub area configuration commands (configured on ABR and intra-area routes) ———–——–No LSA4, 5, 7 advertisement


[R4]ospf 1
[R4-ospf-1]area 2
[R4-ospf-1]network x.x.x.x  x.x.x.x   ###先宣告直连网段,再配优化
[R4-ospf-1-area-0.0.0.2]stub
[R5]display ip routing-table   ###此时未梢区域中的路由会显示一条默认路由到外部区域

———————–Completely stub area configuration commands (configured on ABR and intra-area routes)————–——–Except for an LSA3 default route advertisement, there is no LSA3, 4, 5, 7 advertisement

[R4]ospf 1
[R4-ospf-1]area 2
[R4-ospf-1]network x.x.x.x x.x·x.x   ###先宣告直连网段,再配优化
[R4-ospf-1-area-0.0.0.2]stub no-summary
[R5]display ip routing-table    ###此时完全末梢区域中的路由会显示一条默认路由到除本区域外的其他区域

——————- Completely non-pure stub area or configuration command {ABR and intra-area routing (except ASBR) configuration} ———————–No LSA4, 5 notification

[R4]ospf 1
[R4-ospf-1]area 1
[R4-ospf-1]network x.x.x.x x.x.x.x         #先宣告直连网段,再配优化
[R4-ospf-1-area-o.0.0.1]nssa no-summary    ###ABR配置
----------------------------------------------------------------------------
[R4-ospf-1-area-o.o.o.1]nssa     ###域内路由配置

3. Verify the command

display ospf 1 peer brief   ###查看本地设备上的OSPF 1的相关信息
display ospf 1 peer    ###查看路由表中的OSPF路由(确定路由器的类型和属性)
display ospf 1 brief    ###查看oSPF邻居表的简要信息
display ip routing-table    ###查看oSPF邻居表的详细信息
display ospf routing
display ospf interface GigabitEthernet 0/0/o

4. View LSA commands

[Huawei]dis ospf lsdb router
[Huawei]dis ospf lsdb network
[Huawei]dis ospf lsdb summary
[Huawei]dis ospf lsdb asbr
[Huawei]dis ospf lsdb ase
[Huawei]dis ospf lsdb nssa

5. Modify the interface preference set of oSPF routing, the default value is 1

[R1]int g0/0/0
[Rl-GigabitEthernet0/0/0]ospf dr-priority 1O

6. OSPF route redistribution configuration commands

[R1]rip 1###配置rip
[Rl-rip-l]version 2
[Rl-rip-l]undo summary
[Rl-rip-1]network 11.0.0.o
[Rl-rip-1]import-route ospf 1cost3   ###把ospf协议注入到rip进行路由重分发,路径类型缺省为路径类型2(外部开销),成本开销为3(对于rip的度量值是跳数),rip中重分发ospf要指定metric的值
[Rl-rip-1]ospf 1
[R1-ospf-1]import-route rip 1 type 1 cost 1   ##1把外部rip协议注入到oSPE进行路由重分发,使用路径类型1(内部开销+外部开销),成本开销为1(COST=10OM/BW)
-------------------------------------------------------------------------------------------
[Rl-ospf-1]default-route-advertise always   ###ospf重分发默认路由
[R2-ospf-l]import-route direct     ###ospf重分发直连路由
[R2-ospf-1]import-route static     ###ospf重分发静态路由

7. Inter-area route summary configuration

———–——–OSPF address summary calculation example————–——–

192.168.1.0/24—转换二进制 ——192.168.00000 001.0 /24
192.168.2.0/24—————————————192.168.00000 010.0/24
192.168.3.0/24—————————————192-168.00000 011.0/24
192.168.4.0/24—————————————192.168.00000 100.0/24
192.168.5.0/24—————————————192.168.00000 101.0/24
192.168.6.0/24—————————————192.168.00000 111.0/24
将二进制地址分成两部分(完全相同的前半部分和存在差异的后半部分),数出前半部分的位数(这里的192.168.00000为21位)
则汇总后的结果为:192.168.00000 000/21

———–——– Inter-area route summary configuration (configured on ABR) ———————————————–

[R4]ospf l
[R4-ospf-l]area 2
[R4-ospf-1]abr-summary 192.168.0.0 255.255.248.0

———–——– External route summary configuration (configured on ASBR) ———————————————–

[R5]ospf l
[R5-ospf-1]area 2
[R5-ospf-1]asbr-summary 10.0.o.0 255.248.0.o

8. Virtual link configuration

  • The non-backbone area must be directly connected to the backbone area. If it is not directly connected to the backbone area, a virtual link needs to be configured between two ABRs that traverse a non-backbone area.
  • The establishment of a virtual link depends on the area where the underlying real link is located for transmission
  • OSP: Message (hello etc.). Therefore, if the traversal transmission area of ​​the bottom layer is unstable, the virtual link of the upper layer is unstable, which affects the stability of the backbone area of ​​the entire network. Therefore, this method is generally not recommended. If you have to use it, it is only a temporary solution.

———————– Configure virtual links in the two ABRs of the non-backbone area being traversed————–——–

-[R2]ospf 1
[R2-ospf-1]area 1
[R2-ospf-l-area-o.o.0.1]vlink-peer 1.1.1.1   ###相指定被穿越区域两端ABR的路由ID
----------------------------------------------------------------------------
[Rl]ospf 1
[Rl-ospf-1]area 1
[R1-ospf-1-area-0.0.0.1]vlink-peer 2.2.2.2    ###相指定被穿越区域两端ABR的路由ID
[R1]display ospf vlink    ###查看本地上通过虚链路建立的oSPF邻居关系

Guess you like

Origin blog.csdn.net/CN_LiTianpeng/article/details/108911558