拓扑如下图所示:
上图中AR1与AR3形成ibgp邻居,区域13,AR2与AR4形成ibgp邻居,区域24,AR1与AR2形成ebgp对等体(邻居)。为了让AR3与AR4互通,需要通过AR1和AR2相互传递路由给对端的bgp区域,让区域13和区域24通过bgp协议相互学习到对方的路由。因为bgp只负责控制路由,而底层依然是靠igp来完成寻址建立tcp连接。所以需要使用igp路由使得bgp对等体可以建立tcp连接相互形成bgp对等体,对等体形成后AR1与AR2需要分别将自己从igbp邻居学到的路由宣告给ebgp邻居,从ebgp邻居学到的路由宣告给ibgp邻居,达到as13与as24相互通信的目的。
具体配置如下:
R1:
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
interface GigabitEthernet0/0/1
ip address 13.1.1.1 255.255.255.0
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
quit
bgp 13
router-id 1.1.1.1
peer 2.2.2.2 as-number 24 \\与R2建立ebgp邻居
peer 2.2.2.2 ebgp-max-hop 2 \\ebgp邻居允许的最大跳数修改为2(因为不是直连而是用loopback0接口)
peer 2.2.2.2 connect-interface LoopBack0 \\更新发送bgp报文的接口为loopback0接口
peer 3.3.3.3 as-number 13 \\与R3建立ibgp对等体
peer 3.3.3.3 connect-interface LoopBack0
ipv4-family unicast
network 3.0.0.0 \\宣告从R3这个ibgp邻居学到的路由(给R2这个ebgp邻居)
network 13.1.1.0 255.255.255.0 \\宣告自己的直连路由给ebgp邻居
peer 2.2.2.2 enable \\指定与邻居2.2.2.2开启MP-BGP功能,iPv4地址族默认开启
peer 3.3.3.3 enable
peer 3.3.3.3 next-hop-local \\从ebgp邻居学习到的路由传递给ibgp邻居时,路由的下一跳修改为自己
quit
quit
rip 1 \\使用igp路由搭建底层寻址
undo summary
network 1.0.0.0
network 13.0.0.0
quit
ip route-static 2.2.2.2 255.255.255.255 12.1.1.2 \\R1与R2建立ebgp对等体需要建立tcp连接,这里用静态做底层的寻址
R3:
interface GigabitEthernet0/0/0
ip address 13.1.1.3 255.255.255.0
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
quit
bgp 13
router-id 3.3.3.3
peer 1.1.1.1 as-number 13
peer 1.1.1.1 connect-interface LoopBack0
ipv4-family unicast
peer 1.1.1.1 enable
quit
quit
rip 1
undo summary
network 3.0.0.0
network 13.0.0.0
R2:
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 24.1.1.2 255.255.255.0
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
quit
bgp 24
router-id 2.2.2.2
peer 1.1.1.1 as-number 13 \\与R1建立ebgp对等体
peer 1.1.1.1 ebgp-max-hop 2
peer 1.1.1.1 connect-interface LoopBack0
peer 4.4.4.4 as-number 24 \\与R4建立ibgp对等体
peer 4.4.4.4 connect-interface LoopBack0
ipv4-family unicast
network 4.4.4.4 255.255.255.255
network 24.1.1.0 255.255.255.0
peer 1.1.1.1 enable
peer 4.4.4.4 enable
peer 4.4.4.4 next-hop-local
quit
quit
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 24.1.1.2 0.0.0.0
quit
ip route-static 1.1.1.1 255.255.255.255 12.1.1.1
R4:
interface GigabitEthernet0/0/0
ip address 24.1.1.4 255.255.255.0
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
quit
bgp 24
router-id 4.4.4.4
peer 2.2.2.2 as-number 24
peer 2.2.2.2 connect-interface LoopBack0
ipv4-family unicast
peer 2.2.2.2 enable
quit
quit
ospf 1
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 24.1.1.4 0.0.0.0