Lecture 97: BGP Route selection - ASPATH, LOCAL_PREF, MED
- 课程:[NEW] AWS Certified Advanced Networking Specialty 2026
- 视频时长:08:14
- 来源:Udemy Lecture 26077182
- Slide 数量:4
- 画面切换:03:50、05:42、06:38
扫描说明
逐条检查了 Udemy 页面中的 179 条 Transcript cue,并对全长约 8:14 的视频画面逐段扫描。依据 AS_PATH、LOCAL_PREF、MED 和 BGP Route selection order recap 四张独立 Slide,共划分出 4 个小节。
Transcript 来自 Udemy 页面自带的英文自动字幕,没有使用 ASR。下面保留页面原文,包括其中的语法或识别错误。
1. AS_PATH 与 AS Path Prepending
时间范围:00:00–03:50
总结 / Summary
中文
自治系统路径(Autonomous System Path, AS_PATH)记录到达目标前缀需要经过的自治系统(Autonomous System, AS)序列。其他条件相同时,边界网关协议(Border Gateway Protocol, BGP)优先选择 AS_PATH 更短的路径,而不是单纯依据链路带宽。通过自治系统路径追加(AS path prepending)重复加入自己的 ASN,可以让某条路由看起来更长,从而降低其被外部邻居选择的优先级。
English
AS_PATH records the sequence of autonomous systems traversed to reach a destination prefix. With other attributes equal, BGP prefers the shorter AS_PATH rather than simply choosing the highest-bandwidth link. AS path prepending repeats the local ASN so that a route appears longer and becomes less attractive to external neighbors.
Transcript
00:00 Hello and welcome to this lecture.
00:01 So in earlier lecture we saw how BGP interchange
00:05 the route information between the BGP peers.
00:07 Now let's understand the BGP attributes,
00:10 which would affect the routing decision.
00:12 So first let's look at how ASPATH works.
00:16 So, as I said, ASPATH is like number of hops
00:20 you have to go through in order to reach to the destination,
00:23 right?
00:23 So this is the opening information, so far we have.
00:26 We are really talking about the AS 100 here
00:30 and there are different routes information
00:32 that it received from the neighboring AS's.
00:35 And that's where this AS 300 information it received
00:38 from both the AS 400 and AS 200.
00:41 Now, additionally, if you could see,
00:43 AS 400 is also connected to AS 200,
00:47 and it has the routing information how to reach to AS 200.
00:50 And this is this entry that I'm showing.
00:53 Additionally, what it does,
00:54 it will prepend its own AS number
00:58 and will send that route information back to AS 100.
01:01 So now if you look at this,
01:02 AS 100 has two routes to reach to the AS 200.
01:06 One, it is directly connected.
01:08 So it knows the next hop is 10.20.0.1,
01:12 and it can reach to AS 200
01:14 and other one is a longer route.
01:16 It can go through AS 400
01:18 and from there it reaches to AS 200.
01:21 But if you look at the BGP as in protocol,
01:24 it would rely on the shortest path, right?
01:27 So that means if you want to send the traffic
01:29 from AS 100 to 200, it will choose the shortest path.
01:33 And in this case, the shortest path is this one, right?
01:37 And that works perfectly in normal scenarios.
01:40 But there is a caveat.
01:42 Now, if you look at this network topology,
01:45 the link between the AS 100 and 200 is 2 Mbps,
01:49 however, between 100 to 400, it's 10 Mbps,
01:53 and same between 400 to 200.
01:56 That means if we talk about the bandwidth,
01:59 we can get more bandwidth to reach from 100 to 200
02:04 if it goes via AS 400.
02:06 But as you know, BGP would always prefer the shorter route,
02:09 so it will take this path.
02:12 Now, how do you influence that decision, routing decision?
02:16 And instead going from this path,
02:18 let's try to go over the longer route
02:21 because it provides much more bandwidth.
02:23 In order to do that, you can use something called ASPATH.
02:26 What you can do is you can update the route information
02:29 in AS 100 and you can add additional hop there,
02:34 which are kind of dummy hops, you can say.
02:36 So what I'm saying is you modify that route information
02:40 and you append the same 200 AS as multiple times.
02:44 Now, if you see the length of this path
02:46 has become 4, however, the other path,
02:50 it's length is still 3.
02:53 Once you do that, BGP understand that now
02:55 this is not an optimal route probably,
02:58 though it is.
03:00 But it will then turn out to other path
03:03 which takes through 400 AS
03:06 and then it would select the another path.
03:09 And then the traffic will go from AS 200 to AS 400
03:13 and from there it would be routed to AS 200.
03:16 So basically what we did,
03:17 we could influence the routing decision
03:19 by prepending more paths in the same route entry.
03:24 And so that it chooses it over the another path.
03:27 Now that in a nutshell is ASPATH.
03:29 Okay.
03:30 Now let's try to understand the next attribute in the BGP,
03:33 which is Local preference.
03:35 Now, in this case, the topology is little different.
03:37 In case of AS 100, we have now two routers.
03:40 One router is connected to AS 400
03:43 and another router in the same AS system
03:46 is connected to the AS 200.
03:48 Now let's take an example.
2. LOCAL_PREF 选择 AS 的出站路径
时间范围:03:50–05:42
总结 / Summary
中文
本地优先级(Local Preference, LOCAL_PREF)在同一自治系统(Autonomous System, AS)内部传播,用于决定流量从哪个出口离开本地 AS。数值越高优先级越高,默认值通常为 100;示例把连接 AS 400 的出口设置为 200,另一出口保持 100,因此内部路由器会优先把去往目标的流量发送到 LOCAL_PREF 为 200 的出口。该属性不会通告给外部 BGP 邻居(external BGP neighbor)。
English
LOCAL_PREF is propagated within a single autonomous system and determines which exit is used for outbound traffic. Higher values are preferred, with a common default of 100. In the example, the exit toward AS 400 is assigned 200 while the other remains at 100, so internal routers prefer the 200-valued exit. LOCAL_PREF is not advertised to external BGP neighbors.
Transcript
03:50 We have this router, which is shown here.
03:52 Now this router wants to send a traffic to AS 300.
03:56 Now for that, there are two route table entries here.
03:59 One is through 400 and 300
04:01 and another is through 200 and then 300.
04:04 Now, if the traffic has to go to 400,
04:06 probably this router will send traffic to this router A
04:09 within that AS system.
04:11 And in another case, it may send it to router B here.
04:16 The question is which route it should take.
04:19 Either this route or this route?
04:21 Now, in order to influence that decision,
04:24 you can use something called local preference.
04:26 And as I'm showing here,
04:28 this decision is only within that AS.
04:31 That means this local preference does not affect
04:34 the routing information
04:36 or this routing information is not shared
04:38 with the neighboring external AS's, right?
04:42 So what I can do is for these routes,
04:45 I can set the local preference values,
04:48 say 100 and 200.
04:50 And the highest preference value would take the precedence.
04:53 So in this case, as you can see,
04:55 this router has the precedence as 200,
04:58 then actual traffic will go through router A,
05:02 from there it will go to AS 400,
05:04 and from there it will go to AS 300.
05:07 So local preference would affect the routes within the AS.
05:12 So default value is 100,
05:14 and then you can choose other higher values
05:16 to have the more precedence.
05:19 Now let's try to understand Multi Exit Discriminator.
05:22 Now, here again,
05:23 the network topology is little different.
05:26 We have 2 AS's here.
05:27 So from AS 100,
05:29 we have now 2 connections to reach two AS 400
05:32 through different destination routers in AS 400.
05:35 Now you can see AS 100,
05:37 the single router is connected
05:38 to two different routers in target AS.
3. MED 影响外部 AS 的入口选择
时间范围:05:42–06:38
总结 / Summary
中文
多出口鉴别器(Multi-Exit Discriminator, MED)用于两个自治系统(Autonomous System, AS)之间存在多条入口链路时表达首选入口。通常在本地优先级(LOCAL_PREF)相同且自治系统路径(AS_PATH)相同时再比较 MED,并选择数值更低的路径。示例中 MED=2 比 MED=5 更优,因此 AS 100 选择指向 10.40.0.1 的入口。MED 会在相邻 AS 之间交换。
English
MED expresses a preferred entry point when multiple links connect the same two autonomous systems. It is generally considered after LOCAL_PREF and AS_PATH are equal, and the lower MED is preferred. In the example, MED 2 is preferred over MED 5, so AS 100 selects the path toward 10.40.0.1. MED is exchanged between neighboring autonomous systems.
Transcript
05:42 Now, Multi Exit Discriminator will come into the picture,
05:46 when local preference is the same,
05:49 when ASPATH is the same,
05:51 then only this is MED is looked at.
05:53 Now, if you can see,
05:54 of course there is only one hop between both these,
05:57 that means ASPATH is same.
05:59 Now, Local Preference, we haven't really set right now.
06:02 So default is 100.
06:03 That means it is also the same.
06:05 And now comes the MED.
06:07 So lowest MED value will have highest preference.
06:11 So now, if you set the MED value to 2 for this connection
06:14 and 5 for this connection,
06:16 in that case, the lowest value would take the precedence.
06:20 So traffic will go from here to here.
06:22 So that is a MED.
06:24 Now MED is between the external AS's.
06:27 So there are multiple paths to reach to the same target AS,
06:32 then you can have the MED values
06:34 to influence the routing decision.
06:36 So that's about the MED.
4. BGP Route Selection Order 总结
时间范围:06:38–08:14
总结 / Summary
中文
本课采用的 BGP 选路顺序(BGP route selection order)是:最高权重(highest Weight)、最高本地优先级(highest LOCAL_PREF)、最短自治系统路径(shortest AS_PATH),最后是最低多出口鉴别器(lowest MED)。Weight 是 Cisco 路由器特有且仅在本机有效;LOCAL_PREF 控制本 AS 的出站出口;AS_PATH 可通过路径追加(path prepending)调整;MED 在 AS 间存在多个连接点时影响入口选择。
English
The route-selection order presented is highest Weight, highest LOCAL_PREF, shortest AS_PATH, and then lowest MED. Weight is Cisco-specific and local to the router. LOCAL_PREF selects the outbound exit for the local AS, AS_PATH can be influenced with path prepending, and MED influences the preferred entry when multiple links connect two ASes.
Transcript
06:38 So let's recap what we learnt about the BGP
06:41 in last two lectures.
06:43 So for influencing the BGP routing decision,
06:46 there is something called Highest Weight,
06:48 but this is only specific to the Cisco routers.
06:50 And that's where we are not really interested.
06:52 But then again, the highest weight takes the precedence
06:55 if there is a scenario talking about the weight,
06:57 so make sure you choose the highest weight.
07:00 Now, again, like you can see like a local preference,
07:05 this highest weight information is not exchanged
07:09 between the external BGP routers.
07:12 It works within the AS.
07:14 Then comes the highest local preference.
07:16 As I said, it is not exchanged
07:19 between the external BGP routers.
07:21 It is set by the local AS for internal BGP routing
07:25 and the default value is 100.
07:27 Then comes the shortest AS Path.
07:29 And you know, AS Path can be modified
07:31 using AS path prepend to make it appear longer
07:34 so that another path can be taken up.
07:38 Then comes the MED.
07:40 This is again, a lowest MED will take the precedence.
07:44 And this is between the multiple paths between the two AS's,
07:48 in that case you can use the MED.
07:51 And MED is exchanged between the autonomous system or AS's.
07:55 So with that, I'm sure now you know about the BGP,
07:58 how it works and the various attributes of the BGP,
08:01 how they affect the overall routing.
08:04 So that's it about this lecture,
08:05 and now we will get into the AWS side of the VPN
08:09 and the BGP.
08:11 So thanks for watching.
整讲总结 / Overall Summary
中文
BGP 选路属性(BGP path attributes)分别解决不同层次的问题:Weight 在本地路由器上生效;本地优先级(LOCAL_PREF)在 AS 内选择出站出口;自治系统路径(AS_PATH)偏好经过 AS 更少的路径,并可通过路径追加(path prepending)降低某条路径吸引力;多出口鉴别器(MED)在两个 AS 的多条连接之间偏好较低数值。理解属性作用域和比较方向是考试重点。
English
BGP path attributes solve different selection problems at different scopes. Weight is local to a router, LOCAL_PREF selects an outbound exit within the AS, AS_PATH prefers fewer AS hops and can be made less attractive through prepending, and MED prefers a lower value between multiple links connecting two ASes. Understanding each attribute's scope and comparison direction is essential.
返回顶部 ↑