BGP下有两种方法生成聚合地址,第一种方法是在路由表中为聚合路由建立一条静态路由条目,然后用network命令通告出去,第二种方法是用aggregate-address命令生成聚合地址.
命令aggregate-address使用注意事项,在通告聚合地址的ROUTE上,如果只用aggregate-address通告聚合地址,那么聚合路由和详细路由都通告给对等体,如果在aggregate-address后加上关键字summary-only,那么将只通告聚合路由.
实验
拓扑图

在AS 100 中用网络192.168.192.0/24---192.168.198.0/24的网络,使用LOOPBACK接口实现,AS 100向AS 200通告聚合路由和全部详细路由,在R4和R5上重分布直连,AS 200中只向AS 100通告聚合地址,在R2和R3上使用ROUTE-MAP,设置BGP的团体属性,如果路由与访问列表匹配,则不设置团体属性,如果不匹配,就给该路由分配一个NO_EXPORT的团体属性.
因为使用TELNET配置ROUTE,所以E0口被占用,在重分布时使用ROUTE-MAP E0过滤掉E0的地址.
R5的配置
interface Loopback0
ip address 50.50.50.50 255.255.255.0
!
interface Loopback1
ip address 192.168.192.1 255.255.255.0
!
interface Loopback2
ip address 192.168.193.1 255.255.255.0
!
interface Loopback3
ip address 192.168.195.1 255.255.255.0
!
interface Loopback4
ip address 192.168.196.1 255.255.255.0
!
interface Loopback5
ip address 192.168.197.1 255.255.255.0
!
interface Loopback6
ip address 192.168.198.1 255.255.255.0
!
interface Loopback7
ip address 192.168.199.1 255.255.255.0
!
interface Loopback8
ip address 192.168.194.1 255.255.255.0
!
interface Ethernet0
ip address 192.168.100.6 255.255.255.0
!
interface Serial0
ip address 192.168.1.245 255.255.255.252
clockrate 64000
!
interface Serial1
no ip address
!
router bgp 100
bgp router-id 5.5.5.5
bgp cluster-id 67372036
bgp log-neighbor-changes
aggregate-address 192.168.192.0 255.255.248.0
redistribute connected route-map e0
neighbor 192.168.1.246 remote-as 200
neighbor 192.168.1.246 send-community
neighbor 192.168.1.246 route-map comm out
!
no ip classless
no ip http server
!
access-list 1 deny 192.168.100.0 0.0.0.255
access-list 1 permit any
access-list 101 permit ip host 192.168.192.0 host 255.255.248.0
route-map comm permit 10
match ip address 101
set community none
!
route-map comm permit 20
set community no-export
!
route-map e0 permit 1
match ip address 1
!
R4的配置
interface Loopback0
ip address 40.40.40.40 255.255.255.0
!
interface Loopback1
ip address 192.168.192.1 255.255.255.0
!
interface Loopback2
ip address 192.168.193.1 255.255.255.0
!
interface Loopback3
ip address 192.168.194.1 255.255.255.0
!
interface Loopback4
ip address 192.168.195.1 255.255.255.0
!
interface Loopback5
ip address 192.168.196.1 255.255.255.0
!
interface Loopback6
ip address 192.168.197.1 255.255.255.0
!
interface Loopback7
ip address 192.168.198.1 255.255.255.0
!
interface Loopback8
ip address 192.168.199.1 255.255.255.0
!
interface Ethernet0
ip address 192.168.100.5 255.255.255.0
!
interface Serial0
no ip address
!
interface Serial1
ip address 192.168.1.254 255.255.255.252
clockrate 64000
!
router bgp 100
bgp router-id 4.4.4.4
bgp log-neighbor-changes
aggregate-address 192.168.192.0 255.255.248.0
redistribute connected route-map e0
neighbor 192.168.1.253 remote-as 200
neighbor 192.168.1.253 send-community
neighbor 192.168.1.253 route-map comm out
!
ip classless
no ip http server
!
access-list 1 deny 192.168.100.0 0.0.0.255
access-list 1 permit any
access-list 101 permit ip host 192.168.192.0 host 255.255.248.0
route-map comm permit 10
match ip address 101
set community none
!
route-map comm permit 20
set community no-export
!
route-map e0 permit 10
match ip address 1
!
R2的配置
router bgp 200
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 192.168.1.250 remote-as 300
neighbor 192.168.1.254 remote-as 100
neighbor 192.168.100.4 remote-as 200
!
R3的配置
router bgp 200
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 192.168.1.242 remote-as 300
neighbor 192.168.1.245 remote-as 100
neighbor 192.168.100.3 remote-as 200
!
R1的配置
router bgp 300
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 192.168.1.241 remote-as 200
neighbor 192.168.1.249 remote-as 200
!
现在我们来看看R2和R3的BGP路由表
R2#sho ip b
BGP table version is 69, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i192.168.1.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.192.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.192.0/21 192.168.1.245 100 0 100 i
*> 192.168.1.254 0 100 i
* i192.168.193.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.194.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.195.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.196.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.197.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.198.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
* i192.168.199.0 192.168.1.245 0 100 0 100 ?
*> 192.168.1.254 0 0 100 ?
R3#sho ip b
BGP table version is 38, local router ID is 3.3.3.3
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 192.168.1.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.192.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.192.0/21 192.168.1.245 0 100 i
* i 192.168.1.254 100 0 100 i
*> 192.168.193.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.194.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.195.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.196.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.197.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.198.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
*> 192.168.199.0 192.168.1.245 0 0 100 ?
* i 192.168.1.254 0 100 0 100 ?
接下来我们可以看下带有NO_EXPORT属性的路由条目
R2#sho ip b community no-export
BGP table version is 69, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 192.168.1.0 192.168.1.254 0 0 100 ?
*> 192.168.192.0 192.168.1.254 0 0 100 ?
*> 192.168.193.0 192.168.1.254 0 0 100 ?
*> 192.168.194.0 192.168.1.254 0 0 100 ?
*> 192.168.195.0 192.168.1.254 0 0 100 ?
*> 192.168.196.0 192.168.1.254 0 0 100 ?
*> 192.168.197.0 192.168.1.254 0 0 100 ?
*> 192.168.198.0 192.168.1.254 0 0 100 ?
*> 192.168.199.0 192.168.1.254 0 0 100 ?
在R3上看到的带有NO_EXPORT的路由,只有NEXT-HOP和R不同(192.168.1.245),所以就不贴了.
现在可以看看R1上BGP的路由表
R1#sho ip b
BGP table version is 37, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 192.168.192.0/21 192.168.1.241 0 200 100 i
*>192.168.1.249 0 200 100 i
至此本次实验成功.
| 第1页: BGP聚合路由实验 |