拓扑:
1. no-export属性
当一台路由器,收到一个bgp的路由带有no-export属性是这台路由器就不会再向EBGP对等体发送该路由了
R1:
Router>en
Router#conf t
Router(config)#host R1
R1(config)#no ip do lo
R1(config)#line cons 0
R1(config-line)#no exec-t
R1(config-line)#logg sync
R1(config-line)#exi
R1(config)#int s1/1
R1(config-if)#ip add 10.1.1.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int lo 0
R1(config-if)#ip add 172.16.1.1 255.255.255.0
R1(config-if)#ip add 172.16.2.1 255.255.255.0 s
R1(config-if)#ip add 172.16.3.1 255.255.255.0 s
R1(config-if)#router bgp 1
R1(config-router)#net 172.16.1.0 mask 255.255.255.0
R1(config-router)#net 172.16.2.0 mask 255.255.255.0
R1(config-router)#net 172.16.3.0 mask 255.255.255.0
R1(config-router)#nei 10.1.1.2 remote 2
R1(config-router)#end
没配置NO-EXPORT时,R3仍学到所有路由
R3#sh ip bgp
BGP table version is 6, local router ID is 10.2.2.2
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
*> 10.1.1.0/24 10.2.2.1 0 0 2 i
* 10.2.2.0/24 10.2.2.1 0 0 2 i
*> 0.0.0.0 0 32768 i
*> 172.16.1.0/24 10.2.2.1 0 2 1 i
*> 172.16.2.0/24 10.2.2.1 0 2 1 i
*> 172.16.3.0/24 10.2.2.1 0 2 1 i
配置EX-EXPORT
R1(config)#access-list 1 per 172.16.3.0 0.0.0.255
R1(config)#route-map ccxx per 10
R1(config-route-map)#ma ip add 1
R1(config-route-map)#set community no-export
R1(config-route-map)#exi
R1(config)#route-map ccxx per 20 (写一个空条目)
R1(config-route-map)#exi
R1(config)#router bgp 1
R1(config-router)#nei 10.1.1.2 route-map ccxx out
R1(config-router)#nei 10.1.1.2 send-community
配好后:
R1#cle ip bgp * so out
查看R2 R3路由表
R2#sh ip bgp
BGP table version is 5, local router ID is 10.2.2.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
*> 172.16.1.0/24 10.1.1.1 0 0 1 i
*> 172.16.2.0/24 10.1.1.1 0 0 1 i
*> 172.16.3.0/24 10.1.1.1 0 0 1 i
R3#sh ip bgp
BGP table version is 5, local router ID is 10.2.2.2
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
*> 172.16.1.0/24 10.2.2.1 0 2 1 i
*> 172.16.2.0/24 10.2.2.1 0 2 1 i
(R3没学到172.16.3.0 这一网络吧!!!!!)
R2#sh ip bgp 172.16.3.1
BGP routing table entry for 172.16.3.0/24, version 5
Paths: (1 available, best #1, table Default-IP-Routing-Table, not advertised to EBGP peer)
Not advertised to any peer
1
10.1.1.1 from 10.1.1.1 (172.16.1.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: no-export