OSPF (SPF)

   A link-state routing protocol, and a public standard,

   In theory there is no network size restrictions;

   The hierarchical design support network, the network can be divided into two layers.

    Layer is to be distinguished by the concept of "region".

        - backbone area

        - non-backbone area

           All non-backbone must be directly connected to the backbone in order to communicate.

           

    Router because of a region and are divided into different types:

        - backbone routers

                All links are all routers in the backbone area;

        - non-backbone router

                All links are all non-backbone routers area;

        - Area Border Router (*) [ABR: area border router]

               It must be connected to the backbone region and a non-backbone areas;

        - [autonomous system border router ASBR:]

                Router has the ability to import external routes, called the OSPF ASBR.

  -working principle

      1, set up the neighbor table

            Only use hello packets.

            OSPF routing, only exchanged between routers OSPF neighbors;

                        

         

            Neighbor state:

                 down

                 init

                 2way

                 Exstart(exchange start)

                 exchange

                 loading

                 full          

     

      

      2, database synchronization

              LSA-link state advertisement, LSA;

      

      

      3, routing table calculation (for LSA calculated by the SPF algorithm, to obtain the final routing entry)      

  -OSPF message:

        hello:

        dbd: database description, database description packets;

        lsu: link state update, the link state update packet;

        lsr: link state request, link state request packet;

        lsack: link state ack, link state acknowledgment packets;

1, configure OSPF

    [R1] ospf [process-id] // not write, the default is 1;

    [R1-ospf-1] area 0 // 0 entry region;

    [R1-ospf-1-area-0.0.0.0] network 192.168.12.1 0.0.0.0

                          // declare exactly where the link 192.168.12.1

      The OSPF 0;

      So gi0 / 0/0, then enable OSPF 1:

      Ospf packet # 1 can be transmitted;

      # 1 may receive a packet ospf;

      # The IP address can be in port

      Network part, into an OSPF packet 1, the transmission out to the neighboring routers.

 2, verification

  display ospf [1] peer brief // Check brief OSPF neighbor information table;

  display ospf [1] peer // View Details OSPF neighbor table;

  display ospf [1] brief // view information on the local device OSPF 1;

  display ip routing-table // Check the OSPF routing table of

                               (Route determining types and attributes)

      

=================================================================

Factors establish OSPF neighbor:

1, to ensure a minimum range of Ping the links are mutually; (exchange)

       R 1: R 2 Ping;

       R 2: R 1 Ping;

2, ensure that the port can send packets device;

       #network to declare the correct network range;       

       # Make sure the receiving port OSPF packet can not be "passive port - silent-interface"

         (OSPF silent-interface on the device Huawei, neither send nor receive packet)

         ospf 1  

           silent-interface gi0/0/0         

3, to ensure that the port device can receive packets;

       #network to declare the correct network range;

       # Ensure that the ACL is to allow OSPF traffic;

       # Make sure the receiving port OSPF packet can not be "passive port - silent-interface"

         (OSPF silent-interface on the device Huawei, neither send nor receive packet)

  R1:

  acl name Deny-OSPF advance

  rule 5 deny ospf source 192.168.12.2 0.0.0.0 destination 224.0.0.5    0.0.0.0

  interface gi0/0/0

         traffic-filter inbound acl name Deny-OSPF

                          

4, the key parameters to ensure consistent OSPF Hello packet; hello parameters [Comparative]

       # Router neighbor establish direct relations, RID must not be the same;

   [R1] ospf 1 router-id xxxx // use specified RID OSPF 1

     <R1> reset ospf 1 process // restart OSPF 1, to take effect;

       ID # must be the same region;

              [R1]ospf 1

              [R1-OSPF-1]area 0

              [R1-OSPF-1-area-0.0.0.0]undo network 192.168.12.1 0.0.0.0

              [R1-OSPF-1]undo area 0

              [R1-OSPF-1]area 1

              [R1-OSPF-1-area-1]network 192.168.12.1 0.0.0.0

       # Authentication must succeed;

       # The subnet mask must have the same (exceptional circumstances)    

       # Hello time, must be the same;

             [R1]interface gi0/0/0

             [R1-gi0 / 0/0] changes when the hello, dead ospf timer hello 20 // follow the change, the relationship between the multiple is four times;

       # Dead time, it must be the same;

             [R1]interface gi0/0/0

   [R1-gi0 / 0/0] ospf timer dead time changes dead, hello // 41 unchanged;

       # Special flag bit must be exactly the same;

       # DR priority, not all 0; (special cases)

             [R1]interface gi0/0/0

             [R1-gi0/0/0]ospf dr-priority 0

       Layer # 3 MTU, exactly the same;

       

Verify command:

         display ospf peer brief // Check OSPF neighbor table

         display ospf interface gi0 / 0/0 // View OSPF interface;

Lab topology:

Experimental Procedure:

<Huawei>sys

[Huawei] inter gi 0/0/0

[Huawei-GigabitEthernet0/0/0]undo shutdown

Configuring IP

[Huawei-GigabitEthernet0/0/0]ip address 192.168.12.1 255.255.255.0

[Huawei-GigabitEthernet0/0/0]q

The ospf

[Huawei]ospf  

[Huawei-ospf-1]area 0    

[Huawei-ospf-1-area-0.0.0.0]network 192.168.12.1 0.0.0.0

[Huawei-ospf-1-area-0.0.0.0]q

[Huawei-ospf-1]q

[Huawei]q

<Huawei>sys

Test whether to ping

[Huawei] ping 192.168.12.2

  PING 192.168.12.2: 56  data bytes, press CTRL_C to break

    Reply from 192.168.12.2: bytes=56 Sequence=1 ttl=255 time=30 ms

    Reply from 192.168.12.2: bytes=56 Sequence=2 ttl=255 time=20 ms

    Reply from 192.168.12.2: bytes=56 Sequence=3 ttl=255 time=20 ms

    Reply from 192.168.12.2: bytes=56 Sequence=4 ttl=255 time=20 ms

    Reply from 192.168.12.2: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 192.168.12.2 ping statistics ---

    5 packet(s) transmitted

    5 packet(s) received

    0.00% packet loss

    round-trip min/avg/max = 20/22/30 ms

Check whether to establish adjacency

[Huawei]dis ospf peer

       OSPF Process 1 with Router ID 192.168.12.1

             Neighbors

 Area 0.0.0.0 interface 192.168.12.1(GigabitEthernet0/0/0)'s neighbors

 Router ID: 192.168.12.2     Address: 192.168.12.2   

   State: Full  Mode:Nbr is  Master  Priority: 1

   DR: 192.168.12.1 BDR: 192.168.12.2 MTU: 0   

   Dead timer due in 40  sec

   Retrans timer interval: 5

   Neighbor is up for 00:00:35    

   Authentication Sequence: [ 0 ]

 Configuring passive port gi0 / 0/0 neither close nor contract

[Huawei]acl name ospf-1 advance

[Huawei-acl-adv-ospf-1]rule 5 deny ospf source 192.168.12.2 0.0.0.0 destination 224.0.0.5 0.0.0.0

[Huawei-acl-adv-ospf-1]q

[Huawei] inter gi 0/0/0

[Huawei-GigabitEthernet0/0/0]traffic-filter inbound acl 3999

[Huawei-GigabitEthernet0/0/0]q

View success

[Huawei]dis ospf

Jan 16 2018 19:32:37-08:00 Huawei %%01OSPF/3/NBR_CHG_DOWN(l)[0]:Neighbor event:n

eighbor state changed to Down. (ProcessId=256, NeighborAddress=2.12.168.192, Nei

ghborEvent=InactivityTimer, NeighborPreviousState=Full, NeighborCurrentState=Dow

n)

Router Configuration 2

<Huawei>sys

[Huawei] inter gi 0/0/0

   

[Huawei-GigabitEthernet0/0/0]undo shutdown

Configuring IP port

[Huawei-GigabitEthernet0/0/0]ip address 192.168.12.2 255.255.255.0

[Huawei-GigabitEthernet0/0/0]q

The ospf

[Huawei]ospf  

[Huawei-ospf-1]area 0    

[Huawei-ospf-1-area-0.0.0.0]network 192.168.12.2 0.0.0.0

[Huawei-ospf-1-area-0.0.0.0]q

[Huawei-ospf-1]q

[Huawei]q

result: