11.11.11.11/32 will be appear in R2 with community value 100:111 and local pref 10000 while 111.111.111.111/32 will be shown with community value 100:1212 ( default local pref 100) and metric (MED) 150.
Here is lab topology.
Download lab files from here.
Download completed files from here.
Configure R1 and R2 with following IP address and establish EBGP as below.
In R1,
interface Loopback0
ip address 11.11.11.11 255.255.255.255
!
interface Loopback1
ip address 111.111.111.111 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
-------------------------------
router bgp 100
no synchronization
bgp router-id 1.1.1.1
neighbor 192.168.1.2 remote-as 200
--------------------------------------------------
In R2,
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.0
-----------------
router bgp 200
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 192.168.1.1 remote-as 100
------------------------------------------------------
Start configure bgp-community new format to allow in both routers as follow;
ip bgp-community new-format
------------------------------------
Create the following route-map in R1 to send to R2. It means access list 1 prefix will set community (100:111) and access list 2 will be set 100:1212. Add final route map permit 20 as usual.
route-map r2 permit 10
match ip address 1
set community 100:111
!
route-map r2 permit 15
match ip address 2
set community 100:1212
!
route-map r2 permit 20
------------------------------------------
Create IP access list to permit 11.11.11.11/32 and 111.111.111.111/32 as follow;
access-list 1 permit 11.11.11.11
access-list 2 permit 111.111.111.111
-------------------------------------------
Final step is to configure in BGP mode to announce these community values to R2 and announce two networks.
router bgp 100
no synchronization
bgp router-id 1.1.1.1
bgp log-neighbor-changes
network 11.11.11.11 mask 255.255.255.255
network 111.111.111.111 mask 255.255.255.255
neighbor 192.168.1.2 remote-as 200
neighbor 192.168.1.2 send-community
neighbor 192.168.1.2 route-map r2 out
-------------------------------------------------
Ok, here are the steps in R2 to capture the community values send from R1 and set different BGP attributes.
Set ip community list exactly as from R1 in configuration mode.
ip community-list 1 permit 100:111
ip community-list 2 permit 100:1212
Create route-map as follow ;
route-map fromr1 permit 10
match community 1
set local-preference 10000
!
route-map fromr1 permit 15
match community 2
set metric 150
!
route-map fromr1 permit 20
---------------------------------------------
Finally, apply these route-map to R1 in BGP configuration mode as follow;
router bgp 200
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 192.168.1.1 remote-as 100
neighbor 192.168.1.1 route-map fromr1 in
----------------------------------------------------------
Clear ip bgp * in one of the router before checking bgp routes.
Here is how to check the community value send from R1 in R2 as follow;
R2#sh ip bgp 11.11.11.11
BGP routing table entry for 11.11.11.11/32, version 2
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
100
192.168.1.1 from 192.168.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 10000, valid, external, best
Community: 100:111
--------------------------------------
R2#sh ip bgp 111.111.111.111
BGP routing table entry for 111.111.111.111/32, version 3
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
100
192.168.1.1 from 192.168.1.1 (1.1.1.1)
Origin IGP, metric 150, localpref 100, valid, external, best
Community: 100:1212