Lab Objective:
The focus of this lab is to understand BGP implementation and configuration in Cisco IOS routers. Additional technologies include summarization, route filtering and path control.
Lab Topology:
The lab network topology is illustrated below:
|
IMPORTANT NOTE If you are using the www.howtonetwork.net racks, please bring up the LAN interfaces connected to the routers by issuing the no shutdown command on the connected switches. If you are using a home lab with no interface fastethernet 0/0 Alternately, you can simply connect the interfaces to a hub or switch if you have one available in your own lab. |
Task 1
Configure hostnames and IP addressing on all routers as illustrated in the network topology. Additionally, configure a Loopback 0 interface on all routers using the router number and a host mask. For example, on R1, configure Loopback 0 with the IP address 1.1.1.1/32, on R2 configure interface Loopback 0 with the IP address 2.2.2.2/32 and so forth for R3 and also R4.
Task 2
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. On R3 and R4, ensure that packets are load balanced between the two WAN links. Do NOT configure PPP Multilink. Verify the configuration using the appropriate commands.
Task 3
Configure all routers to advertise their LAN subnet addresses via BGP. These should appear in the BGP RIBs of all other routers with an ORIGIN code of INCOMPLETE, by default. Verify the configuration using the appropriate commands.
Task 4
Configure BGP so that R4 prefers the path via R3 to reach any subnet. You are NOT allowed to implement any configuration on R4 itself. Verify your BGP configuration using the appropriate commands.
Task 5
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. Do NOT modify any other BGP attributes or default administrative distance values when completing this task. Verify your configuration using the appropriate commands.
Task 6
Configure the following Loopback interfaces on R2:
Loopback 192: IP Address 192.1.1.1/24
Loopback 193: IP Address 193.1.1.1/24
Loopback 194: IP Address 194.1.1.1/24
Loopback 195: IP Address 195.1.1.1/24
The 192.1.1.1/24 subnet should appear to have originated in AS 192. The 193.1.1.1/24 subnet should appear to have originated in AS 193. The 194.1.1.1/24 subnet should appear to have originated in AS 194. And finally, the 195.1.1.1/24 subnet should appear to have originated in AS 195. These prefixes should be advertised using the network command. Verify your configuration using the appropriate commands.
Task 7
Configure R1 so that it only accepts prefixes originated in AS 192, 193, 194 and 195 from R4. It should never have any entries in its BGP RIB for any prefixes originating in these ASes directly from R2. Use an AS_PATH filter. This should only have TWO lines. Verify your configuration using the appropriate commands.
Lab Validation
Task 1
Please refer to previous labs for basic IP addressing and hostname configuration. This will not be included in this section to avoid being redundant.
Task 2
The most simple way to complete this task is to use BGP peer group configuration to minimize the number of commands that you need to specify. However, the task specifically states that peer groups should not be used. Additionally, in order to establish the BGP adjacencies using peer groups, you need to configure static routes on all routers because you are not allowed to enable an IGP of any kind. This task is completed as follows:
| R1(config)#ip route 2.2.2.2 255.255.255.255 serial 0/0 R1(config)#ip route 4.4.4.4 255.255.255.255 fastethernet 0/0 150.1.1.4 R1(config)#router bgp 1 R1(config-router)#neighbor 2.2.2.2 remote-as 2 R1(config-router)#neighbor 2.2.2.2 update-source loopback 0 R1(config-router)#neighbor 2.2.2.2 ebgp-multihop R1(config-router)#neighbor 4.4.4.4 remote-as 4 R1(config-router)#neighbor 4.4.4.4 update-source loopback 0 R1(config-router)#neighbor 4.4.4.4 ebgp-multihop R1(config-router)#exit |
| R2(config)#ip route 1.1.1.1 255.255.255.255 serial 0/0 R2(config)#ip route 3.3.3.3 255.255.255.255 serial 0/1 R2(config)#router bgp 2 R2(config-router)#neighbor 1.1.1.1 remote-as 1 R2(config-router)#neighbor 1.1.1.1 update-source loopback 0 R2(config-router)#neighbor 1.1.1.1 ebgp-multihop R2(config-router)#neighbor 3.3.3.3 remote-as 3 R2(config-router)#neighbor 3.3.3.3 update-source loopback 0 R2(config-router)#neighbor 3.3.3.3 ebgp-multihop R2(config-router)#exit |
| R3(config)#ip route 2.2.2.2 255.255.255.255 serial 1/1 R3(config)#ip route 4.4.4.4 255.255.255.255 serial 1/2 R3(config)#ip route 4.4.4.4 255.255.255.255 serial 1/3 R3(config)#router bgp 3 R3(config-router)#neighbor 2.2.2.2 remote-as 2 R3(config-router)#neighbor 2.2.2.2 update-source loopback 0 R3(config-router)#neighbor 2.2.2.2 ebgp-multihop R3(config-router)#neighbor 4.4.4.4 remote-as 4 R3(config-router)#neighbor 4.4.4.4 update-source loopback 0 R3(config-router)#neighbor 4.4.4.4 ebgp-multihop R3(config-router)#exit |
| R4(config)#ip route 1.1.1.1 255.255.255.255 fastethernet 0/0 150.1.1.1 R4(config)#ip route 3.3.3.3 255.255.255.255 serial 0/0 R4(config)#ip route 3.3.3.3 255.255.255.255 serial 0/1 R4(config)#router bgp 4 R4(config-router)#neighbor 1.1.1.1 remote-as 1 R4(config-router)#neighbor 1.1.1.1 update-source loopback 0 R4(config-router)#neighbor 1.1.1.1 ebgp-multihop R4(config-router)#neighbor 3.3.3.3 remote-as 3 R4(config-router)#neighbor 3.3.3.3 update-source loopback 0 R4(config-router)#neighbor 3.3.3.3 ebgp-multihop R4(config-router)#exit |
Verify your configuration using the show ip bgp summary command on all routers:
| R1#show ip bgp summary BGP router identifier 1.1.1.1, local AS number 1 BGP table version is 1, main routing table version 1 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd |
| R2#show ip bgp summary BGP router identifier 2.2.2.2, local AS number 2 BGP table version is 1, main routing table version 1 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd |
| R3#show ip bgp summary BGP router identifier 3.3.3.3, local AS number 3 BGP table version is 1, main routing table version 1 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd |
| R4#show ip bgp summary BGP router identifier 4.4.4.4, local AS number 4 BGP table version is 1, main routing table version 1 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd |
Task 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 networkstatement in conjunction with a route map and set the ORIGIN code within the route map. Either option is acceptable when completing this task. This task is completed as follows when using the redistribution method:
| R1(config)#route-map CONNECTED permit 10 R1(config-route-map)#match interface fastethernet 0/0 R1(config-route-map)#exit R1(config)#route-map CONNECTED deny 20 R1(config-route-map)#exit R1(config)#router bgp 1 R1(config-router)#redistribute connected route-map CONNECTED R1(config-router)#exit |
| R2(config)#route-map CONNECTED permit 10 R2(config-route-map)#match interface fastethernet 0/0 R2(config-route-map)#exit R2(config)#route-map CONNECTED deny 20 R2(config-route-map)#exit R2(config)#router bgp 2 R2(config-router)#redistribute connected route-map CONNECTED R2(config-router)#exit |
| R3(config)#route-map CONNECTED permit 10 R3(config-route-map)#match interface fastethernet 0/0 R3(config-route-map)#exit R3(config)#route-map CONNECTED deny 20 R3(config-route-map)#exit R3(config)#router bgp 3 R3(config-router)#redistribute connected route-map CONNECTED R3(config-router)#exit |
| R4(config)#route-map CONNECTED permit 10 R4(config-route-map)#match interface fastethernet 0/0 R4(config-route-map)#exit R4(config)#route-map CONNECTED deny 20 R4(config-route-map)#exit R4(config)#router bgp 4 R4(config-router)#redistribute connected route-map CONNECTED R4(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.
| R1#show ip bgp BGP table version is 4, local router ID is 1.1.1.1 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 |
| R2#show ip bgp BGP table version is 4, local router ID is 2.2.2.2 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 |
| R3#show ip bgp BGP table version is 5, local router ID is 3.3.3.3 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 |
| R4#show ip bgp BGP table version is 6, local router ID is 4.4.4.4 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 |
Task 4
This task requires a little thought. Because we cannot implement any configuration on R4 itself, we have to think outside the box. The current BGP RIB on R4 shows the following entries:
| R4#show ip bgp BGP table version is 6, local router ID is 4.4.4.4 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 |
In the output above, the path via R3 is preferred for the 150.3.3.0/24 prefix; however, the router prefers the path via R1 for the 150.2.2.0/24 prefix because, all else being equal, it is the router with the lower IP address. To influence path selection in this case, we need to configure BGP on R1 to advertise all prefixes with a longer AS_PATH. The MED will not work because this attribute is not, by default, considered when prefixes are received from multiple ASes. This task is completed by configuring R1 as follows:
| R1(config)#route-map PREPEND permit 10 R1(config-route-map)#set as-path prepend 1 1 1 1 R1(config-route-map)#exit R1(config)#router bgp 1 R1(config-router)#neighbor 4.4.4.4 route-map PREPEND out R1(config-router)#exit |
Following this configuration, the BGP Table on R4 shows the following:
| R4#show ip bgp BGP table version is 14, local router ID is 4.4.4.4 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 |
Task 5
The requirements of this task are two-fold. The first requirement is that R4 and R2 advertise all prefixes to R3 with a MED of 4 and 2, respectively. This is completed using an outbound route map on these two routers. Before any BGP configuration changes, the BGP RIB on R3 shows the following route entries:
| R3#show ip bgp BGP table version is 11, local router ID is 3.3.3.3 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 |
The first part of this task is completed as follows:
| R4(config)#route-map MED permit 10 R4(config-route-map)#set metric 4 R4(config-route-map)#exit R4(config)#router bgp 4 R4(config-router)#neighbor 3.3.3.3 route-map MED out R4(config-router)#exit |
| R2(config)#route-map MED permit 10 R2(config-route-map)#set metric 2 R2(config-route-map)#exit R2(config)#router bgp 2 R2(config-router)#neighbor 3.3.3.3 route-map MED out R2(config-router)#exit |
Following these changes, the BGP RIB on R3 shows the following:
| R3#show ip bgp BGP table version is 13, local router ID is 3.3.3.3 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 |
The second part of this task has two caveats. The first is that the MED attribute should be used in the path selection process. The issue here is that, by default, the MED is only compared for path received from the same AS. In order to allow BGP to compare MED values from prefixes received from multiple ASes, this default behavior needs to be modified. The second caveat is that the MED is compared AFTER the AS_PATH. This means that, for example, BGP 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. Again, this default behavior has to be modified to complete this task. The second part of this task is therefore completed as follows:
| R3(config)#router bgp 3 R3(config-router)#bgp bestpath as-path ignore R3(config-router)#bgp always-compare-med R3(config-router)#exit |
Following this configuration, the BGP Table on R3 now shows the following:
| R3#show ip bgp BGP table version is 14, local router ID is 3.3.3.3 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 |
A more detailed look reveals that the path with the longer AS_PATH sequence, but LOWER metric (MED) value is now preferred because of the configuration implemented on R3:
| R3#show ip bgp 150.1.1.0 255.255.255.0 BGP routing table entry for 150.1.1.0/24, version 14 Paths: (2 available, best #2, table Default-IP-Routing-Table) Flag: 0x820 Advertised to update-groups: 1 4 4.4.4.4 from 4.4.4.4 (4.4.4.4) Origin incomplete, metric 4, localpref 100, valid, external 2 1 2.2.2.2 from 2.2.2.2 (2.2.2.2) Origin incomplete, metric 2, localpref 100, valid, external, best |
Task 6
While seemingly difficult, this task is very straightforward and requires the use of AS_PATH prepending when advertising these prefixes via BGP on R2. This is completed as follows:
| R2(config)#interface loopback 192 R2(config-if)#ip address 192.1.1.1 255.255.255.0 R2(config-if)#exit R2(config)#interface loopback 193 R2(config-if)#ip address 193.1.1.1 255.255.255.0 R2(config-if)#exit R2(config)#interface loopback 194 R2(config-if)#ip address 194.1.1.1 255.255.255.0 R2(config-if)#exit R2(config)#interface loopback 195 R2(config-if)#ip address 195.1.1.1 255.255.255.0 R2(config-if)#exit R2(config)#ip prefix-list LOOPBACK192 seq 5 permit 192.1.1.0/24 R2(config)#ip prefix-list LOOPBACK193 seq 5 permit 193.1.1.0/24 R2(config)#ip prefix-list LOOPBACK194 seq 5 permit 194.1.1.0/24 R2(config)#ip prefix-list LOOPBACK195 seq 5 permit 195.1.1.0/24 R2(config)#route-map PREPEND permit 10 R2(config-route-map)#match ip address prefix-list LOOPBACK192 R2(config-route-map)#set as-path prepend 192 R2(config-route-map)#exit R2(config)#route-map PREPEND permit 20 R2(config-route-map)#match ip address prefix-list LOOPBACK193 R2(config-route-map)#set as-path prepend 193 R2(config-route-map)#exit R2(config)#route-map PREPEND permit 30 R2(config-route-map)#match ip address prefix-list LOOPBACK194 R2(config-route-map)#set as-path prepend 194 R2(config-route-map)#exit R2(config)#route-map PREPEND permit 40 R2(config-route-map)#match ip address prefix-list LOOPBACK195 R2(config-route-map)#set as-path prepend 195 R2(config-route-map)#exit R2(config)#route-map PREPEND permit 50 R2(config-route-map)#exit R2(config)#router bgp 2 R2(config-router)#network 192.1.1.0 R2(config-router)#network 193.1.1.0 R2(config-router)#network 194.1.1.0 R2(config-router)#network 195.1.1.0 R2(config-router)#neighbor 1.1.1.1 route-map PREPEND out R2(config-router)#neighbor 3.3.3.3 route-map PREPEND out R2(config-router)#exit |
Following this configuration, verify the BGP RIB entries for these prefixes are correct:
| R1#show ip bgp BGP table version is 29, local router ID is 1.1.1.1 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 |
| R3#show ip bgp BGP table version is 44, local router ID is 3.3.3.3 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 |
| R4#show ip bgp BGP table version is 38, local router ID is 4.4.4.4 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 |
Task 7
To complete this task, we need to use a two-line AS_PATH filter. Prior to any configuration changes, the BGP Table on R1 shows the following entries:
| R1#show ip bgp BGP table version is 29, local router ID is 1.1.1.1 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 |
To complete this task, you need to have a good understanding of basic regular expressions and how they are configured. A regular expression comprises four main parts. These four main parts, which are described in the following sections, are:
- A Range
- An Atom
- A Piece
- A Branch
A range is a sequence of characters within left and right square brackets. Examples of ranges are [abcd] or [1-9] or [0,4-7]. An atom is a single character. A Piece or Multiplier is a symbol that follows an Atom. Examples include the plus sign (+) and the question mark (?).branch is 0 or more concatenated pieces, i.e. 0 or more pieces used together in a regular expression, for example ^[0-9]+ [0-9]+?$. Before configuring and then applying AS_PATH filters, you should always use the show ip bgp regexp <regular expression> command to ensure that you are matching the desired routes. For example, prior to R1s configuration change, this command, used with the appropriate regular expression, confirms that the AS_PATH filter will match the desired prefixes:
| R1#show ip bgp regexp _19[2-5]$ BGP table version is 29, local router ID is 1.1.1.1 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 |
To complete this task, implement the following configuration on R1:
| R1(config)#ip as-path access-list 1 deny _19[2-5]$ R1(config)#ip as-path access-list 1 permit .* R1(config)#router bgp 1 R1(config-router)#neighbor 2.2.2.2 filter-list 1 in R1(config-router)#exit |
Following this change, the BGP Table on R1 shows the following entries:
| R1#show ip bgp BGP table version is 33, local router ID is 1.1.1.1 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 |
NOTE: You can also complete this task by matching the configured AS_PATH ACL in a route map and applying that inbound. Either solution is acceptable.
Final Router Configurations
R1
|
R1#term len 0 Current configuration : 1614 bytes R1# |
R2
|
R2#term len 0 Current configuration : 2455 bytes R2# |
R3
|
R3#term len 0 Current configuration : 1850 bytes R3# |
R4
|
R4#term len 0 Current configuration : 1518 bytes R4# |
