TS2-Big Office BGP AS 60004 分析-BGP Local-Preference

本文详细介绍了在Big Office环境中如何通过调整BGP的本地优先级(local-preference)来优化路由选择,确保数据包能沿最优路径传输。特别关注了R40和R41路由器上的配置,以及如何设置特定前缀的本地优先级来改善到不同子网的路由。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   所以 在  TS 的时候,  user4在  AS 65004(10.4.0.0/16)去往 server2 AS 65002 (10.2.0.0/16) 走的是 R41(local-pref =1000),user4-R41-到 --R7-R21-SW210--server2.

  回来的时候,也要从 R21 回来, 所以在 R20和R21 上也针对了 user4  AS 65004(10.4.0.0/16) ,需改了 本地优先级, 但是他们都改为了100, 所以要实现原路返回,需要在  R21 上把针对了 user4  AS 65004(10.4.0.0/16) , 的 路由的 本地优先级调高为200,(local-pref=200),这时候回来的路由也是从 R7回来的, server2--到 --R21--R7--R41--user4. 

----------------------------------------------------------------------------


R40 出口优化了路由,R40去往 10.1.0.0/16 , 10.3.0.0/16, 10.5.0.0/16 ,10.6.0.0/16  比较优化,比较近,所以在 R40上对这个前缀设置了本地优先级高。 neighbor 10.4.40.40 route-map local-pref out                     set local-preference 1000
-----------------
R41 出口优化了路由,R41去往 10.2.0.0/16  比较优化,比较近,所以在 R41上对这个前缀设置了本地优先级高。 neighbor 10.4.40.40 route-map local-pref out                     set local-preference 1000
----------------------------------------------------------------------------------------------------------------
BGP本地优先级默认是 100。 




TS2-Big Office BGP AS 60004 分析。

R40 出口优化了路由,R40去往 10.1.0.0/16 , 10.3.0.0/16, 10.5.0.0/16 ,10.6.0.0/16  比较优化,比较近,所以在 R40上对这个前缀设置了本地优先级高。 neighbor 10.4.40.40 route-map local-pref out                     set local-preference 1000
-----------------
R41 出口优化了路由,R41去往 10.2.0.0/16  比较优化,比较近,所以在 R41上对这个前缀设置了本地优先级高。 neighbor 10.4.40.40 route-map local-pref out                     set local-preference 1000
----------------------------------------------------------------------------------------------------------------
BGP本地优先级默认是 100。 

-------------------------------------------------------------------------------------------------------------------------------------
同时 R40和R41对内网ospf下发了默认路由,对外网把ospf重分发到了BGP,同时在bgp对外做了路由汇总,优化了路由条目。

-----------------------------------------------------------------------------------------------------------------------------------


R41#show run
R41#show running-config | sec bgp
router bgp 65004
 bgp log-neighbor-changes
 aggregate-address 10.4.0.0 255.255.0.0 summary-only
 redistribute ospf 1
 neighbor 10.4.40.40 remote-as 65004
 neighbor 10.4.40.40 password cisco
 neighbor 10.4.40.40 update-source Loopback0
 neighbor 10.4.40.40 next-hop-self
 neighbor 10.4.40.40 route-map local-pref out
 neighbor 101.41.0.1 remote-as 10001
 neighbor 101.41.0.1 prefix-list LOCAL out
R41# 
R41#
R41#show run
R41#show running-config   |  sec local-pref
 neighbor 10.4.40.40 route-map local-pref out
route-map local-pref permit 10
 match ip address prefix-list local_pref
 set local-preference 1000
route-map local-pref permit 20
R41#
R41#
R41#show urn
R41#show run
R41#show running-config | sec local_pref
ip prefix-list local_pref seq 5 permit 10.2.0.0/16 le 32
 match ip address prefix-list local_pref
R41#
-------------------------------------------------------

R40#show run
R40#show running-config | sec bgp
router bgp 65004
 bgp log-neighbor-changes
 aggregate-address 10.4.0.0 255.255.0.0 summary-only
 redistribute ospf 1
 neighbor 10.4.41.41 remote-as 65004
 neighbor 10.4.41.41 password cisco
 neighbor 10.4.41.41 update-source Loopback0
 neighbor 10.4.41.41 next-hop-self
 neighbor 10.4.41.41 route-map local-pref out
 neighbor 100.40.0.1 remote-as 10000
 neighbor 100.40.0.1 prefix-list LOCAL out
R40#
R40#
R40#show ru
R40#show run
R40#show running-config | sec local-pref
 neighbor 10.4.41.41 route-map local-pref out
route-map local-pref permit 10
 match ip address prefix-list local_pref
 set local-preference 1000
route-map local-pref permit 20
R40#
R40#
R40#show run
R40#show running-config | sec local_pref
ip prefix-list local_pref seq 5 permit 10.1.0.0/16 le 32
ip prefix-list local_pref seq 10 permit 10.3.0.0/16 le 32
ip prefix-list local_pref seq 15 permit 10.5.0.0/16 le 32
ip prefix-list local_pref seq 20 permit 10.6.0.0/16 le 32
 match ip address prefix-list local_pref
R40#
--------------------------------
---------------------------------

R40#show run
R40#show running-config | sec ospf
 ip ospf 1 area 0
 ip ospf 1 area 0
 ip ospf 1 area 0
 ip ospf 1 area 0
router ospf 1
 default-information originate metric-type 1
 redistribute ospf 1
R40#
----------------------------------------------------------
R41#show run
R41#show running-config | sec ospf
 ip ospf 1 area 0
 ip ospf 1 area 0
 ip ospf 1 area 0
 ip ospf 1 area 0
router ospf 1
 default-information originate metric-type 1
 redistribute ospf 1
R41#
R41#
------------------------------------------------------
R40#show ip ro
R40#show ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is 100.40.0.1 to network 0.0.0.0

B*    0.0.0.0/0 [20/0] via 100.40.0.1, 02:50:08
      10.0.0.0/8 is variably subnetted, 24 subnets, 4 masks
B        10.1.0.0/16 [20/0] via 100.40.0.1, 02:50:08
B        10.1.200.0/24 [20/0] via 100.40.0.1, 02:49:50
B        10.1.201.0/24 [20/0] via 100.40.0.1, 02:49:50
B        10.2.0.0/16 [200/0] via 10.4.41.41, 02:50:35
B        10.2.200.0/24 [200/0] via 10.4.41.41, 02:50:35
B        10.2.201.0/24 [200/0] via 10.4.41.41, 02:50:35
B        10.3.0.0/16 [20/0] via 100.40.0.1, 02:49:50
B        10.4.0.0/16 [200/0] via 0.0.0.0, 02:51:24, Null0
C        10.4.10.0/30 is directly connected, Ethernet0/3
L        10.4.10.1/32 is directly connected, Ethernet0/3
O        10.4.11.0/30 [110/20] via 10.4.99.2, 02:50:31, Ethernet0/1
                      [110/20] via 10.4.12.2, 02:50:46, Ethernet0/2
C        10.4.12.0/30 is directly connected, Ethernet0/2
L        10.4.12.1/32 is directly connected, Ethernet0/2
O        10.4.13.0/30 [110/19] via 10.4.10.2, 02:50:31, Ethernet0/3
C        10.4.40.40/32 is directly connected, Loopback0
O        10.4.41.41/32 [110/11] via 10.4.99.2, 02:50:31, Ethernet0/1
C        10.4.99.0/30 is directly connected, Ethernet0/1
L        10.4.99.1/32 is directly connected, Ethernet0/1
O        10.4.100.0/24 [110/11] via 10.4.12.2, 02:50:46, Ethernet0/2
                       [110/11] via 10.4.10.2, 02:51:08, Ethernet0/3
O        10.4.101.0/24 [110/11] via 10.4.12.2, 02:50:46, Ethernet0/2
                       [110/11] via 10.4.10.2, 02:51:08, Ethernet0/3
O        10.4.109.0/30 [110/19] via 10.4.10.2, 02:50:15, Ethernet0/3
O        10.4.140.140/32 [110/11] via 10.4.10.2, 02:51:09, Ethernet0/3
O        10.4.141.141/32 [110/11] via 10.4.12.2, 02:50:46, Ethernet0/2
B        10.5.0.0/16 [20/0] via 100.40.0.1, 02:50:07
      100.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
B        100.10.0.0/30 [20/0] via 100.40.0.1, 02:50:08
B        100.20.0.0/30 [20/0] via 100.40.0.1, 02:50:12
C        100.40.0.0/30 is directly connected, Ethernet0/0
L        100.40.0.2/32 is directly connected, Ethernet0/0
B        100.50.0.0/30 [20/0] via 100.40.0.1, 02:50:07
R40#
R40# 
---------------------------------
R41#show ip route  
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is 101.41.0.1 to network 0.0.0.0

B*    0.0.0.0/0 [20/0] via 101.41.0.1, 02:50:08
      10.0.0.0/8 is variably subnetted, 24 subnets, 4 masks
B        10.1.0.0/16 [200/0] via 10.4.40.40, 02:49:08
B        10.1.200.0/24 [200/0] via 10.4.40.40, 02:48:50
B        10.1.201.0/24 [200/0] via 10.4.40.40, 02:48:50
B        10.2.0.0/16 [20/0] via 101.41.0.1, 02:49:58
B        10.2.200.0/24 [20/0] via 101.41.0.1, 02:49:40
B        10.2.201.0/24 [20/0] via 101.41.0.1, 02:49:40
B        10.3.0.0/16 [200/0] via 10.4.40.40, 02:48:50
B        10.4.0.0/16 [200/0] via 0.0.0.0, 02:49:58, Null0
O        10.4.10.0/30 [110/19] via 10.4.13.2, 02:49:33, Ethernet0/2
C        10.4.11.0/30 is directly connected, Ethernet0/3
L        10.4.11.1/32 is directly connected, Ethernet0/3
O        10.4.12.0/30 [110/20] via 10.4.99.1, 02:49:41, Ethernet0/1
                      [110/20] via 10.4.11.2, 02:49:45, Ethernet0/3
C        10.4.13.0/30 is directly connected, Ethernet0/2
L        10.4.13.1/32 is directly connected, Ethernet0/2
O        10.4.40.40/32 [110/11] via 10.4.99.1, 02:49:41, Ethernet0/1
C        10.4.41.41/32 is directly connected, Loopback0
C        10.4.99.0/30 is directly connected, Ethernet0/1
L        10.4.99.2/32 is directly connected, Ethernet0/1
O        10.4.100.0/24 [110/11] via 10.4.13.2, 02:49:33, Ethernet0/2
                       [110/11] via 10.4.11.2, 02:49:45, Ethernet0/3
O        10.4.101.0/24 [110/11] via 10.4.13.2, 02:49:33, Ethernet0/2
                       [110/11] via 10.4.11.2, 02:49:45, Ethernet0/3
O        10.4.109.0/30 [110/19] via 10.4.13.2, 02:49:18, Ethernet0/2
O        10.4.140.140/32 [110/11] via 10.4.13.2, 02:49:33, Ethernet0/2
O        10.4.141.141/32 [110/11] via 10.4.11.2, 02:49:45, Ethernet0/3
B        10.5.0.0/16 [200/0] via 10.4.40.40, 02:49:07
      100.0.0.0/30 is subnetted, 4 subnets
B        100.10.0.0 [200/0] via 10.4.40.40, 02:49:08
B        100.20.0.0 [200/0] via 10.4.40.40, 02:49:12
B        100.40.0.0 [200/0] via 10.4.40.40, 02:49:36
B        100.50.0.0 [200/0] via 10.4.40.40, 02:49:07
      101.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        101.41.0.0/30 is directly connected, Ethernet0/0
L        101.41.0.2/32 is directly connected, Ethernet0/0
R41#
R41# 
-----------------------------------------------------------------------
SW400#show ip ro
SW400#show ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is 10.4.13.1 to network 0.0.0.0

O*E1  0.0.0.0/0 [110/10] via 10.4.13.1, 02:51:44, Ethernet1/1
                [110/10] via 10.4.10.1, 02:51:17, Ethernet1/0
      10.0.0.0/8 is variably subnetted, 17 subnets, 3 masks
C        10.4.10.0/30 is directly connected, Ethernet1/0
L        10.4.10.2/32 is directly connected, Ethernet1/0
O        10.4.11.0/30 [110/19] via 10.4.109.2, 02:51:27, Ethernet1/2
                      [110/19] via 10.4.13.1, 02:51:44, Ethernet1/1
O        10.4.12.0/30 [110/19] via 10.4.109.2, 02:51:27, Ethernet1/2
                      [110/19] via 10.4.10.1, 02:52:14, Ethernet1/0
C        10.4.13.0/30 is directly connected, Ethernet1/1
L        10.4.13.2/32 is directly connected, Ethernet1/1
O        10.4.40.40/32 [110/10] via 10.4.10.1, 02:52:14, Ethernet1/0
O        10.4.41.41/32 [110/10] via 10.4.13.1, 02:51:44, Ethernet1/1
O        10.4.99.0/30 [110/19] via 10.4.13.1, 02:51:44, Ethernet1/1
                      [110/19] via 10.4.10.1, 02:51:44, Ethernet1/0
C        10.4.100.0/24 is directly connected, Vlan2000
L        10.4.100.252/32 is directly connected, Vlan2000
C        10.4.101.0/24 is directly connected, Vlan2001
L        10.4.101.252/32 is directly connected, Vlan2001
C        10.4.109.0/30 is directly connected, Ethernet1/2
L        10.4.109.1/32 is directly connected, Ethernet1/2
C        10.4.140.140/32 is directly connected, Loopback0
O        10.4.141.141/32 [110/10] via 10.4.109.2, 02:51:27, Ethernet1/2
SW400# 
SW400# 
SW400# 
SW400# 
SW400#show ip os
SW400#show ip ospf nei
SW400#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
10.4.141.141      1   FULL/DR         00:00:31    10.4.109.2      Ethernet1/2
10.4.41.41        1   FULL/DR         00:00:37    10.4.13.1       Ethernet1/1
10.4.40.40        1   FULL/DR         00:00:31    10.4.10.1       Ethernet1/0
SW400# 
SW400#
-------------------------------------------------------
SW401#show ip ro
SW401#show ip route 
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       + - replicated route, % - next hop override

Gateway of last resort is 10.4.12.1 to network 0.0.0.0

O*E1  0.0.0.0/0 [110/11] via 10.4.12.1, 02:52:11, Ethernet1/1
                [110/11] via 10.4.11.1, 02:52:54, Ethernet1/0
      10.0.0.0/8 is variably subnetted, 17 subnets, 3 masks
O        10.4.10.0/30 [110/19] via 10.4.109.1, 02:52:21, Ethernet1/2
C        10.4.11.0/30 is directly connected, Ethernet1/0
L        10.4.11.2/32 is directly connected, Ethernet1/0
C        10.4.12.0/30 is directly connected, Ethernet1/1
L        10.4.12.2/32 is directly connected, Ethernet1/1
O        10.4.13.0/30 [110/19] via 10.4.109.1, 02:52:21, Ethernet1/2
O        10.4.40.40/32 [110/11] via 10.4.12.1, 02:53:04, Ethernet1/1
O        10.4.41.41/32 [110/11] via 10.4.11.1, 02:52:54, Ethernet1/0
O        10.4.99.0/30 [110/20] via 10.4.12.1, 02:52:39, Ethernet1/1
                      [110/20] via 10.4.11.1, 02:52:54, Ethernet1/0
C        10.4.100.0/24 is directly connected, Vlan2000
L        10.4.100.253/32 is directly connected, Vlan2000
C        10.4.101.0/24 is directly connected, Vlan2001
L        10.4.101.253/32 is directly connected, Vlan2001
C        10.4.109.0/30 is directly connected, Ethernet1/2
L        10.4.109.2/32 is directly connected, Ethernet1/2
O        10.4.140.140/32 [110/11] via 10.4.109.1, 02:52:21, Ethernet1/2
C        10.4.141.141/32 is directly connected, Loopback0
SW401# 
SW401#
SW401#
SW401#show ip os
SW401#show ip ospf nei
SW401#show ip ospf neighbor 

Neighbor ID     Pri   State           Dead Time   Address         Interface
10.4.140.140      1   FULL/BDR        00:00:33    10.4.109.1      Ethernet1/2
10.4.40.40        1   FULL/DR         00:00:30    10.4.12.1       Ethernet1/1
10.4.41.41        1   FULL/DR         00:00:35    10.4.11.1       Ethernet1/0
SW401#
SW401#
---------------------------------------------------------------------
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值