BGP Community Properties (Lab)
Set the BGP routing policy according to the community attribute of BGP routing
R1 configuration:
Loopback0 1.1.1.1
Loopback1 192.168.1.1/24
Loopback2 192.168.2.1/24
Loopback3 192.168.3.1/24
Loopback4 192.168.4.1/24
E1/0 10.1.12.1
R2 configuration:
Loopback 2.2.2.2
E1/0 10.1.12.2
Configure IGP (RIP) to maintain connectivity:
R1 configuration:
Router rip
Version 2
Network 1.0.0.0
Network 10.0.0.0
Network 192.168.1.0
Network 192.168.2.0
Network 192.168.3.0
Network 192.168.4.0
No auto-summary
R2 configuration:
Router rip
Version 2
Network 2.0.0.0
Network 10.0.0.0
No auto-summary
Start configuring BGP (EBGP):
R1
Router bgp 109
Bgp router-id 1.1.1.1
Bgp log-neighbor-changes
Network 1.1.1.1 mask 255.255.255.255
Network 10.1.12.0 mask 255.255.255.0
Network 192.168.1.0
Network 192.168.2.0
Network 192.168.3.0
Network 192.168.4.0
Neighbor 10.1.12.2 remote-as 110
R2
Router bgp 110
Bgp router-id 2.2.2.2
Bgp log-neighbor-changes
Network 1.1.1.1 mask 255.255.255.255
Network 10.1.12.0 mask 255.255.255.0
Neighbor 10.1.12.1 remote-as 109
Neighbor 10.1.12.1 route-map set_local_pref in
R2#sh ip bgp
BGP table version is 7, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, I-internal
R RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter
X best-external, an additional-path, c RIB-compressed
Origin codes: I-IGP, e-EGP,?-incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* > 1.1.1.1 Compact 32 10.1.12.1 1 32768 I
* > 10.1.12.0 Compact 24 0.0.0.0 32768 I
* > 192.168.1.0 10.1.12.1 0 200 0 109 I
* > 192.168.2.0 10.1.12.1 0 200 0 109 I
* > 192.168.3.0 10.1.12.1 0 150 0109 I
* > 192.168.4.0 10.1.12.1 0 150 0109 I
R1 configure Community Properties
Step 1: turn on the router support community attribute
Ip bgp-community new-format
Step 2, configure the prefix-list list
Ip prefix-list 1 permit 192.168.1.0/24
Ip prefix-list 1 permit 192.168.2.0/24
Ip prefix-list 2 permit 192.168.3.0/24
Ip prefix-list 2 permit 192.168.4.0/24
Step 3, configure route-map set_community
Route-map set_community permit 10
Match ip address prefix-list 1
Set community 109:1
Route-map set_community permit 20
Match ip address prefix-list 2
Set community 109:2
The fourth step is to call the
Neighbor 10.1.12.2 send-community
Neighbor 10.1.12.2 route-map set_community out
Route-map set_local_pref is configured on R2 to match the routes with community attributes passed by R1 and attach a specific local-preference
Step 1: turn on the router support community attribute
Ip bgp-community new-format
Step 2: set the list of community properties
Ip prefix-list 1 seq 5 permit 192.168.2.0/24
Ip prefix-list 1 seq 10 permit 192.168.4.0/24
Step 3:
Route-map set_local_pref permit 10
Match community 1
Set local-preference 200
Route-map set_local_pref permit 20
Match community 2
Set local-preference 150
Step 4: call route-map set_local_pref in BGP
Neighbor 10.1.12.1 route-map set_local_pref in
Verify the configuration:
R2#sh ip bgp
BGP table version is 7, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, I-internal
R RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter
X best-external, an additional-path, c RIB-compressed
Origin codes: I-IGP, e-EGP,?-incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* > 1.1.1.1 Compact 32 10.1.12.1 1 32768 I
* > 10.1.12.0 Compact 24 0.0.0.0 32768 I
* > 192.168.1.0 10.1.12.1 0 200 0 109 I
* > 192.168.2.0 10.1.12.1 0 200 0 109 I
* > 192.168.3.0 10.1.12.1 0 150 0109 I
* > 192.168.4.0 10.1.12.1 0 150 0109 I
R2#sh ip bgp 192.168.1.0
BGP routing table entry for 192.168.1.0/24, version 2
Paths: (1 available, best # 1, table default)
Not advertised to any peer
Refresh Epoch 1
one hundred and nine
10.1.12.1 from 10.1.12.1 (1.1.1.1)
Origin IGP, metric 0, localpref 200, valid, external, best
Community: 109:1
Rx pathid: 0, tx pathid: 0x0
The community attribute learned from R1 is to set the local priority to 200 for the route Community: 109. 1.
R2#sh ip bgp 192.168.3.0
BGP routing table entry for 192.168.3.0/24, version 4
Paths: (1 available, best # 1, table default)
Not advertised to any peer
Refresh Epoch 1
one hundred and nine
10.1.12.1 from 10.1.12.1 (1.1.1.1)
Origin IGP, metric 0, localpref 150, valid, external, best
Community: 109:2
Rx pathid: 0, tx pathid: 0x0
The community attribute learned from R1 is to set the local priority to 150 for the route Community: 109 2.
Routes that are not matched are passed at default values.