BGP Routing Protocol Practice Lab 01
Lab 1: MED and AS-Path Prepend
Basic configuration
R1:interface Loopback0ip address 1.1.1.1 255.255.255.255!interface FastEthernet0/0ip address 150.1.1.1 255.255.255.0
no shut!interface Serial0/0ip address 10.0.0.1 255.255.255.252no shut
R2:interface Loopback0ip address 2.2.2.2 255.255.255.255!interface Loopback192ip address 192.1.1.1 255.255.255.0!interface Loopback193ip address 193.1.1.1 255.255.255.0!
interface Loopback194ip address 194.1.1.1 255.255.255.0!interface Loopback195ip address 195.1.1.1 255.255.255.0!interface Serial0/0ip address 10.0.0.2 255.255.255.252no shut !interface Serial0/1ip address 10.0.0.9 255.255.255.252no shut
R3:
interface Loopback0ip address 3.3.3.3 255.255.255.255!interface FastEthernet0/0 ip address 150.3.3.3 255.255.255.0 no shut!interface Serial0/1ip address 10.0.0.10 255.255.255.252no shut !interface Serial0/2ip address 10.0.0.13 255.255.255.252no shut !interface Serial0/3ip address 10.0.0.17 255.255.255.252no shut
R4:
interface Loopback0ip address 4.4.4.4 255.255.255.255!interface FastEthernet0/0 ip address 150.1.1.4 255.255.255.0 no shut!interface Serial0/0ip address 10.0.0.14 255.255.255.252no shut !interface Serial0/1ip address 10.0.0.18 255.255.255.252no shut
Configure BGP as illustrated in the topology. Use the Loopback 0 addresses for peering. Do NOT configure any IGPs. Instead, use static routes only. R1 should peer with R2 and R4. R2 should peer with R1 and R3. R3 should peer with R2 and R4. R4 should peer with R1 and R3.
R1(config)#ip route 2.2.2.2 255.255.255.255 serial 0/0R1(config)#ip route 4.4.4.4 255.255.255.255 fastethernet 0/0 150.1.1.4R1(config)#router bgp 1
R1(config-router)#neighbor 2.2.2.2 remote-as 2R1(config-router)#neighbor 2.2.2.2 update-source loopback 0R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 3R1(config-router)#neighbor 4.4.4.4 remote-as 4R1(config-router)#neighbor 4.4.4.4 update-source loopback 0R1(config-router)#neighbor 4.4.4.4 ebgp-multihop 3
R1(config-router)#neighbor 2.2.2.2 remote-as 2R1(config-router)#neighbor 2.2.2.2 update-source loopback 0R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 3R1(config-router)#neighbor 4.4.4.4 remote-as 4R1(config-router)#neighbor 4.4.4.4 update-source loopback 0R1(config-router)#neighbor 4.4.4.4 ebgp-multihop 3
R2(config)#ip route 1.1.1.1 255.255.255.255 serial 0/0R2(config)#ip route 3.3.3.3 255.255.255.255 serial 0/1R2(config)#router bgp 2R2(config-router)#neighbor 1.1.1.1 remote-as 1R2(config-router)#neighbor 1.1.1.1 update-source loopback 0R2(config-router)#neighbor 1.1.1.1 ebgp-multihop 3R2(config-router)#neighbor 3.3.3.3 remote-as 3R2(config-router)#neighbor 3.3.3.3 update-source loopback 0R2(config-router)#neighbor 3.3.3.3 ebgp-multihop 3
R3(config)#ip route 2.2.2.2 255.255.255.255 serial 1/1R3(config)#ip route 4.4.4.4 255.255.255.255 serial 1/2R3(config)#ip route 4.4.4.4 255.255.255.255 serial 1/3R3(config)#router bgp 3R3(config-router)#neighbor 2.2.2.2 remote-as 2R3(config-router)#neighbor 2.2.2.2 update-source loopback 0R3(config-router)#neighbor 2.2.2.2 ebgp-multihop 3R3(config-router)#neighbor 4.4.4.4 remote-as 4R3(config-router)#neighbor 4.4.4.4 update-source loopback 0R3(config-router)#neighbor 4.4.4.4 ebgp-multihop 3
R4(config)#ip route 1.1.1.1 255.255.255.255 fastethernet 0/0 150.1.1.1R4(config)#ip route 3.3.3.3 255.255.255.255 serial 0/0R4(config)#ip route 3.3.3.3 255.255.255.255 serial 0/1R4(config)#router bgp 4R4(config-router)#neighbor 1.1.1.1 remote-as 1R4(config-router)#neighbor 1.1.1.1 update-source loopback 0R4(config-router)#neighbor 1.1.1.1 ebgp-multihop 3R4(config-router)#neighbor 3.3.3.3 remote-as 3R4(config-router)#neighbor 3.3.3.3 update-source loopback 0R4(config-router)#neighbor 3.3.3.3 ebgp-multihop 3
In order to ensure that the ORIGIN code is INCOMPLETE, you need to redistribute the LAN subnets into BGP. However, you can also use the network statement in conjunction with a route map and set the ORIGIN code within the route map.
R1(config)#route-map CONNECTED permit 10R1(config-route-map)#match interface fastethernet 0/0R1(config-route-map)#exitR1(config)#route-map CONNECTED deny 20R1(config-route-map)#exitR1(config)#router bgp 1R1(config-router)#redistribute connected route-map CONNECTED R1(config-router)#exit
You can verify the ORIGIN code by looking at the prefix entry in the BGP Tables. The ORIGIN code of INCOMPLETE is denoted by a question mark (?) in the output of the show ip bgp command. You can view additional detail on a per-prefix basis also when using this command
Configure BGP, so that R4 prefers the path via R3 to reach any subnet
In the output of the show ip bgp command on R4 we can see that the preferred route to reach 150.3.3.0 is via R3, however the preferred route to reach 150.2.2.0 is via R1 (the lowest routerid), also, to ensure that the subnet 150.1.1.0 will be reached via R3, configure BGP on R1 to advertise all prefixes with a longer AS-PATH to influence the path selection as follow:R1(config)#route-map PREP permit 10R1(config-route-map)#set as-path prepend 1 1 1 1 R1(config-route-map)#exitR1(config)#router bgp 1R1(config-router)#neighbor 4.4.4.4 route-map PREP out R1(config-router)#exit
Notice now the preferred path to reach both prefixes 150.3.3.0 and 150.2.2.0 is via R3 with the next-hop 3.3.3.3 because the shortest AS-PATH length:
Configure R4 so that it sends all updates to R3 with a MED of 4. Configure R2 so that it sends all updates to R3 with a MED of 2. Ensure that R3 prefers all routes with the better (lower) MED value.Before configuring the MED let's verify the BGP RIBs on R3:The preferred path to reach the prefix 150.1.1.0 is via R4, we should see all routes with the next-hop R2:
Let's configure MED on R3:
R4(config)#route-map MED permit 10R4(config-route-map)#set metric 4R4(config-route-map)#exitR4(config)#router bgp 4R4(config-router)#neighbor 3.3.3.3 route-map MED outR4(config-router)#exit
R2(config)#route-map MED permit 10R2(config-route-map)#set metric 2R2(config-route-map)#exitR2(config)#router bgp 2
R2(config-router)#neighbor 3.3.3.3 route-map MED outR2(config-router)#exit
Let's verify the BGP RIBs of R3:We have still the best path to reach 150.1.1.0 via R4 as shown by the show ip bgp command on R3 below, so the problem is not resolved even if R2 advertises the lowest MED comparing with R4.The reason is: we met two issues in this case:-the first issue is: by default, the MED is only compared for path received from the same AS ,in this case R3 receives two values of MED from two routers (R2 and R4) configured in different AS.-The second issue: the MED is compared after the AS-PATH in the BGP decision process. In this case R3 will select the path via R4 as the best path to the 150.1.1.0/24 prefix because of the shorter AS-PATH length.
To override the two issues, configure the bgp always-compare-med command to avoid the first issue so always compare the MED even if MED is received from Different AS. And bgp bestpath as-path ignore command to avoid the second issue so that R3 override the BGP decision process by ignoring the step of the AS-PATH in the BGP Decision Process:Let's configure these two commands:
R3(config)#router bgp 3R3(config-router)#bgp bestpath as-path ignore R3(config-router)#bgp always-compare-med
We can see for the prefix 150.1.1.0 that the path with the longer AS-PATH length is preferred because the lowest MED even if the AS-PATH takes precedence over the MED in the order of the path selection in BGP:
Another way to verify all BGP RIBs with do show ip bgp, R3 prefers all routes from R2 because the lowest MED:
#BGP #LAB #CCNA #CCNP #CCIE #cisco #gns3 #solution
Comments