基本配置如上图,AS123内IGP为RIPv2!
基本配置完毕后,PING测试通过就继续下面!
各个路由器联邦配置:
R1:
router bgp 65012 //这里先启用AS123内的一个联邦
bgp ro 1.1.1.1
no sy
no au
nei 2.2.2.2 remote 65012
nei 2.2.2.2 up lo 0
nei 2.2.2.2 next-hop-self
nei 3.3.3.3 remote 65003
nei 3.3.3.3 up lo 0
nei 3.3.3.3 next-hop-self
bgp confederation identifier 123 // 表示联邦为AS123内的成员
bgp confederation peers 65003 //表示与联邦65003建立的是EBGP邻居关系
nei 3.3.3.3 ebgp-multihop 2 //既然是EBGP邻居关系就少不了这条命令,表示到邻居有2条
R2:
router bgp 65012
no sy
no au
bgp rou 2.2.2.2
nei 24.1.1.4 remote 400
bgp confederation identifier 123
nei 1.1.1.1 remote 65012
nei 1.1.1.1 up lo 0
nei 1.1.1.1 next-hop-self
R3:
router bgp 65003
no sy
no au
bgp rou 3.3.3.3
nei 35.1.1.5 remote 500
nei 1.1.1.1 remote 65012
nei 1.1.1.1 up lo 0
nei 1.1.1.1 next-hop-self
bgp confederation identifier 123
nei 1.1.1.1 ebgp-multihop 2
bgp confederation peers 65012
R4:
router bgp 400
bgp router-id 4.4.4.4
no sy
no au
nei 24.1.1.2 remote 123
net 4.4.4.0 mask 255.255.255.0
end
R5:
router bgp 500
bgp rou 5.5.5.5
no sy
no au
nei 35.1.1.3 remote 123
net 5.5.5.0 mask 255.255.255.0
end
R5#show ip bgp
BGP table version is 3, local router ID is 5.5.5.5
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.0/24 35.1.1.3 0 123 400 i
*> 5.5.5.0/24 0.0.0.0 0 32768 i
BGP邻居成功建立。
接下来在R4建立4个环回借口,并添加到BGP路由
R4命令如下:
int lo 0
ip ad 4.4.4.4 255.255.255.0
int lo 1
ip ad 172.1.12.1 255.255.255.0
int lo 2
ip ad 172.1.13.1 255.255.255.0
int lo 3
ip ad 172.1.14.1 255.255.255.0
int lo 4
ip ad 172.1.15.1 255.255.255.0
exit
router bgp 400
net 172.1.12.0 mask 255.255.255.0
net 172.1.13.0 mask 255.255.255.0
net 172.1.14.0 mask 255.255.255.0
net 172.1.15.0 mask 255.255.255.0
R5#show ip bgp
BGP table version is 7, local router ID is 5.5.5.5
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.0/24 35.1.1.3 0 123 400 i
*> 5.5.5.0/24 0.0.0.0 0 32768 i
*> 172.1.12.0/24 35.1.1.3 0 123 400 i
*> 172.1.13.0/24 35.1.1.3 0 123 400 i
*> 172.1.14.0/24 35.1.1.3 0 123 400 i
*> 172.1.15.0/24 35.1.1.3 0 123 400 i
各个路由器已经学到。。
现在重点来了:
要求R1只能学到3条路由,R3只能学到2条。R5只能学到一条。
引入BGP的几个属性:
Loacl AS:相当于当有联邦AS时,加上这个属性的路由不会被传出联邦AS
No-export:不传出大的AS,也就是不传给EBPG邻居
No-advertise:谁也不传送。
在R4上的配置:
R4(config)#ip prefix-list 12 per 172.1.12.0/24
R4(config)#ip prefix-list 13 per 172.1.13.0/24
R4(config)#ip prefix-list 14 per 172.1.14.0/24
R4(config)#ip prefix-list 15 per 172.1.15.0/24
给路由加属性,控制路由的传送
R4(config)#route-map comm per 10
R4(config-route-map)#match ip ad prefix-list 12
R4(config-route-map)#set community no-advertise 谁也不公告
R4(config)#route-map comm per 20
R4(config-route-map)#mat ip ad pre 13
R4(config-route-map)#set community local-AS 不出联邦AS
R4(config-route-map)#exit
R4(config)#route-map comm per 30
R4(config-route-map)#mat ip ad pre 14
R4(config-route-map)#set community no-export 不传出大的AS,也就是不传给EBGP
R4(config-route-map)#exit
R4(config)#route-map comm per 40
R4(config-route-map)#mat ip ad pre 15
R4(config-route-map)#set commun none 什么也不做
R4(config-router)#nei 24.1.1.2 route-map comm out
R4(config-router)#nei 24.1.1.2 send-community 需要在每个路由器上打,因为这样才能把路由的属性传出,以达到控制路由的目的
R2(config-router)#nei 1.1.1.1send-community
172.1.12.0/24谁也不公告
172.1.13.0/24 不出联邦AS
172.1.14.0/24 不传给EBGP
172.1.15.0/24 无限制
也就是说在R1上只能学到:PS:学不到就刷新下 clear ip bgp *
172.1.13.0/24
172.1.14.0/24
172.1.15.0/24
在R3上能学到
172.1.14.0/24
172.1.15.0/24
在R5上能学到
172.1.15.0/24
R1#show ip bgp
BGP table version is 11, local router ID is 1.1.1.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
*> 5.5.5.0/24 3.3.3.3 0 100 0 (65003) 500 i
*>i172.1.13.0/24 2.2.2.2 0 100 0 400 i
*>i172.1.14.0/24 2.2.2.2 0 100 0 400 i
*>i172.1.15.0/24 2.2.2.2 0 100 0 400 i
R3#show ip bgp
BGP table version is 11, local router ID is 3.3.3.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
*> 5.5.5.0/24 35.1.1.5 0 0 500 i
*> 172.1.14.0/24 1.1.1.1 0 100 0 (65012) 400 i
*> 172.1.15.0/24 1.1.1.1 0 100 0 (65012) 400 i
R5#show ip bgp
BGP table version is 11, local router ID is 5.5.5.5
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
*> 5.5.5.0/24 0.0.0.0 0 32768 i
*> 172.1.15.0/24 35.1.1.3 0 123 400 i
OK实验成功。