Network Requirements
- Set up EBGP neighbors between Device1 and Device2.
- Device1 introduces two direct-connect routes 100.0.0.0/24 and 200.0.0.0/24 to BGP in network mode, and set different community properties for two routes that are advertised to Device2.
- When Device2 receives routes from Device1, it applies community properties in the incoming direction of a neighbor to filter route 100.0.0.0/24 and allow route 200.0.0.0/24.
Network Topology
Figure 12–3 Networking for configuring BGP community properties
Configuration Steps
Step 1: Configure the VLAN and join the interface to the corresponding VLAN. (Omitted)
Step 2: Configure the IP addresses of the interfaces. (Omitted)
Step 3: Configure BGP.
#Configure Device1.
Device1#configure terminal
Device1(config)#router bgp 100
Device1(config-bgp)#neighbor 2.0.0.2 remote-as 200
Device1(config-bgp)#network 100.0.0.0 255.255.255.0
Device1(config-bgp)#network 200.0.0.0 255.255.255.0
Device1(config-bgp)#exit
|
#Configure Device2.
Device2#configure terminal
Device2(config)#router bgp 200
Device2(config-bgp)#neighbor 2.0.0.1 remote-as 100
Device2(config-bgp)#exit
|
#On Device1, check the BGP neighbor status.
Device1#show ip bgp summary
BGP router identifier 200.0.0.1, local AS number 100 BGP table version is 1
1 BGP AS-PATH entries 0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
2.0.0.2 4 200 2 3 1 0 0 00:00:04 0
BGP neighbors have been successfully set up between Device1 and Device2.
#Query the routing table of Device2.
Device2#show ip route bgp
Codes: C - Connected, L - Local, S - static, R - RIP, B - BGP, i-ISIS
U - Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX - IRMP external
B 100.0.0.0/24 [20/0] via 2.0.0.1, 00:07:47, vlan2
B 200.0.0.0/24 [20/0] via 2.0.0.1, 00:07:47, vlan2
According to the queried information, Device2 has successfully learnt routes 100.0.0.0/24 and 200.0.0.0/24.
Step 4: Configure the ACL and routing policy, and set BGP community properties.
#Configure Device1.
Device1(config)#ip access-list standard 1
Device1(config-std-nacl)#permit 100.0.0.0 0.0.0.255
Device1(config-std-nacl)#commit
Device1(config-std-nacl)#exit
Device1(config)#ip access-list standard 2
Device1(config-std-nacl)#permit 200.0.0.0 0.0.0.255
Device1(config-std-nacl)#commit
Device1(config-std-nacl)#exit
Device1(config)#route-map CommunitySet 10
Device1(config-route-map)#match ip address 1
Device1(config-route-map)#set community 100:1
Device1(config-route-map)#exit
Device1(config)#route-map CommunitySet 20
Device1(config-route-map)#match ip address 2
Device1(config-route-map)#set community 100:2
Device1(config-route-map)#exit
|
Set different community properties for routes 100.0.0.0/24 and 200.0.0.0/24 respectively by configuring an ACL and routing policy.
Step 5: Configure a routing policy for BGP.
#Configure Device1.
Device1(config)#router bgp 100
Device1(config-bgp)#neighbor 2.0.0.2 route-map CommunitySet out
Device1(config-bgp)#neighbor 2.0.0.2 send-community
Device1(config-bgp)#exit
|
#Query the BGP routing table of Device2.
Device2#show ip bgp 100.0.0.0
BGP routing table entry for 100.0.0.0/24
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
100
2.0.0.1 (metric 10) from 2.0.0.1 (10.0.0.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: 100:1
Last update: 00:01:06 ago
Device2#show ip bgp 200.0.0.0
BGP routing table entry for 200.0.0.0/24
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
100
2.0.0.1 (metric 10) from 2.0.0.1 (10.0.0.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Community: 100:2
Last update: 00:01:10 ago
According to the BGP routing table of Device2, the community property of route 100.0.0.0/24 is set to 100:1, and the community properties of route 200.0.0.0/24 is set to 100:2.
Step 6: Configure BGP route filtration.
#Configure Device2.
Device2(config)#ip community-list 1 permit 100:2
Device2(config)#route-map communityfilter
Device2(config-route-map)#match community 1
Device2(config-route-map)#exit
Device2(config)#router bgp 200
Device2(config-bgp)#neighbor 2.0.0.1 route-map communityfilter in
Device2(config-bgp)#exit
|
Step 7: Check the result.
#Query the routing table of Device2.
Device2#show ip route bgp
Codes: C - Connected, L - Local, S - static, R - RIP, B - BGP, i-ISIS
U - Per-user Static route
O - OSPF, OE-OSPF External, M - Management, E - IRMP, EX - IRMP external
B 200.0.0.0/24 [20/0] via 2.0.0.1, 00:00:53, vlan2
According to the BGP routing table of Device2, route 100.0.0.0/24 has been filtered in the incoming direction, and route 200.0.0.0/24 has been allowed.
-
After a routing policy is configured on the peer, the BGP must be reset to make the configuration take effect.
- You must configure the send-community command to advertise the community property to the peer.