Lab 2: BGP Local Preference
Basic configuration
R1:
interface Loopback0
ip address 1.0.0.1 255.0.0.0
!
interface Loopback1
ip address 2.0.0.1 255.0.0.0
!
interface FastEthernet0/0
ip address 12.0.0.1 255.255.255.0
no shutdown
!
interface FastEthernet0/1
ip address 13.0.0.1 255.255.255.0
no shutdown
R2:
interface FastEthernet0/0
ip address 12.0.0.2 255.255.255.0
no shutdown
!
interface FastEthernet0/1
ip address 24.0.0.2 255.255.255.0
no shutdown
R3:
interface FastEthernet0/0
ip address 13.0.0.3 255.255.255.0
no shutdown
!
interface FastEthernet0/1
ip address 35.0.0.3 255.255.255.0
no shutdown
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
9
R4:
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface FastEthernet0/0
ip address 24.0.0.4 255.255.255.0
no shutdown
!
interface FastEthernet0/1
ip address 10.100.1.4 255.255.255.248
no shutdown
R5:
interface Loopback0
ip address 5.5.5.5 255.255.255.255
!
interface FastEthernet0/0
ip address 35.0.0.5 255.255.255.0
no shutdown
!
interface FastEthernet0/1
ip address 10.100.1.5 255.255.255.248
no shutdown
R6:
interface Loopback0
ip address 6.6.6.6 255.255.255.255
!
interface FastEthernet0/0
ip address 10.100.1.6 255.255.255.248
no shutdown
R7:
interface Loopback0
ip address 7.7.7.7 255.255.255.255
!
interface FastEthernet0/0
ip address 10.100.1.3 255.255.255.248
no shutdown
Configure EIGRP AS 4567 on R4, R5, R6 and R7 and advertise the subnet 10.100.1.0/29 and the
loopback 0 subnets:
R4:
router eigrp 4567
network 4.4.4.4 0.0.0.0
network 10.100.1.0 0.0.0.7
R5:
router eigrp 4567
network 5.5.5.5 0.0.0.0
network 10.100.1.0 0.0.0.7
R6:
router eigrp 4567
network 6.6.6.6 0.0.0.0
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
10
network 10.100.1.0 0.0.0.7
R7:
router eigrp 4567
network 7.7.7.7 0.0.0.0
network 10.100.1.0 0.0.0.7
Configure iBGP in AS 4567, use loopback 0 interface for peering and use peer group
configuration.
Configure eBGP between AS 4567 and AS 2 and AS 3.
Configure eBGP between AS 2 and AS 1.
Configure eBGP between AS 3 and AS 1, advertise 1.0.0.0/8 and 2.0.0.0/8 subnets in BGP:
R4:
router bgp 4567
network 10.100.1.0 mask 255.255.255.248
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor INTERNAL next-hop-self
neighbor 5.5.5.5 peer-group INTERNAL
neighbor 6.6.6.6 peer-group INTERNAL
neighbor 7.7.7.7 peer-group INTERNAL
neighbor 24.0.0.2 remote-as 2
R5:
router bgp 4567
network 10.100.1.0 mask 255.255.255.248
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor INTERNAL next-hop-self
neighbor 4.4.4.4 peer-group INTERNAL
neighbor 6.6.6.6 peer-group INTERNAL
neighbor 7.7.7.7 peer-group INTERNAL
neighbor 35.0.0.3 remote-as 3
R6:
router bgp 4567
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor 4.4.4.4 peer-group INTERNAL
neighbor 5.5.5.5 peer-group INTERNAL
neighbor 7.7.7.7 peer-group INTERNAL
R7:
router bgp 4567
neighbor INTERNAL peer-group
neighbor INTERNAL remote-as 4567
neighbor INTERNAL update-source Loopback0
neighbor 4.4.4.4 peer-group INTERNAL
neighbor 5.5.5.5 peer-group INTERNAL
neighbor 6.6.6.6 peer-group INTERNAL
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
11
R1:
router bgp 1
network 1.0.0.0
network 2.0.0.0
neighbor 12.0.0.2 remote-as 2
neighbor 13.0.0.3 remote-as 3
R2:
router bgp 2
neighbor 12.0.0.1 remote-as 1
neighbor 24.0.0.4 remote-as 4567
R3:
router bgp 3
neighbor 13.0.0.1 remote-as 1
neighbor 35.0.0.5 remote-as 4567
Verify the peer-group and see the current members, the members on this group are: R5 5.5.5.5,
R6 6.6.6.6 and R7 7.7.7.7:
R4#sh ip bgp peer-group INTERNAL
BGP peer-group is INTERNAL, remote AS 4567
BGP version 4
Default minimum time between advertisement runs is 0 seconds
For address family: IPv4 Unicast
BGP neighbor is INTERNAL, peer-group internal, members:
5.5.5.5 6.6.6.6 7.7.7.7
Index 0, Offset 0, Mask 0x0
NEXT_HOP is always this router
Update messages formatted 0, replicated 0
Number of NLRIs in the update sent: max 0, min 0
Peer groups is used for less processing power, let's verify the adjacencies:
R1(config-router)#do show ip bgp sum
BGP router identifier 2.0.0.1, local AS number 1
BGP table version is 6, main routing table version 6
3 network entries using 351 bytes of memory
4 path entries using 208 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1103 total bytes of memory
BGP activity 3/0 prefixes, 4/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
12.0.0.2 4 2 6 6 6 0 0 00:01:33 1
13.0.0.3 4 3 6 6 6 0 0 00:00:34 1
R1(config-router)#
R4(config-router)#do show ip bgp sum
BGP router identifier 4.4.4.4, local AS number 4567
BGP table version is 5, main routing table version 5
3 network entries using 351 bytes of memory
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
12
6 path entries using 312 bytes of memory
5/2 BGP path/bestpath attribute entries using 620 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1331 total bytes of memory
BGP activity 3/0 prefixes, 6/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
5.5.5.5 4 4567 11 11 5 0 0 00:06:58 3
6.6.6.6 4 4567 10 12 5 0 0 00:07:05 0
7.7.7.7 4 4567 10 12 5 0 0 00:06:27 0
24.0.0.2 4 2 7 6 5 0 0 00:01:55 2
R7(config-router)#do show ip bgp sum
BGP router identifier 7.7.7.7, local AS number 4567
BGP table version is 5, main routing table version 5
3 network entries using 351 bytes of memory
6 path entries using 312 bytes of memory
4/2 BGP path/bestpath attribute entries using 496 bytes of memory
2 BGP AS-PATH entries using 48 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 1207 total bytes of memory
BGP activity 3/0 prefixes, 6/0 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
4.4.4.4 4 4567 12 10 5 0 0 00:06:47 3
5.5.5.5 4 4567 12 10 5 0 0 00:07:08 3
6.6.6.6 4 4567 9 9 5 0 0 00:06:56 0
Ensure AS 4567 will use the link between R3-R5 towards network 2.0.0.0/8. Use LOCAL_PREF
only.
Before configuring the Local-Pref, let’s use a traceroute on R6 and R7 toward 2.0.0.1. We can
see that the packet goes through R4--R2:
R6#traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
1 10.100.1.4 72 msec 24 msec 24 msec
2 24.0.0.2 60 msec 28 msec 80 msec
3 12.0.0.1 96 msec * 96 msec
R6#
R7(config-router)#do traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
1 10.100.1.4 56 msec 56 msec 12 msec
2 24.0.0.2 52 msec 48 msec 32 msec
3 12.0.0.1 84 msec * 108 msec
R7(config-router)
Verify the RIB of R6 and R7:
Notice that the best route to reach 2.0.0.0/24 is via R4 (4.4.4.4) denoted by " *>i " on both R6
and R7:
R6#show ip bgp
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
13
BGP table version is 5, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i1.0.0.0 5.5.5.5 0 100 0 3 1 i
*>i 4.4.4.4 0 100 0 2 1 i
* i2.0.0.0 5.5.5.5 0 100 0 3 1 i
*>i 4.4.4.4 0 100 0 2 1 i
r i10.100.1.0/29 5.5.5.5 0 100 0 i
r>i 4.4.4.4 0 100 0 i
R7(config-router)#do show ip bgp
BGP table version is 5, local router ID is 7.7.7.7
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i1.0.0.0 5.5.5.5 0 100 0 3 1 i
*>i 4.4.4.4 0 100 0 2 1 i
* i2.0.0.0 5.5.5.5 0 100 0 3 1 i
*>i 4.4.4.4 0 100 0 2 1 i
r i10.100.1.0/29 5.5.5.5 0 100 0 i
r>i 4.4.4.4 0 100 0 i
To ensure that the traffic goes through R5--R3 you will tell to R5 to advertise into BGP AS 4567
the prefix 2.0.0.0/24 with a better (higher) local-preference than R4 as follow, by default the
Local-Pref is equal to 100:
router bgp 4567
neighbor 35.0.0.3 route-map RM_LOC_PREF in
!
ip prefix-list NET-2 seq 5 permit 2.0.0.0/8
!
route-map RM_LOC_PREF permit 10
match ip address prefix-list NET-2
set local-preference 200
!
route-map RM_LOC_PREF permit 20
Verify the RIB of R6 and R7.
The best route now toward 2.0.0.0/24 on both R6 and R7 is via R5 (5.5.5.5) because the better
(higher) Local-Preference 200:
R6#show ip bgp
BGP table version is 6, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i1.0.0.0 5.5.5.5 0 100 0 3 1 i
*>i 4.4.4.4 0 100 0 2 1 i
*>i2.0.0.0 5.5.5.5 0 200 0 3 1 i
r i10.100.1.0/29 5.5.5.5 0 100 0 i
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
14
r>i 4.4.4.4 0 100 0 i
R7(config)#do show ip bgp
BGP table version is 6, local router ID is 7.7.7.7
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* i1.0.0.0 5.5.5.5 0 100 0 3 1 i
*>i 4.4.4.4 0 100 0 2 1 i
*>i2.0.0.0 5.5.5.5 0 200 0 3 1 i
r i10.100.1.0/29 5.5.5.5 0 100 0 i
r>i 4.4.4.4 0 100 0 i
The traceroute shown that the packet goes through R5--R3 to reach 2.0.0.0/24:
R6#traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
1 10.100.1.5 76 msec 108 msec 20 msec
2 35.0.0.3 100 msec 120 msec 32 msec
3 13.0.0.1 148 msec * 176 msec
R6#
R7(config)#do traceroute 2.0.0.1
Type escape sequence to abort.
Tracing the route to 2.0.0.1
1 10.100.1.5 68 msec 136 msec 28 msec
2 35.0.0.3 112 msec 76 msec 36 msec
3 13.0.0.1 180 msec * 204 msec
Ensure AS 4567 will use the link between R2-R4 towards network 1.0.0.0/8. Use LOCAL_PREF
only.
You will tell to R4 to advertise into BGP AS 4567 the prefix 1.0.0.0/24 with a better(higher)
local-preference than R4 as follow,by default the Local-Pref is equal to 100:
router bgp 4567
neighbor 24.0.0.2 route-map RM_LOC_PREF in
no auto-summary
!
ip prefix-list NET-1 seq 5 permit 1.0.0.0/8
!
route-map RM_LOC_PREF permit 10
match ip address prefix-list NET-1
set local-preference 200
!
route-map RM_LOC_PREF permit 20
Now the best path to reach 1.0.0.0/24 is via R4 on both R6 and R7 because the better(higher)
Local-Preference 200 :
R6#show ip bgp
BGP table version is 10, local router ID is 6.6.6.6
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
15
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i1.0.0.0 4.4.4.4 0 200 0 2 1 i
*>i2.0.0.0 5.5.5.5 0 200 0 3 1 i
r>i10.100.1.0/29 4.4.4.4 0 100 0 i
r i 5.5.5.5 0 100 0 i
R7(config)#do show ip bgp
BGP table version is 10, local router ID is 7.7.7.7
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*>i1.0.0.0 4.4.4.4 0 200 0 2 1 i
*>i2.0.0.0 5.5.5.5 0 200 0 3 1 i
r>i10.100.1.0/29 4.4.4.4 0 100 0 i
r i 5.5.5.5 0 100 0 i
Note: you must enter the clear ip bgp * command to reset the bgp neighbors relationship when
configuring the Local-Preference to take effect.
BGP ROUTING PROTOCOL PRACTICE LABS
REDOUANE MEDDANE
16