OSPF
Full name: Open Shortest Path Firs
1, Basic concepts
1) Basic information
Multicast sending: 224.0.0.5/6
Standard link state routing protocol -- transfer topology between routers
Version: ospfv2 -- IPv4 -- OSPFv3 -- IPv6
Update method: trigger update; There is an update cycle of 30min
OSPF network needs structured deployment: 1. Region division 2. IP address planning
Distance vector characteristics of link state routing protocols -- intra region transmission topology and inter region transmission routing table
Priority 10 cost value = reference bandwidth ÷ interface bandwidth
2) OSPF packet
hello package: used to discover, establish and keep alive (10s) neighbor relationships. There is a unique router ID in the whole network, which is used for the identity of the router and expressed in the form of IP address.
DD package: Database Description.
LSR: link status request.
LSU: link status update.
LSAck: link status confirmation.
3) OSPF state machine:
down: protocol not started. Once the protocol is started and the hello package is issued, the next state is entered immediately
init: the state of waiting for a reply from a neighbor. If the received hello package carries its own RID, it will enter the next state together with the other party
2-way: indicates the establishment of neighbor relationship
Condition matching: if successful, enter the next status; If it fails, only the hello package is kept alive
exstart: pre start, compare RID with fake DD message, and the larger one has priority to enter the next state.
exchange: DD message exchanged by both parties
loading: use LSR/LSU/LSAck to obtain unknown path topology or route
full: the adjacency relationship is established and the convergence is completed
4) OSPF working process
After starting the protocol, the local device sends out hello packets based on 224.0.0.5 multicast, finds and establishes neighbor relationships, and generates neighbor tables;
After that, condition matching is carried out. If it is successful, it will enter the next state; If it fails, only the hello package will be kept alive for 10s.
The one with the higher RID has the priority to enter the next state. First exchange the DD, and then use LSR/LSU/LSACK to collect the unknown LSA and generate LSDB -- database table
Based on this LSDB, the device uses the SPF algorithm to calculate the best path to the target, generate a routing table, and complete the convergence.
Keep alive for 10s and compare DD periodically for 30min
Network structure changes:
1. Add & disconnect: the equipment with direct connection changes can be improved through DBD/LSR/LSU/LSACK.
2. The device cannot communicate: hello 10s keep alive dead time 40s -- after the timing is over, delete the neighbor relationship and all paths learned from the neighbors.
Explanation of terms:
LSA: link status announcement - topology information or route information sent in OSPF
LSDB: link state database, a collection of LSA S
5) Area division rules:
1. You must have area 0 (backbone area), and all non backbone areas must be directly connected to the backbone area.
2. Must have ABR -- area boundary router.
6) OSPF routing rules:
If there are multiple paths to a certain target, it is preferred to select the path with the smallest sum of Cost through the control interface
Control level: the direction of the origin of the road; Data level: the direction of data going
When the bandwidth is greater than the reference bandwidth, it will lead to poor channel selection.
In the routing table:
All paths calculated by OSPF are represented by OSPF; OSPF priority is 10; Cost = reference bandwidth ÷ input interface bandwidth. By default, the reference bandwidth is 100Mbits / s < --- > note the unit.
It can be solved by modifying the reference bandwidth. Note: the modification of the reference bandwidth needs to be consistent across the network.
7) A. conditions for becoming adjacency relations -- focus on network types
Point to point: there can only be two nodes in a network --- string line -- > if it is a point-to-point network type, the adjacency relationship will be established directly from the neighbor relationship.
MA (multiple access): there is no limit on the number of nodes in a network -- Ethernet -- > if the network type is Ma, the DR/BDR role needs to be elected. In order to eliminate repeated updates, the election time is 40s. All other routers without defined roles become DROther
B. Relationship among DR, BDR and other
DR and DROther are adjacency; BDR and DROther are adjacency; DROther and DROther are neighbors; DR and BDR are adjacency
C. election rules:
1. Interface priority: by default, the interface priority of all routers is 1, which is superior
2. Compare the advantages of router ID
D. DR/BDR election is non preemptive; You can control the election by modifying the priority of the interface of the equipment participating in the election. You can change the priority of the interface to 0 and it will take effect directly. However, all interface priorities cannot be changed to 0.
8) Extended configuration
1. Default route: configured on the border router connecting the operator - non mandatory distribution default: if you want to distribute successfully, there must be a default route in your own routing table.
2. Silent interface: only receive but not send OSPF packets. It is generally used to connect the user's interface, and it is prohibited to use it for the interface between routers
2, OSPF configuration
Basic configuration
[r1]ospf 1 router-id 1.1.1.1 //Start the protocol and configure the process number. At the same time, you can choose to configure the RID of the router. If it is not configured, the router can choose by itself, and the loopback interface is the largest>Maximum physical interface Announcement: 1. Activate interface 2. Publish topology or route 3. Region division [r1-ospf-1]area 0 //Access area [r1-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255 Unmask Unmask: 32-bit binary, expressed in dotted decimal system, composed of continuous 0 and continuous 1. If the unmask is 0, it means IP The corresponding bit is fixed; If it is 1, it means variable.
Modify bandwidth:
[r1]ospf 1 [r1-ospf-1]bandwidth-reference ? INTEGER<1-2147483648> The reference bandwidth (Mbits/s)---Pay attention to the unit when modifying [r1-ospf-1]bandwidth-reference 10000 //Modify reference bandwidth
Modify priority control election:
[r1]interface GigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]ospf dr-priority * //Modification priority is* <r1>reset ospf 1 process //Restart OSPF process
Default route:
Non mandatory [r1]ospf 1 [r1-ospf-1]default-route-advertise //Non mandatory distribution default force [r1]ospf 1 [r1-ospf-1]default-route-advertise always //Forced distribution default
Silent interface:
[r1]ospf 1 [r1-ospf-1]silent-interface GigabitEthernet 0/0/1 //Silent interface
Neighbor table:
After the device starts OSPF, use 224.0.0.5 to send a hello package, discover and establish a neighbor relationship, and generate a neighbor table;
<r1>display ospf peer brief //View neighborhood summary OSPF Process 1 with Router ID 2.2.2.2 //Own information Peer Statistic Information ---------------------------------------------------------------------------- Area Id Interface Neighbor id State 0.0.0.0 GigabitEthernet0/0/1 1.1.1.1 Full 0.0.0.1 GigabitEthernet0/0/2 3.3.3.3 Full ---------------------------------------------------------------------------- Neighbor's area ID Local connection neighbor interface Neighbor's RID Status of and neighbors In Huawei equipment OSPF region ID Representation of: Neighbor's area ID: area 0--->0.0.0.0 area 12345--->0.0.48.57
LSCB table:
When the device uses DD/LSR/LSU/LSAck data packet to collect all unknown LSAS, LSDB -- link state database table (set of LSAS) is generated locally
<r1>display ospf lsdb //View local LSDB table OSPF Process 1 with Router ID 1.1.1.1 Link State Database Area: 0.0.0.0 Type LinkState ID AdvRouter Age Len Sequence Metric Router 2.2.2.2 2.2.2.2 502 48 80000007 1 Router 1.1.1.1 1.1.1.1 863 48 80000006 1 Network 172.16.4.1 1.1.1.1 863 32 80000002 0 Sum-Net 172.16.3.0 2.2.2.2 796 28 80000001 2 Sum-Net 172.16.5.0 2.2.2.2 856 28 80000001 1
Routing table:
Based on the local LSDB, the SPF algorithm is used to calculate the best path to the target network segment and generate the routing table.
<r1>display ip routing-table protocol ospf //View only the routing entries learned by OSPF Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 3 Routes : 3 OSPF routing table status : <Active> Destinations : 3 Routes : 3 Destination/Mask Proto Pre Cost Flags NextHop Interface 172.16.2.0/24 OSPF 10 2 D 172.16.4.2 GigabitEthernet0/0/1 172.16.3.0/24 OSPF 10 3 D 172.16.4.2 GigabitEthernet0/0/1 172.16.5.0/24 OSPF 10 2 D 172.16.4.2 GigabitEthernet0/0/1 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0
VLAN
1. Concept: virtual LAN, isolation of broadcast domain (logically dividing the original broadcast domain into multiple broadcast domains) -- by creating different VLANs on the switch and dividing the impassable interfaces into corresponding VLANs, the switch can send data according to different VLANs during flooding to realize the isolation of broadcast domain. VLAN 1 exists on the default switch, and all interfaces belong to VLAN 1 by default
2. Configuration Basics
1. Create VLAN
(range of VLAN creation: 1-4094)
[sw1]vlan 10 //Create separately [sw1]vlan batch ** to ** //Batch create * * - * * VLAN [sw1]display vlan //Check the vlan and the ownership of the interface [sw1]display vlan summary //View the created summary
2. Interface into VLAN
access: if an interface is set to this type, it can only belong to one VLAN, which is generally used to connect the user's interface.
*****The first configuration mode***** [sw1]interface GigabitEthernet 0/0/1 //Access interface [sw1-GigabitEthernet0/0/1]port link-type access Link type access type [sw1]interface GigabitEthernet 0/0/2 [sw1-GigabitEthernet0/0/2]port link-type access [sw1-GigabitEthernet0/0/2]port default vlan 10 *****The second configuration method (the interface type must be modified to access)***** [sw1]vlan 10 [sw1-vlan10]port GigabitEthernet 0/0/1 ************************ [sw1]interface range g 0/0/3 to g 0/0/10 //Batch entry interface [sw1-GigabitEthernet0/0/2]port link-type access [sw1-GigabitEthernet0/0/2]port default vlan 10
3. TRUNK road
Trunk: if an interface type is changed to trunk, the interface does not belong to any VLAN, but allows all VLAN data to pass through (by default, all VLANs cannot pass through, and the VLAN number allowed to pass through needs to be manually specified).