[r3]bgp 2345
[r3]peer 2.2.2.2 reflect-client # 指定R3为RR,且R2为R3的客户,其他未指定的IBGP邻居为非客户
由于IBGP水平分割是用来防止AS内部路由环路,而路由反射器打破了IBGP水平分割,则将有可能出现路由环路,所以为了避免环路的出现,路由反射器在设计的时候,专门引入了两个属性,来避免环路从产生: Originator_ID(起源者ID)、Cluster_list(簇列表)
如果RR从IBGP邻居处学到的路由没有携带该属性,则将再该路由信息上添加该属性,谁发送给RR的路由信息,Originator_ID就是谁的RID,如果RR从IBGP邻居处学到的路由携带该属性,则不修改该属性。当一台设备收到的IBGP路由信息后,发现里面的Originator_ID是自己的RID,则不接受这条路由信息。
但只是使用起源者ID不能完全解决环路的问题,如下图中,虽然起源者不会接收回传的路由,但其他已拥有该路由的设备呢?所以还需要另一个属性帮助防环—Cluster_list(簇列表)。
注意:
这两个属性,只是用来在IBGP内部进行防环的,所以,当这些路由被传递到EBGP对等体时,将不携带这两属性。RR在进行路由反射时,除了会在路由信息中添加以上两个属性外,其他属性不变。
[r3]bgp 64512 # 联邦内运行BGP的设备在运行BGP时需先指定联邦(小AS)号,以免后面忘记有联邦的存在
[r3-bgp]router-id 3.3.3.3 # 指定RID
[r3-bgp]confederation id 2 # 声明自己的大AS号(真实所在的AS号)
[r3-bgp]peer 1.1.1.1 as-number 64512 # 联邦成员建立IBGP邻居关系时使用小号
[r3-bgp]confederation peer-as 64513 # 需要建立联邦的EBGP对等体关系时,需要先声明对方的小号
[r3-bgp]peer 4.4.4.4 as-number 64513
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 ebgp-max-hop 2 # 联邦间使用EBGP路由传递规则,所以,默认的TTL值1,使用环回建立时需修改
同反射器一样,打破了IBGP水平分割,有可能会造成环路,所以联邦也需要解决环路问题。联邦EBGP之间防环可以直接采用EBGP水平分割的机制来进行防环,直接在AS_PATH属性中增加联邦AS号来进行防环,只不过,联邦的AS号会使用括号括起来,来进行区分。
<r3>display bgp routing-table
BGP Local router ID is 172.16.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 6
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.0.0.0/24 172.16.0.1 0 100 0 1i
*>i 11.0.0.0/24 172.16.130.1 0 100 0 (64513) 3i
*>i 12.1.1.0/24 172.16.0.1 0 100 0 i
*>i 78.1.1.0/24 172.16.130.1 0 100 0 (64513)i
*>i 172.16.0.0 172.16.0.1 100 0 ?
* i 172.16.130.1 100 0 (64513)?
#
sysname r1
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 12.1.1.1 255.255.255.0
#
interface LoopBack1
ip address 192.168.1.1 255.255.255.0
# 创建tunnel口,搭建GRE隧道
interface Tunnel0/0/0
ip address 192.168.3.1 255.255.255.0
tunnel-protocol gre
source 12.1.1.1
destination 78.1.1.2
# 运行BGP
bgp 1
router-id 1.1.1.1
peer 12.1.1.2 as-number 2
network 10.0.0.0 255.255.255.0
# 静态路由配合GRE
ip route-static 192.168.2.0 255.255.255.0 Tunnel0/0/0
#
#
sysname r2
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 12.1.1.2 255.255.255.0
#
interface GigabitEthernet0/0/1
ip address 172.16.3.1 255.255.255.248
#
interface GigabitEthernet0/0/2
ip address 172.16.131.1 255.255.255.248
#
interface LoopBack0
ip address 172.16.0.1 255.255.255.0
# 运行BGP
bgp 64512
router-id 2.2.2.2
confederation id 2
confederation peer-as 64513
peer 12.1.1.1 as-number 1
peer 172.16.1.1 as-number 64512
peer 172.16.1.1 connect-interface LoopBack0
peer 172.16.128.1 as-number 64513
peer 172.16.128.1 ebgp-max-hop 2
peer 172.16.128.1 connect-interface LoopBack0
summary automatic
network 12.1.1.0 255.255.255.0
import-route ospf 1
peer 172.16.1.1 next-hop-local
peer 172.16.128.1 next-hop-local
# 运行OSPF
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 172.16.0.0 0.0.127.255
area 0.0.0.1
network 172.16.128.0 0.0.127.255
stub no-summary
#
#
sysname r3
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 172.16.3.2 255.255.255.248
#
interface GigabitEthernet0/0/1
ip address 172.16.3.9 255.255.255.248
#
interface LoopBack0
ip address 172.16.1.1 255.255.255.0
# 运行BGP
bgp 64512
peer 172.16.0.1 as-number 64512
peer 172.16.0.1 connect-interface LoopBack0
peer 172.16.2.1 as-number 64512
peer 172.16.2.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 172.16.0.1 enable
peer 172.16.0.1 reflect-client
peer 172.16.2.1 enable
# 运行OSPF
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 172.16.0.0 0.0.127.255
#
#
sysname r4
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 172.16.3.10 255.255.255.248
#
interface GigabitEthernet0/0/1
ip address 172.16.3.17 255.255.255.248
#
interface LoopBack0
ip address 172.16.2.1 255.255.255.0
# 运行BGP
bgp 64512
router-id 4.4.4.4
confederation id 2
confederation peer-as 64513
peer 172.16.1.1 as-number 64512
peer 172.16.1.1 connect-interface LoopBack0
peer 172.16.130.1 as-number 64513
peer 172.16.130.1 ebgp-max-hop 2
peer 172.16.130.1 connect-interface LoopBack0
# 运行OSPF
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 172.16.0.0 0.0.127.255
#
#
sysname r5
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 172.16.131.2 255.255.255.248
#
interface GigabitEthernet0/0/1
ip address 172.16.131.9 255.255.255.248
#
interface LoopBack0
ip address 172.16.128.1 255.255.255.0
# 运行BGP
bgp 64513
router-id 5.5.5.5
confederation id 2
confederation peer-as 64512
peer 172.16.0.1 as-number 64512
peer 172.16.0.1 ebgp-max-hop 2
peer 172.16.0.1 connect-interface LoopBack0
peer 172.16.129.1 as-number 64513
peer 172.16.129.1 connect-interface LoopBack0
# 运行OSPF
ospf 1 router-id 5.5.5.5
area 0.0.0.1
network 172.16.128.0 0.0.127.255
stub
#
#
sysname r6
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 172.16.131.10 255.255.255.248
#
interface GigabitEthernet0/0/1
ip address 172.16.131.17 255.255.255.248
#
interface LoopBack0
ip address 172.16.129.1 255.255.255.0
# 运行BGP
bgp 64513
router-id 6.6.6.6
confederation id 2
peer 172.16.128.1 as-number 64513
peer 172.16.128.1 connect-interface LoopBack0
peer 172.16.130.1 as-number 64513
peer 172.16.130.1 connect-interface LoopBack0
peer 172.16.130.1 reflect-client
# 运行OSPF
ospf 1 router-id 6.6.6.6
area 0.0.0.1
network 172.16.128.0 0.0.127.255
stub
#
#
sysname r7
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 172.16.131.18 255.255.255.248
#
interface GigabitEthernet0/0/1
ip address 172.16.3.18 255.255.255.248
#
interface GigabitEthernet0/0/2
ip address 78.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 172.16.130.1 255.255.255.0
# 运行BGP
bgp 64513
router-id 7.7.7.7
confederation id 2
confederation peer-as 64512
peer 78.1.1.2 as-number 3
peer 172.16.2.1 as-number 64512
peer 172.16.2.1 ebgp-max-hop 2
peer 172.16.2.1 connect-interface LoopBack0
peer 172.16.129.1 as-number 64513
peer 172.16.129.1 connect-interface LoopBack0
summary automatic
network 78.1.1.0 255.255.255.0
import-route ospf 1
peer 172.16.2.1 next-hop-local
peer 172.16.129.1 next-hop-local
#
ospf 1 router-id 7.7.7.7
area 0.0.0.0
network 172.16.0.0 0.0.127.255
area 0.0.0.1
network 172.16.128.0 0.0.127.255
stub no-summary
#
#
sysname r8
#
# 配置接口IP
interface GigabitEthernet0/0/0
ip address 78.1.1.2 255.255.255.0
#
interface LoopBack0
ip address 11.0.0.1 255.255.255.0
#
interface LoopBack1
ip address 192.168.2.1 255.255.255.0
# 创建tunnel口,搭建GRE隧道
interface Tunnel0/0/0
description 10.0.0.1
ip address 192.168.3.2 255.255.255.0
tunnel-protocol gre
source 78.1.1.2
destination 12.1.1.1
# 运行BGP
bgp 3
router-id 8.8.8.8
peer 78.1.1.1 as-number 2
network 11.0.0.0 255.255.255.0
# 静态路由配合GRE
ip route-static 192.168.1.0 255.255.255.0 Tunnel0/0/0
#