BGP 路径选择--Next_Hop

  • Next_Hop属性

    Next_Hop属性记录了路由的下一跳信息。BGP的下一跳属性和IGP的有所不同,不一定就是邻居设备的IP地址。通常情况下,Next_Hop属性遵循下面的规则:

    • BGP Speaker在向EBGP对等体发布某条路由时,会把该路由信息的下一跳属性设置为本地与对端建立BGP邻居关系的接口地址。

    • BGP Speaker将本地始发路由发布给IBGP对等体时,会把该路由信息的下一跳属性设置为本地与对端建立BGP邻居关系的接口地址。

    • BGP Speaker在向IBGP对等体发布从EBGP对等体学来的路由时,并不改变该路由信息的下一跳属性。

实验拓扑图 

BGP 路径选择--Next_Hop_第1张图片

 实验步骤

 全部路由器IP配置

R1 IP配置
 
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 %%01IFNET/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 
	
[R1]interface LoopBack 0	
[R1-LoopBack0]ip address 172.16.1.1 32	
[R1-LoopBack0]quit 
		
[R1]interface LoopBack 1
[R1-LoopBack1]ip address 172.16.11.11 32	
[R1-LoopBack1]quit 
 
R2 IP配置
 
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 
	
[R2]interface Serial 4/0/0
[R2-Serial4/0/0]ip address 192.168.3.1 24	
[R2-Serial4/0/0]quit 
	
[R2]interface LoopBack 0	
[R2-LoopBack0]ip address 172.16.2.2 32
[R2-LoopBack0]quit 
                   
R3 IP配置
 
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 
	
[R3]interface LoopBack 0	
[R3-LoopBack0]ip address 172.16.3.3 32
[R3-LoopBack0]quit 
 
R4 IP配置
 
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 
	
[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、R4 OSPF配置,使AS200内的loopback接口能够互通

R2 OSPF配置
 
[R2]ospf 1 router-id 172.16.2.2	 创建OSPF 1和指定router-id
[R2-ospf-1]area 0	创建骨干区域area 0
[R2-ospf-1-area-0.0.0.0]network 192.168.3.0 0.0.0.255  宣告网段
[R2-ospf-1-area-0.0.0.0]network 172.16.2.2 0.0.0.0	   宣告loopback接口
[R2-ospf-1-area-0.0.0.0]quit 
[R2-ospf-1]quit
 
R3 OSPF配置
 
[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配置
 
[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 

 所有路由器BGP配置

R1 BGP配置
 
[R1]bgp 100  创建区域AS100
[R1-bgp]router-id 172.16.1.1  指定router-id 为172.16.1.1
[R1-bgp]peer 192.168.1.2 as-number 200	指定邻居,这里指定的是物理接口,位于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配置
 
[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	指定邻居,这里使用的是Loopback接口
[R2-bgp]peer 172.16.3.3 connect-interface LoopBack 0  指定更新源
[R2-bgp]peer 172.16.3.3 next-hop-local   把下一跳属性设为自身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配置
 
[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配置
 
[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 

 修改cost值为66

[R4]interface GigabitEthernet 0/0/1	
[R4-GigabitEthernet0/0/1]ospf cost 66	
[R4-GigabitEthernet0/0/1]quit 

 修改前,去往172.16.11.11的最优下一跳为172.16.3.3,从图中可以看出其cost值为1,所以成为了最优下一跳BGP 路径选择--Next_Hop_第2张图片

BGP 路径选择--Next_Hop_第3张图片

 修改后对比,cost值越小就会被优选BGP 路径选择--Next_Hop_第4张图片

BGP 路径选择--Next_Hop_第5张图片

你可能感兴趣的:(网络,运维,服务器)