巩固下BGP的知识点,就把BGP中联邦和团体的属性集中在一个实验中,分享给大家。先上拓扑图:
PS:AS200内部IGP跑ospf协议,划分2个子AS 65001.65002,所有路由器起BGP协议
通过BGP-COMMUNITY属性,R2能学到R1通告的所有路由,R3学不到111.111.33.0这个条目,R4学不到111.111.22.0,R5只能学到1.1.1.0这个条目
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
ip address 111.111.111.1 255.255.255.0
!
interface Loopback2
ip address 111.111.22.1 255.255.255.0
!
interface Loopback3
ip address 111.111.33.1 255.255.255.0
!
interface FastEthernet0/0
ip address 12.1.1.1 255.255.255.0
duplex auto
speed auto
!
router bgp 100
no synchronization
bgp log-neighbor-changes
network 1.1.1.0 mask 255.255.255.0
network 111.111.22.0 mask 255.255.255.0
network 111.111.33.0 mask 255.255.255.0
network 111.111.111.0 mask 255.255.255.0
neighbor 12.1.1.2 remote-as 200
neighbor 12.1.1.2 send-community
neighbor 12.1.1.2 route-map set_community out
no auto-summary
access-list 10 permit 1.1.1.0 0.0.0.255
access-list 20 permit 111.111.111.0 0.0.0.255
access-list 30 permit 111.111.22.0 0.0.0.255
access-list 40 permit 111.111.33.0 0.0.0.255
route-map set_community permit 10
match ip address 40
set community no-advertise
!
route-map set_community permit 20
match ip address 30
set community local-AS
!
route-map set_community permit 30
match ip address 20
set community no-export
!
route-map set_community permit 40
R2:
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Loopback1
ip address 222.222.222.2 255.255.255.0
!
interface FastEthernet0/0
ip address 12.1.1.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 23.1.1.1 255.255.255.0
duplex auto
speed auto
!
router ospf 200
router-id 2.2.2.2
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 65001
no synchronization
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65002
network 2.2.2.0 mask 255.255.255.0
network 222.222.222.0
neighbor 3.3.3.3 remote-as 65001
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 3.3.3.3 send-community
neighbor 12.1.1.1 remote-as 100
no auto-summary
R3:
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Loopback1
ip address 33.33.33.3 255.255.255.0
!
interface FastEthernet0/0
ip address 34.1.1.1 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 23.1.1.2 255.255.255.0
duplex auto
speed auto
!
router ospf 200
router-id 3.3.3.3
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 65001
no synchronization
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65002
network 3.3.3.0 mask 255.255.255.0
network 33.33.33.0 mask 255.255.255.0
neighbor 2.2.2.2 remote-as 65001
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 4.4.4.4 remote-as 65002
neighbor 4.4.4.4 ebgp-multihop 20
neighbor 4.4.4.4 update-source Loopback0
neighbor 4.4.4.4 send-community
no auto-summary
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.0
!
interface Loopback1
ip address 44.44.44.4 255.255.255.0
!
interface FastEthernet0/0
ip address 34.1.1.2 255.255.255.0
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 45.1.1.1 255.255.255.0
duplex auto
speed auto
!
router ospf 200
router-id 4.4.4.4
log-adjacency-changes
network 0.0.0.0 255.255.255.255 area 0
!
router bgp 65002
no synchronization
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65001
network 4.4.4.0 mask 255.255.255.0
network 44.44.44.0 mask 255.255.255.0
neighbor 3.3.3.3 remote-as 65001
neighbor 3.3.3.3 ebgp-multihop 20
neighbor 3.3.3.3 update-source Loopback0
neighbor 45.1.1.2 remote-as 300
no auto-summary
R5:
interface Loopback0
ip address 5.5.5.5 255.255.255.0
!
interface Loopback1
ip address 55.55.55.5 255.255.255.0
!
interface FastEthernet0/0
no ip address
shutdown
duplex auto
speed auto
!
interface FastEthernet1/0
ip address 45.1.1.2 255.255.255.0
duplex auto
speed auto
!
router bgp 300
no synchronization
bgp log-neighbor-changes
network 5.5.5.0 mask 255.255.255.0
network 55.55.55.0 mask 255.255.255.0
neighbor 45.1.1.1 remote-as 200
no auto-summary
配置完以后我们来看下路由表
r1#show ip bgp
BGP table version is 13, local router ID is 111.111.111.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
*> 1.1.1.0/24 0.0.0.0 0 32768 i
*> 2.2.2.0/24 12.1.1.2 0 0 200 i
*> 3.3.3.0/24 12.1.1.2 0 200 i
*> 4.4.4.0/24 12.1.1.2 0 200 i
*> 5.5.5.0/24 12.1.1.2 0 200 300 i
*> 33.33.33.0/24 12.1.1.2 0 200 i
*> 44.44.44.0/24 12.1.1.2 0 200 i
*> 55.55.55.0/24 12.1.1.2 0 200 300 i
*> 111.111.22.0/24 0.0.0.0 0 32768 i
*> 111.111.33.0/24 0.0.0.0 0 32768 i
*> 111.111.111.0/24 0.0.0.0 0 32768 i
*> 222.222.222.0 12.1.1.2 0 0 200 i
R1通告了4条路由分别是:1.1.1.0/24 111.111.22.0/24 111.111.33.0/24 111.111.111.0/24
r2#show ip bgp
BGP table version is 25, local router ID is 222.222.222.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
*> 1.1.1.0/24 12.1.1.1 0 0 100 i
*> 2.2.2.0/24 0.0.0.0 0 32768 i
*>i3.3.3.0/24 3.3.3.3 0 100 0 i
*>i4.4.4.0/24 3.3.3.3 0 100 0 (65002) i
*>i5.5.5.0/24 3.3.3.3 0 100 0 (65002) 300 i
*>i33.33.33.0/24 3.3.3.3 0 100 0 i
*>i44.44.44.0/24 3.3.3.3 0 100 0 (65002) i
*>i55.55.55.0/24 3.3.3.3 0 100 0 (65002) 300 i
*> 111.111.22.0/24 12.1.1.1 0 0 100 i
*> 111.111.33.0/24 12.1.1.1 0 0 100 i
*> 111.111.111.0/24 12.1.1.1 0 0 100 i
*> 222.222.222.0 0.0.0.0 0 32768 i
R2从R1那4条路由都学到了
r3#show ip bgp
BGP table version is 38, local router ID is 33.33.33.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
*>i1.1.1.0/24 2.2.2.2 0 100 0 100 i
*>i2.2.2.0/24 2.2.2.2 0 100 0 i
*> 3.3.3.0/24 0.0.0.0 0 32768 i
*> 4.4.4.0/24 4.4.4.4 0 100 0 (65002) i
*> 5.5.5.0/24 45.1.1.2 0 100 0 (65002) 300 i
*> 33.33.33.0/24 0.0.0.0 0 32768 i
*> 44.44.44.0/24 4.4.4.4 0 100 0 (65002) i
*> 55.55.55.0/24 45.1.1.2 0 100 0 (65002) 300 i
*>i111.111.22.0/24 2.2.2.2 0 100 0 100 i
*>i111.111.111.0/24 2.2.2.2 0 100 0 100 i
*>i222.222.222.0 2.2.2.2 0 100 0 i
R3没有学到111.111.33.0/24这个条目,因为R2从R1上收到这个条目的属性是no-advertise,因此没有向R3宣告
r4#show ip bgp
BGP table version is 37, local router ID is 44.44.44.4
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
*> 1.1.1.0/24 2.2.2.2 0 100 0 (65001) 100 i
*> 2.2.2.0/24 2.2.2.2 0 100 0 (65001) i
*> 3.3.3.0/24 3.3.3.3 0 100 0 (65001) i
*> 4.4.4.0/24 0.0.0.0 0 32768 i
*> 5.5.5.0/24 45.1.1.2 0 0 300 i
*> 33.33.33.0/24 3.3.3.3 0 100 0 (65001) i
*> 44.44.44.0/24 0.0.0.0 0 32768 i
*> 55.55.55.0/24 45.1.1.2 0 0 300 i
*> 111.111.111.0/24 2.2.2.2 0 100 0 (65001) 100 i
*> 222.222.222.0 2.2.2.2 0 100 0 (65001) i
R4从R3那没有学到111.111.22.0这个条目,因为111.111.22.0这个路由条目的属性为local-as,只在联邦内AS传播
r5#show ip bgp
BGP table version is 32, local router ID is 55.55.55.5
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
*> 1.1.1.0/24 45.1.1.1 0 200 100 i
*> 2.2.2.0/24 45.1.1.1 0 200 i
*> 3.3.3.0/24 45.1.1.1 0 200 i
*> 4.4.4.0/24 45.1.1.1 0 0 200 i
*> 5.5.5.0/24 0.0.0.0 0 32768 i
*> 33.33.33.0/24 45.1.1.1 0 200 i
*> 44.44.44.0/24 45.1.1.1 0 0 200 i
*> 55.55.55.0/24 0.0.0.0 0 32768 i
*> 222.222.222.0 45.1.1.1 0 200 i
R4收到111.111.111.0这个条目的属性为no-export,因此它不向R5宣告这条路由