通过本节你可以了解到怎么读取BGP表,了解BGP路由是沿着哪条路径学习到的,对于网络的troubleshooting 很有用
BGP将学习到的所有前缀都存储在 BGP 表中,通过你将学习如何阅读它,我们从一个简单的拓扑开始,然后快速浏览一下完整的 Internet 路由表。
配置
hostname R1
!
interface fastEthernet0/0
ip address 192.168.12.1 255.255.255.0
!
interface fastEthernet0/1
ip address 192.168.13.1 255.255.255.0
!
router bgp 1
neighbor 192.168.12.2 remote-as 2
neighbor 192.168.13.3 remote-as 3
!
end
hostname R2
!
interface fastEthernet0/0
ip address 192.168.12.2 255.255.255.0
!
interface fastEthernet0/1
ip address 192.168.24.2 255.255.255.0
!
router bgp 2
neighbor 192.168.12.1 remote-as 1
neighbor 192.168.24.4 remote-as 4
!
end
hostname R3
!
interface fastEthernet0/0
ip address 192.168.13.3 255.255.255.0
!
interface fastEthernet0/1
ip address 192.168.34.3 255.255.255.0
!
router bgp 3
neighbor 192.168.13.1 remote-as 1
neighbor 192.168.34.4 remote-as 4
!
end
hostname R4
!
interface Loopback 0
ip address 4.4.4.4 255.255.255.255
!
interface fastEthernet0/0
ip address 192.168.24.4 255.255.255.0
!
interface fastEthernet0/1
ip address 192.168.34.4 255.255.255.0
!
router bgp 4
network 4.4.4.4 mask 255.255.255.255
neighbor 192.168.24.2 remote-as 2
neighbor 192.168.34.3 remote-as 3
!
end
BGP 配置非常简单,我们在这里使用 eBGP,请注意,R4 在 BGP 中通告网络(环回接口)。
我们来看看BGP表,首先从 R4 开始:
R4#show ip bgp
BGP table version is 2, local router ID is 192.168.34.4
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 0.0.0.0 0 32768 i
先从我用红色突出显示的条目开始,该路由器的 BGP 表中有网络 4.4.4.4/32,并且在网络前面有*>符号:
*代表这是一条有效的路由,BGP将会使用它;
>代表这条路由被选为最佳路径。
下一跳 0.0.0.0 意味着这个网络起源于这个路由器,因为我在 R4 上使用了 network 命令将这个网络通告到 BGP。
在右侧,会看到metric, local preference 和weight,这些是用于选择最佳路径的 BGP 属性。
Path处将显示 AS 路径,因为该条目是在本台路由器中通告的,所以没有任何内容,在其他路由器上,你会在这里看到一些东西。
“i”是源属性,是指通过network命令通告近BGP的路由,如果是”?”代表重分布。
supressed:BGP 知道这个网络条目但不会通告它,当这条网络是汇总路由的一部分时会发生这种情况。
damped:BGP 不通告此网络,通常发生在其频繁的抖动,BGP将其标记为惩罚状态;
history : BGP 学习了这个网络,但目前不是有效的路由。
RIB-failure : BGP 学习了这个网络,但没有将它安装在路由表中。当路由器通过其它更小的管理距离路由协议学习到了此路由。
stale : 这用于不间断转发,当远程 BGP 邻居返回时必须刷新此条目。
让我们看看其他路由器的 BGP 表;:
R2#show ip bgp
BGP table version is 2, local router ID is 192.168.24.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 4.4.4.4/32 192.168.24.4 0 0 4 i
R2 的输出与在 R4 上看到的相似,但有两个重要区别,第一个是下一跳,R2 从 192.168.24.4 学习到这个网络,第二件是 AS path,它显示的是 AS 4。
R1#show ip bgp
BGP table version is 2, local router ID is 192.168.13.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 4.4.4.4/32 192.168.13.3 0 3 4 i
*> 192.168.12.2 0 2 4 i
路由器R1从 R2 和 R3 学习到这个网络,这两个条目都是有效的,它们前面有 *,BGP 选择通过 R2 的路径作为最佳路径,你可以看到此条目前面的 >,还可以看到到达此网络的 AS 路径。
也可以在路由表中查看最佳路径:
R1#show ip route bgp
4.0.0.0/32 is subnetted, 1 subnets
B 4.4.4.4 [20/0] via 192.168.12.2, 00:25:51
也可通过如下命令查看详细信息,这在有很多路由条目的时候很方便:
R1#show ip bgp 4.4.4.4
BGP routing table entry for 4.4.4.4/32, version 2
Paths: (2 available, best #2, table Default-IP-Routing-Table)
Advertised to update-groups:
1
3 4
192.168.13.3 from 192.168.13.3 (192.168.34.3)
Origin IGP, localpref 100, valid, external
2 4
192.168.12.2 from 192.168.12.2 (192.168.24.2)
Origin IGP, localpref 100, valid, external, best
通过上面信息可以看到有两条路径,第二条已被选为最佳路径。
最后来看看 R3:
R3#show ip bgp
BGP table version is 2, local router ID is 192.168.34.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 4.4.4.4/32 192.168.13.1 0 1 2 4 i
*> 192.168.34.4 0 0 4 i
上面可以看到R3有两条路径,可以使用R1或者R4到达4.4.4.4/32。
通过本节可以对BGP表有个基本的了解,不至于不知道怎么看此表。