本文档介绍最初在Cisco IOS®软件版本12.0(5)S中提供的边界网关协议(BGP)local-AS功能。
本文档建议了解BGP路由协议及其操作。有关详细信息,请参阅检查边界网关协议案例研究。
本文档中的信息是使用此软件版本创建的,但并不限于特定的软件和硬件版本:
Cisco IOS 软件版本 12.2(28)
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
BGP本地AS功能允许运行一个BGP自治系统(AS)的路由器向特定eBGP邻居提供不同的AS编号。这在AS迁移方案期间非常有用,例如当一个ISP收购另一个ISP时,客户无法立即更改或首选维护其eBGP配置。这样可以确保顺利过渡,并最大程度地减少被收购ISP客户的中断。
例如,请参阅网络图,其中图1中,ISP-A尚未购买ISP-B,图2中,ISP-A已购买ISP-B,而ISP-B使用BGP local-AS功能。如果ISP-A购买ISP-B,但ISP-B客户不想修改任何配置,则BGP local-AS功能允许ISP-B中的路由器成为ISP-A(100)AS的成员。同时,这些路由器对客户而言似乎保留了其ISP-B(200)AS编号。
在图2中,ISP-B现在属于AS 100,而ISP-C(客户)属于AS 300。与ISP-C对等时,ISP-B使用neighbor <ISP-C> local-as 200命令将AS 200用作其AS编号。在从ISP-B发送到ISP-C的BGP更新中,AS_PATH属性中的AS_SEQUENCE包含“200 100”。 由于为ISP-C配置了local-as 200命令,ISP-B会将“200”置于前面。
通常,合并的ISP-A/B会将ISP-B中的路由器重新编号为AS 100的一部分。如果ISP-C无法使用ISP-B更改其eBGP配置怎么办?在BGP本地AS功能之前,组合的ISP-A/B必须维护两个AS编号。当 ISP-A/B 对 ISP-C 显示为两个 AS 时,local-as 命令允许其在物理上成为一个 AS。
此列表显示本文档中的配置使用的命令的语法:
neighbor
neighbor
注意:配置的本地AS不能与本地BGP进程AS相同。
注意:配置的本地AS不能与远程对等体AS相同。
注意:仅当对等体为真 eBGP 对等体时,local-as 命令才有效。对于作为联盟中不同子 AS 的两个对等体,此命令不起作用。
本部分提供了用于配置本文档所述功能的信息。
本文档使用这些网络设置。
图 1

图 2

路由器(在ISP-B内)运行BGP AS 100,它代表ISP-B使用的收购后AS。local-as 200 命令使ISP-C将此邻居视为AS 200而不是AS 100。它还导致AS 200预置在发送到ISP-C的路由通告之前。
| ISP-B(AS 100、本地 as 200) |
|---|
hostname ISP-B ! interface serial 0 ip address 192.168.1.1 255.255.255.252 ! interface ethernet 0 ip address 192.168.4.1 255.255.255.0 ! router bgp 100 !--- Note the AS number 100. This is the AS number of ISP-A, which is now |
| ISP-C (AS 300) |
|---|
hostname ISP-C ! interface serial 1 ip address 192.168.1.2 255.255.255.252 ! interface ethernet 0 ip address 192.168.9.1 255.255.255.0 ! router bgp 300 neighbor 192.168.1.1 remote-as 200 !--- Defines the eBGP connection to ISP-B. !--- Note AS is 200 and not AS 100. network 192.168.9.0 ! ! |
本部分提供的信息可用于确认您的配置是否工作正常。
在ISP-B上,show ip bgp summary确认本地BGP进程作为AS 100运行。
ISP-B#show ip bgp summary BGP router identifier 192.168.4.1, local AS number 100 BGP table version is 3, main routing table version 3 2 network entries and 2 paths using 266 bytes of memory 2 BGP path attribute entries using 104 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP activity 2/6 prefixes, 2/0 paths, scan interval 15 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.1.2 4 300 29 29 3 0 0 00:25:19 1
在ISP-C的下一个输出中,show ip bgp summary确认192.168.1.1处的ISP-B邻居被视为AS 200。
ISP-C#show ip bgp summary BGP table version is 3, main routing table version 3 2 network entries (2/6 paths) using 480 bytes of memory 2 BGP path attribute entries using 192 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd 192.168.1.1 4 200 34 34 3 0 0 00:30:19 1
请注意,在此输出中,ISP-B将“200”附加到从ISP-C获知的路由。 local-as 200命令导致ISP-B将AS 200显示到ISP-C。 ISP-C通过AS_PATH 200 100查看从ISP-B获知的路由,而ISP-B显示通过AS_PATH 200 300从ISP-C获知的路由。
ISP-B#show ip bgp
BGP table version is 3, local router ID is 192.168.4.1 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 192.168.4.0 0.0.0.0 0 32768 i *> 192.168.9.0 192.168.1.2 0 0 200 300 i
请注意,show ip bgp输出确认了local-as命令引入的AS_PATH行为。ISP-C从ISP-B接收带有AS_PATH "200 100"的路由192.168.4.0/24。
ISP-C#show ip bgp BGP table version is 3, local router ID is 192.168.1.2 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 192.168.4.0 192.168.1.1 0 0 200 100 i *> 192.168.9.0 0.0.0.0 0 32768 i
这些命令显示了在其输出中配置的 local-as 值:
show ip bgp neighbor
show ip bgp peer-group
ISP-B#show ip bgp neighbors 192.168.1.2
BGP neighbor is 192.168.1.2, remote AS 300, local AS 200, external link
BGP version 4, remote router ID 192.168.9.1
BGP state = Established, up for 00:22:42
Last read 00:00:42, hold time is 180, keepalive interval is 60 seconds
Neighbor capabilities:
Route refresh: advertised and received(old & new)
Address family IPv4 Unicast: advertised and received
Message statistics:
InQ depth is 0
OutQ depth is 0
Sent Rcvd
Opens: 1 1
Notifications: 0 0
Updates: 2 1
Keepalives: 25 25
Route Refresh: 0 1
Total: 28 28
Default minimum time between advertisement runs is 30 seconds
debug ip bgp updates 命令显示了从邻居处接收的前缀及其属性。此输出显示收到前缀 192.168.4.0/24 与 AS PATH 200、100。
警告:debug ip bgp updates命令可以在生产路由器上生成大量输出。仅在受控故障排除期间使用,最好是在维护时段或TAC指导下使用。收集所需的输出后,使用undebug all或no debug ip bgp updates禁用调试。
ISP-C# *May 10 12:45:14.947: BGP(0): 192.168.1.1 computing updates, afi 0, neighbor version 0, table version 5, starting at 0.0.0.0 *May 10 12:45:14.947: BGP(0): 192.168.1.1 send UPDATE (format) 192.168.9.0/24, next 192.168.1.2, metric 0, path *May 10 12:45:14.947: BGP(0): 192.168.1.1 1 updates enqueued (average=52, maximum=52) *May 10 12:45:14.947: BGP(0): 192.168.1.1 update run completed, afi 0, ran for 0ms, neighbor version 0, start version 5, throttled to 5 *May 10 12:45:14.947: BGP: 192.168.1.1 initial update completed *May 10 12:45:15.259: BGP(0): 192.168.1.1 rcvd UPDATE w/ attr: nexthop 192.168.1.1, origin i, metric 0, path 200 100 *May 10 12:45:15.259: BGP(0): 192.168.1.1 rcvd 192.168.4.0/24 *May 10 12:45:15.279: BGP(0): Revise route installing 192.168.4.0/24 -> 192.168.1.1 to main IP table ISP-C#
| 版本 | 发布日期 | 备注 |
|---|---|---|
5.0 |
09-Jul-2026
|
重新认证 |
2.0 |
08-May-2023
|
更新的格式。重新认证。 |
1.0 |
10-Dec-2001
|
初始版本 |