配置iBGP和eBGP的实验拓扑如下:
为了实现网络之间的互联互通,建立BGP邻居达成TCP连接,需要在AS 123内部路由器之间运行IGP,为了快速收敛,这里实施EIGRP。
R1的基础配置:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 10.88.12.1 255.255.255.0
no shutdown
!
router eigrp DUAL
!
address-family ipv4 unicast autonomous-system 88
!
topology base
exit-af-topology
network 1.1.1.1 0.0.0.0
network 10.88.12.1 0.0.0.0
exit-address-family
!
router bgp 123
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 2.2.2.2 remote-as 123
neighbor 2.2.2.2 update-source Loopback0
neighbor 3.3.3.3 remote-as 123
neighbor 3.3.3.3 update-source Loopback0
R2的基础配置:
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Ethernet0/0
ip address 10.88.12.2 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 10.88.23.2 255.255.255.0
no shutdown
!
router eigrp CISCO
!
address-family ipv4 unicast autonomous-system 88
!
topology base
exit-af-topology
network 2.2.2.0 0.0.0.255
network 10.88.0.0 0.0.255.255
exit-address-family
!
router bgp 123
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 123
neighbor 1.1.1.1 update-source Loopback0
neighbor 3.3.3.3 remote-as 123
neighbor 3.3.3.3 update-source Loopback0
R3的基础配置:(R3用的都是新结构的配置,R2和R1的eigrp也是用的命名方式配置,虽然看着配置略有繁琐,但是结构特别清晰一致。)
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Ethernet0/0
ip address 100.192.34.1 255.255.255.252
no shutdown
!
interface Ethernet0/1
ip address 10.88.23.3 255.255.255.0
no shutdown
!
router eigrp D
!
address-family ipv4 unicast autonomous-system 88
!
topology base
exit-af-topology
network 3.0.0.0
network 10.88.23.3 0.0.0.0
exit-address-family
!
router bgp 123
bgp router-id 3.3.3.3
bgp log-neighbor-changes
no bgp default ipv4-unicast
neighbor 1.1.1.1 remote-as 123
neighbor 1.1.1.1 update-source Loopback0
neighbor 2.2.2.2 remote-as 123
neighbor 2.2.2.2 update-source Loopback0
neighbor 100.192.34.2 remote-as 444
!
address-family ipv4
network 1.1.1.0 mask 255.255.255.0
network 2.2.2.0 mask 255.255.255.0
network 3.3.3.0 mask 255.255.255.0
neighbor 1.1.1.1 activate
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 activate
neighbor 2.2.2.2 next-hop-self
neighbor 100.192.34.2 activate
exit-address-family
R4的基础配置:
interface Loopback0
ip address 4.4.0.4 255.255.255.0
!
interface Loopback1
ip address 4.4.1.4 255.255.255.0
!
interface Loopback2
ip address 4.4.2.4 255.255.255.0
!
interface Loopback3
ip address 4.4.3.4 255.255.255.0
!
interface Ethernet0/0
ip address 100.192.34.2 255.255.255.0
no shutdown
!
router bgp 444
bgp router-id 4.4.4.4
bgp log-neighbor-changes
network 4.4.0.0 mask 255.255.252.0
neighbor 100.192.34.1 remote-as 123
!
ip route 4.4.0.0 255.255.252.0 Null0
R4使用静态路由构建一条指向空接口的汇总路由,否则不能在BGP进程下直接用network命令通告出去。如果不使用这条构建的静态路由,则需要分别network loopback0、1、2和3的网络ID和子网掩码,然后再写一条aggregate-address汇总地址后再加一个summary-only的参数才可以实现相差无几的效果。
在iBGP和eBGP的边界路由器上对iBGP的邻居后接一条next-hop-self参数是为了解决下一跳可达的问题,因为通过eBGP注入到AS时,从eBGP获得的下一跳地址默认是不加改变的在iBGP中传递;next-hop-self参数的作用是将与eBGP连接的本路由器把自己作为发送BGP更新信息的下一跳通告给iBGP邻居。可以简单记住:next-hop-self
= 把“下一跳改成我”。这就是它的作用!
在R3上查看TCP连接信息摘要,可以查看R3与其他对等体建立TCP 179的连接情况。(只要两台路由器之间可以建立一条TCP连接,就能形成BGP的邻居关系)
在R3是查看eBGP邻居的详细信息:
查看两台不同AS之间的BGP表和路由表:
查看R1和R2的BGP表和安装失败的RIB表:
r:是指将BGP表中的路由条目安装到IP路由表失败,结合show ip bgp rib-failure显示没有安装到路由表的BGP路由以及没有装入的原因,此实验显示的是路由条目没有被安装到路由表的原因是管理距离高,因为显示r的路由条目可通过具有更低管理距离90的EIGRP到达,iBGP的AD值是200,所以会装表失败。
连通性测试如下:
直接使用默认的ping测试,不通原因是R1和R2的路由表中没有到达eBGP直连的条目;然而使用带源的ping测试,则直接可达。如果一定要使用默认的直接ping而不要源的测试,则需要让路由器R1和R2学到eBGP的直连路由即可(比如在R3的EIGRP中重分布直连)。
验证、抑制和多跳的拓扑如下:
一般来说eBGP之间总是使用直连物理接口建立邻居,但是,当两个不同的AS对等体之间有多条物理链路时,则建议使用环回接口建立邻居关系,这样可以增加BGP连接的稳定性。(之前的实验描述过eBGP之间使用环回接口建立邻居的特性和要求)
R5的基础配置:
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface Loopback1
ip address 55.55.55.55 255.255.255.255
!
interface Ethernet0/0
ip address 10.0.12.1 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 10.1.12.1 255.255.255.0
no shutdown
!
router bgp 100
bgp router-id 5.5.5.5
bgp log-neighbor-changes
network 55.55.55.55 mask 255.255.255.255
neighbor 6.6.6.6 remote-as 200
neighbor 6.6.6.6 password Cisc0123
neighbor 6.6.6.6 ebgp-multihop 2
neighbor 6.6.6.6 update-source Loopback0
!
ip route 6.6.6.6 255.255.255.255 10.0.12.2
ip route 6.6.6.6 255.255.255.255 10.1.12.2
R6的基础配置:
interface Loopback0
ip address 6.6.6.6 255.255.255.255
!
interface Ethernet0/0
ip address 10.0.12.2 255.255.255.0
no shutdown
!
interface Ethernet0/1
ip address 10.1.12.2 255.255.255.0
no shutdown
!
router bgp 200
bgp router-id 6.6.6.6
bgp log-neighbor-changes
bgp dampening route-map DAM
neighbor 5.5.5.5 remote-as 100
neighbor 5.5.5.5 password Cisc0123
neighbor 5.5.5.5 ebgp-multihop 2
neighbor 5.5.5.5 update-source Loopback0
!
ip route 5.5.5.5 255.255.255.255 10.0.12.1
ip route 5.5.5.5 255.255.255.255 10.1.12.1
!
ip prefix-list DAM seq 5 permit 55.55.55.55/32
!
route-map DAM permit 10
match ip address prefix-list DAM
set dampening 15 750 2000 60
如果不使用路由映射挂在dampening使其加载特定路由条目上,可在BGP路由模式下直接使用此命令设置参数,这样就是对全局生效。
建立BGP邻居身份验证设置密码后使用的是基于MD5摘要的加密方式。
查看dampening的参数及设置:
由于R5没有配置dampening parameters的任何参数,所以查看为未启用。
测试dampening flap-statistics,先在R5上把55.55.55.55那个环回接口关闭,查看:
再打开R5环回接口查看,然反复3次这种开关操作:
标记为d意味着已经接口flapping,处于被惩罚期间。
处于dampening惩罚状态的路由不会被放入路由表中,同时也不被BGP传递。
清除被抑制的BGP路由再查看:
R6#clear ip bgp dampening
反复开关接口,配有抑制参数的路由器,认为这样翻动的路由是不稳定的,所有惩罚值;在惩罚期间即使接口处于打开状态也没法重建BGP路由表,始终处于抑制状态,所以这时需要清除BGP抑制计时器即可恢复以及重新使BGP加入路由表。