Network Requirements
- Set up IBGP neighbors between Device1 and Device2 and between Device1 and Device3, and set up EBGP neighbors between Device4 and Device2 and between Device4 and Device3.
- Device1 advertises two routes 55.0.0.0/24 and 65.0.0.0/24 to Device4, and Device4 advertises two routes 75.0.0.0/24 and 85.0.0.0/24 to Device1.
- Modify the Local-preference property of routes on Device2 and Device3 so that Device1 selects route 75.0.0.0/24 advertised by Device2 and route 85.0.0.0/24 advertised by Device3 with priority.
- Modify the MED property of routes on Device2 and Device3 so that Device4 selects route 55.0.0.0/24 advertised by Device2 and route 65.0.0.0/24 advertised by Device3 with priority.
Network Topology
Figure 12–6 Networking for configuring the BGP route selection priority
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 OSPF so that loopback routes are reachable between devices.
#Configure Device1.
Device1#configure terminal
Device1(config)#router ospf 100
Device1(config-ospf)#network 1.0.0.0 0.0.0.255 area 0
Device1(config-ospf)#network 2.0.0.0 0.0.0.255 area 0
Device1(config-ospf)#network 10.0.0.1 0.0.0.0 area 0
Device1(config-ospf)#exit
|
#Configure Device2.
Device2#configure terminal
Device2(config)#router ospf 100
Device2(config-ospf)#network 1.0.0.0 0.0.0.255 area 0
Device2(config-ospf)#network 20.0.0.1 0.0.0.0 area 0
Device2(config-ospf)#exit
|
#Configure Device3.
Device3#configure terminal
Device3(config)#router ospf 100
Device3(config-ospf)#network 2.0.0.0 0.0.0.255 area 0
Device3(config-ospf)#network 30.0.0.1 0.0.0.0 area 0
Device3(config-ospf)#exit
|
#Query the routing table of Device1.
Device1#show ip route ospf
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
O 20.0.0.1/32 [110/2] via 1.0.0.2, 00:03:15, vlan2
O 30.0.0.1/32 [110/2] via 2.0.0.2, 00:01:40, vlan3
#Query the routing table of Device2.
Device2#show ip route ospf
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
O 2.0.0.0/24 [110/2] via 1.0.0.1, 00:03:54, vlan2
O 10.0.0.1/32 [110/2] via 1.0.0.1, 00:03:54, vlan2
O 30.0.0.1/32 [110/3] via 1.0.0.1, 00:02:14, vlan2
#Query the routing table of Device3.
Device3#show ip route ospf
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
O 1.0.0.0/24 [110/2] via 2.0.0.1, 00:02:35, vlan2
O 10.0.0.1/32 [110/2] via 2.0.0.1, 00:02:35, vlan2
O 20.0.0.1/32 [110/3] via 2.0.0.1, 00:02:35, vlan2
According to the routing table, Device1, Device2, and Device3 have learnt the routes of the loopback interfaces of each other.
Step 4: Configure BGP.
#Configure Device1.
Device1(config)#router bgp 100
Device1(config-bgp)#neighbor 20.0.0.1 remote-as 100
Device1(config-bgp)#neighbor 20.0.0.1 update-source loopback0
Device1(config-bgp)#neighbor 30.0.0.1 remote-as 100
Device1(config-bgp)#neighbor 30.0.0.1 update-source loopback0
Device1(config-bgp)#network 55.0.0.0 255.255.255.0
Device1(config-bgp)#network 65.0.0.0 255.255.255.0
Device1(config-bgp)#exit
|
#Configure Device2.
Device2(config)#router bgp 100
Device2(config-bgp)#neighbor 10.0.0.1 remote-as 100
Device2(config-bgp)#neighbor 10.0.0.1 update-source loopback0
Device2(config-bgp)#neighbor 10.0.0.1 next-hop-self
Device2(config-bgp)#neighbor 3.0.0.1 remote-as 200
Device2(config-bgp)#exit
|
#Configure Device3.
Device3(config)#router bgp 100
Device3(config-bgp)#neighbor 10.0.0.1 remote-as 100
Device3(config-bgp)#neighbor 10.0.0.1 update-source loopback0
Device3(config-bgp)#neighbor 10.0.0.1 next-hop-self
Device3(config-bgp)#neighbor 4.0.0.1 remote-as 200
Device3(config-bgp)#exit
|
#Configure Device4.
Device4#configure terminal
Device4(config)#router bgp 200
Device4(config-bgp)#neighbor 3.0.0.2 remote-as 100
Device4(config-bgp)#neighbor 4.0.0.2 remote-as 100
Device4(config-bgp)#network 75.0.0.0 255.255.255.0
Device4(config-bgp)#network 85.0.0.0 255.255.255.0
Device4(config-bgp)#exit
|
#On Device1, check the BGP neighbor status.
Device1#show ip bgp summary
BGP router identifier 10.0.0.1, local AS number 100 BGP table version is 2
2 BGP AS-PATH entries 0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
20.0.0.1 4 100 11 11 2 0 0 00:07:40 2
30.0.0.1 4 100 7 7 2 0 0 00:03:59 2
#On Device4, check the BGP neighbor status.
Device4#show ip bgp summary
BGP router identifier 85.0.0.1, local AS number 200 BGP table version is 2
2 BGP AS-PATH entries 0 BGP community entries
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
3.0.0.2 4 100 5 6 2 0 0 00:02:24 2
4.0.0.2 4 100 6 5 2 0 0 00:02:24 2
IBGP neighbors have been set up between Device1 and Device2 and between Device2 and Device3, and EBGP neighbors have been set up between Device4 and Device2 and between Device4 and Device3.
#Query the routing table of Device1.
Device1#show ip bgp
BGP table version is 2, local router ID is 10.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
[B]*> 55.0.0.0/24 0.0.0.0 0 32768 i
[B]*> 65.0.0.0/24 0.0.0.0 0 32768 i
[B]* i75.0.0.0/24 30.0.0.1 0 100 0 200 i
[B]*>i 20.0.0.1 0 100 0 200 i
[B]* i85.0.0.0/24 30.0.0.1 0 100 0 200 i
[B]*>i 20.0.0.1 0 100 0 200 i
Device1#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 75.0.0.0/24 [200/0] via 20.0.0.1, 01:13:17, vlan2
B 85.0.0.0/24 [200/0] via 20.0.0.1, 01:13:17, vlan2
According to the routing table, both route 75.0.0.0/24 and route 85.0.0.0/24 of Device1, select Device2 as the next-hop device.
#Query the routing table of Device4.
Device4#show ip bgp
BGP table version is 2, local router ID is 85.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i internal,
S Stale
Origin codes: i - IGP, e - EGP, ? incomplete
Network Next Hop Metric LocPrf Weight Path
[B]* 55.0.0.0/24 3.0.0.2 0 0 100 i
[B]*> 4.0.0.2 0 0 100 i
[B]* 65.0.0.0/24 3.0.0.2 0 0 100 i
[B]*> 4.0.0.2 0 0 100 i
[B]*> 75.0.0.0/24 0.0.0.0 0 32768 i
[B]*> 85.0.0.0/24 0.0.0.0 0 32768 i
Device4#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 55.0.0.0/24 [20/0] via 4.0.0.2, 01:25:19, vlan3
B 65.0.0.0/24 [20/0] via 4.0.0.2, 01:25:19, vlan3
According to the routing table, both route 55.0.0.0/24 and route 65.0.0.0/24 of Device4, select Device3 as the next-hop device.
Step 5: Configure an ACL and routing policy to set local-preference and metric.
#Configure Device2.
Device2(config)#ip access-list standard 1
Device2(config-std-nacl)#permit 75.0.0.0 0.0.0.255
Device2(config-std-nacl)#commit
Device2(config-std-nacl)#exit
Device2(config)#ip access-list standard 2
Device2(config-std-nacl)#permit 65.0.0.0 0.0.0.255
Device2(config-std-nacl)#commit
Device2(config-std-nacl)#exit
Device2(config)#route-map SetPriority1 10
Device2(config-route-map)#match ip address 1
Device2(config-route-map)#set local-preference 110
Device2(config-route-map)#exit
Device2(config)#route-map SetPriority1 20
Device2(config-route-map)#exit
Device2(config)#route-map SetPriority2 10
Device2(config-route-map)#match ip address 2
Device2(config-route-map)#set metric 100
Device2(config-route-map)#exit
Device2(config)#route-map SetPriority2 20
Device2(config-route-map)#exit
|
On Device2, configure a routing policy to set local-preference of route 75.0.0.0/24 to 110, and set metric of route 65.0.0.0/24 to 100.
#Configure Device3.
Device3(config)#ip access-list standard 1
Device3(config-std-nacl)#permit 85.0.0.0 0.0.0.255
Device2(config-std-nacl)#commit
Device3(config-std-nacl)#exit
Device3(config)#ip access-list standard 2
Device3(config-std-nacl)#permit 55.0.0.0 0.0.0.255
Device2(config-std-nacl)#commit
Device3(config-std-nacl)#exit
Device3(config)#route-map SetPriority1 10
Device3(config-route-map)#match ip address 1
Device3(config-route-map)#set local-preference 110
Device3(config-route-map)#exit
Device3(config)#route-map SetPriority1 20
Device3(config-route-map)#exit
Device3(config)#route-map SetPriority2 10
Device3(config-route-map)#match ip address 2
Device3(config-route-map)#set metric 100
Device3(config-route-map)#exit
Device3(config)#route-map SetPriority2 20
Device3(config-route-map)#exit
|
On Device3, configure a routing policy to set local-preference of route 85.0.0.0/24 to 110, and set metric of route 55.0.0.0/24 to 100.
-
In configuring a routing policy, you can create a filtration rule based on a prefix list or ACL. The prefix list can precisely match routing masks while the ACL cannot match routing masks.
Step 6: Configure a routing policy for BGP.
#Configure Device2.
Device2(config)#router bgp 100
Device2(config-bgp)#neighbor 10.0.0.1 route-map SetPriority1 out
Device2(config-bgp)#neighbor 3.0.0.1 route-map SetPriority2 out
Device2(config-bgp)#exi
|
On Device2, configure the outgoing direction of neighbor 10.0.0.1 to modify local-preference of route 75.0.0.0/24, and configure the outgoing direction of neighbor 3.0.0.1 to modify metric of route 65.0.0.0/24.
#Configure Device3.
Device3(config)#router bgp 100
Device3(config-bgp)#neighbor 10.0.0.1 route-map SetPriority1 out
Device3(config-bgp)#neighbor 4.0.0.1 route-map SetPriority2 out
Device3(config-bgp)#exit
|
On Device3, configure the outgoing direction of neighbor 10.0.0.1 to modify local-preference of route 85.0.0.0/24, and configure the outgoing direction of neighbor 4.0.0.1 to modify metric of route 55.0.0.0/24.
After a routing policy is configured on the peer, the BGP must be reset to make the configuration take effect.
Step 7: Check the result.
#Query the routing table of Device1.
Device1#show ip bgp
BGP table version is 5, local router ID is 10.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
[B]*> 55.0.0.0/24 0.0.0.0 0 32768 i
[B]*> 65.0.0.0/24 0.0.0.0 0 32768 i
[B]* i75.0.0.0/24 30.0.0.1 0 100 0 200 i
[B]*>i 20.0.0.1 0 110 0 200 i
[B]*>i85.0.0.0/24 30.0.0.1 0 110 0 200 i
[B]* i 20.0.0.1 0 100 0 200 i
Device1#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 75.0.0.0/24 [200/0] via 20.0.0.1, 00:01:34, vlan2
B 85.0.0.0/24 [200/0] via 30.0.0.1, 00:00:51, vlan3
According to the routing table, local-preference of routes 75.0.0.0/24 and 85.0.0.0/24 is modified successfully, and Device1 select route 75.0.0.0/24 that is advertised by Device2 and route 85.0.0.0/24 that is advertised by Device3 with priority.
#Query the routing table of Device4.
Device4#show ip bgp
BGP table version is 4, local router ID is 85.0.0.1
Status codes: s suppressed, d damped, h history, * valid, > best, i internal,
S Stale
Origin codes: i - IGP, e - EGP, ? incomplete
Network Next Hop Metric LocPrf Weight Path
[B]* 55.0.0.0/24 4.0.0.2 100 0 100 i
[B]*> 3.0.0.2 0 0 100 i
[B]*> 65.0.0.0/24 4.0.0.2 0 0 100 i
[B]* 3.0.0.2 100 0 100 i
[B]*> 75.0.0.0/24 0.0.0.0 0 32768 i
[B]*> 85.0.0.0/24 0.0.0.0 0 32768 i
Device4#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 55.0.0.0/24 [20/0] via 3.0.0.2, 00:15:02, vlan2
B 65.0.0.0/24 [20/0] via 4.0.0.2, 00:14:55, vlan3
According to the routing table, metric of routes 55.0.0.0/24 and 65.0.0.0/24 is modified successfully, and Device4 select route 55.0.0.0/24 that is advertised by Device2 and route 65.0.0.0/24 that is advertised by Device3 with priority.
-
A routing policy can be used in the outgoing direction of route advertisement, and it can also be used in the incoming direction of route receiving.