-
Next_Hop attribute
The Next_Hop attribute records the next hop information of the route. The next hop attribute of BGP is different from that of IGP and is not necessarily the IP address of the neighbor device. Normally, the Next_Hop attribute follows the following rules:
-
When the BGP Speaker advertises a route to an EBGP peer, it will set the next hop attribute of the route information to the address of the interface that establishes a BGP neighbor relationship between the local and the peer.
-
When the BGP Speaker advertises a locally originated route to an IBGP peer, it will set the next hop attribute of the route information to the address of the interface that establishes a BGP neighbor relationship between the local and the peer.
-
When the BGP Speaker advertises the route learned from the EBGP peer to the IBGP peer, it does not change the next hop attribute of the routing information.
-
Experimental topology diagram
Experimental steps
All router IP configurations
R1 IP configuration <Huawei>system-view Enter system view, return user view with Ctrl + Z. [Huawei]sysname R1 [R1]interface GigabitEthernet 0/0/0 [R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24 Nov 8 2023 18:05:04-08:00 R1 % IFNET/4/LINK_STATE(l)[2]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state. [R1-GigabitEthernet0/0/0]quit [R1]undo info-center enable Info: Information center is disabled. [R1]interface GigabitEthernet 0/0/1 [R1-GigabitEthernet0/0/1]ip address 192.168.2.1 24 [R1-GigabitEthernet0/0/1]quit \t [R1]interface LoopBack 0 [R1-LoopBack0]ip address 172.16.1.1 32 [R1-LoopBack0]quit \t\t [R1]interface LoopBack 1 [R1-LoopBack1]ip address 172.16.11.11 32 [R1-LoopBack1]quit R2 IP configuration <Huawei>system-view Enter system view, return user view with Ctrl + Z. [Huawei]sysname R2 [R2]undo info-center enable Info: Information center is disabled. [R2]interface g0/0/0 [R2-GigabitEthernet0/0/0]ip address 192.168.1.2 24 [R2-GigabitEthernet0/0/0]quit \t [R2]Interface Serial 4/0/0 [R2-Serial4/0/0]ip address 192.168.3.1 24 [R2-Serial4/0/0]quit \t [R2]interface LoopBack 0 [R2-LoopBack0]ip address 172.16.2.2 32 [R2-LoopBack0]quit R3 IP configuration <Huawei>system-view Enter system view, return user view with Ctrl + Z. [Huawei]sysname R3 [R3]undo info-center enable Info: Information center is disabled. [R3]interface GigabitEthernet 0/0/0 [R3-GigabitEthernet0/0/0]ip address 192.168.4.1 24 [R3-GigabitEthernet0/0/0]quit [R3]interface GigabitEthernet 0/0/1 [R3-GigabitEthernet0/0/1]ip address 192.168.2.2 24 [R3-GigabitEthernet0/0/1]quit \t [R3]interface LoopBack 0 [R3-LoopBack0]ip address 172.16.3.3 32 [R3-LoopBack0]quit R4 IP configuration <Huawei>system-view Enter system view, return user view with Ctrl + Z. [Huawei]sysname R4 [R4]undo info-center enable Info: Information center is disabled. [R4]interface Serial 4/0/0 [R4-Serial4/0/0]ip address 192.168.3.2 24 [R4-Serial4/0/0]quit [R4]interface GigabitEthernet 0/0/1 [R4-GigabitEthernet0/0/1]ip address 192.168.4.2 24 [R4-GigabitEthernet0/0/1]quit \t [R4]interface LoopBack 0 [R4-LoopBack0]ip address 172.16.4.4 32 [R4-LoopBack0]quit [R4]interface LoopBack 1 [R4-LoopBack1]ip address 172.16.44.44 32 [R4-LoopBack1]quit
R2, R3, and R4 OSPF configuration enables the loopback interfaces in AS200 to communicate with each other.
R2 OSPF configuration [R2]ospf 1 router-id 172.16.2.2 Create OSPF 1 and specify router-id [R2-ospf-1]area 0 Create backbone area area 0 [R2-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255 declare network segment [R2-ospf-1-area-0.0.0.0]network 172.16.2.2 0.0.0.0 announces loopback interface [R2-ospf-1-area-0.0.0.0]quit [R2-ospf-1]quit R3 OSPF configuration [R3]ospf 1 router-id 172.16.3.3 [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]network 172.16.3.3 0.0.0.0 [R3-ospf-1-area-0.0.0.0]quit [R3-ospf-1]quit R4 OSPF configuration [R4]ospf 1 router-id 172.16.4.4 [R4-ospf-1]area 0 [R4-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255 [R4-ospf-1-area-0.0.0.0]network 192.168.4.0 0.0.0.255 [R4-ospf-1-area-0.0.0.0]network 172.16.4.4 0.0.0.0 [R4-ospf-1-area-0.0.0.0]quit [R4-ospf-1]quit
All router BGP configuration
R1 BGP configuration [R1]bgp 100 Create area AS100 [R1-bgp]router-id 172.16.1.1 Specify router-id as 172.16.1.1 [R1-bgp]peer 192.168.1.2 as-number 200 specifies the neighbor. The physical interface specified here is located on AS200 [R1-bgp]peer 192.168.2.2 as-number 200 [R1-bgp]network 172.16.1.1 32 [R1-bgp]network 172.16.11.11 32 [R1-bgp]quit R2 BGP configuration [R2]bgp 200 [R2-bgp]router-id 172.16.2.2 [R2-bgp]peer 192.168.1.1 as-number 100 [R2-bgp]peer 172.16.3.3 as-number 200 specifies the neighbor. The Loopback interface is used here. [R2-bgp]peer 172.16.3.3 connect-interface LoopBack 0 Specify update source [R2-bgp]peer 172.16.3.3 next-hop-local Set the next hop attribute to its own IP [R2-bgp]peer 172.16.4.4 as-number 200 [R2-bgp]peer 172.16.4.4 connect-interface LoopBack 0 [R2-bgp]peer 172.16.4.4 next-hop-local [R2-bgp]quit R3 BGP configuration [R3]bgp 200 [R3-bgp]router-id 172.16.3.3 [R3-bgp]peer 192.168.2.1 as-number 100 [R3-bgp]peer 172.16.2.2 as-number 200 [R3-bgp]peer 172.16.2.2 connect-interface LoopBack 0 [R3-bgp]peer 172.16.2.2 next-hop-local [R3-bgp]peer 172.16.4.4 as-number 200 [R3-bgp]peer 172.16.4.4 connect-interface LoopBack 0 [R3-bgp]peer 172.16.4.4 next-hop-local [R3-bgp]quit R4 BGP configuration [R4]bgp 200 [R4-bgp]router-id 172.16.4.4 [R4-bgp]peer 172.16.2.2 as-number 200 [R4-bgp]peer 172.16.2.2 connect-interface LoopBack 0 [R4-bgp]peer 172.16.3.3 as-number 200 [R4-bgp]peer 172.16.3.3 connect-interface LoopBack 0 [R4-bgp]network 172.16.44.44 32 [R4-bgp]quit
Modify the cost value to 66
[R4]interface GigabitEthernet 0/0/1 [R4-GigabitEthernet0/0/1]ospf cost 66 [R4-GigabitEthernet0/0/1]quit
Before modification, the optimal next hop to 172.16.11.11 is 172.16.3.3. As can be seen from the figure, its cost value is 1, so it becomes the optimal next hop
After modification and comparison, the smaller the cost value will be preferred