Note that in the output of “show ip bgp” above, the weights assigned to each route to
192.168.3.0 are 0:
* 192.168.3.0 192.168.0.13 0 65004 65003 i
*> 192.168.0.2 0 65002 65003 i
we want to route traffic for 192.168.3.0/24 through AS 65004 (R4). The easiest
(but not always best) way to do this is by using BGP’s weight attribute.
Zero is the default value. When multiple routes to the same destination exist, BGP will
prefer the route with the highest weight. To influence traffic to 192.168.3.0 to take the
path through AS 65004 (R4), we need to modify the weight assigned to the route
received from R4. There are a few ways of doing this, but we’re going to use a route
map (probably the most common method).
Just for verification, let’s look at what is currently in our routing table for 192.168.3.0/24:
R1# show ip route | include 192.168.3.0
B 192.168.3.0/24 [20/0] via 192.168.0.2, 00:17:31
We are, indeed, routing traffic to 192.168.3.0/24 via R2 (192.168.0.2).
Defining an access list
We are actually receiving multiple routes from R4, but only want to influence routing
for one route so we are going to use route maps in conjunction with an IP access list to
achieve our desired outcome. First, we need to define an access list that matches
192.168.3.0/24:
R1# configure terminal
R1(config)# access-list 3 permit 192.168.3.0 0.0.0.255
R1(config)# end
!
Defining a route map
With our access list now matching the networks we want to manipulate, we can now
create our route map (which we’ll call “NET3″). Our route map will be configured to
match traffic defined by access list 3 and will set the weight to 100:
R1# configure terminal
R1(config)# route-map NET3 permit 10
R1(config-route-map)# match ip address 3
R1(config-route-map)# set weight 100
R1(config-route-map)# route-map NET3 permit 20
R1(config-route-map)# end
You may be wondering about the “route-map NET3 permit 20″ statement, since it
doesn’t appear to do anything. From Cisco:
That’s exactly what we did in this case. If we had left out the “route-map NET3 permit
20″ statement, any other routes from R4 would not be accepted. Although we are only
going to be manipulating the route to 192.168.3.0/24 from R4, we still need to accept
all other routes from R4 into our BGP table.
Applying a route map to a neighbor
With our route map configured, we now need to instruct R1 to apply the route-map to
any updates received from our neighbor, R4. Easy enough:
R1# configure terminal
R1(config)# router bgp 65001
R1(config-router)# neighbor 192.168.0.13 route-map NET3 in
R1(config-router)# end
We’re pretty much set at this point. The changes won’t take effect immediately,
however. We need to restart the BGP process in order for our changes to take effect.
Let’s restart:
R1# clear ip bgp 65004
If we take a look at our BGP table, we should see that the route for 192.168.3.0/24 that
came from R4 (AS 65004) should now have a weight of 100 assigned to it, and it does:
*> 192.168.3.0 192.168.0.13 100 65004 65003 i
- 192.168.0.2 0 65002 65003 i
Subsequently, we should see that the “new” route to 192.168.3.0/24 (via 192.168.0.13
in AS 65004) was installed into our routing table:
R1# show ip route | include 192.168.3.0
B 192.168.3.0/24 [20/0] via 192.168.0.13, 00:01:56
And that’s all there it is to it!
Comments
(There are currently no comments for this post.)