How to advertise networks in BGP

Hello Jyothi

When an IP packet arrives on a router, the destination address is compared to the entries in the routing table. The router goes through all of the routing entries in the routing table and attempts to match it to a particular entry. If there are multiple entries that the destination IP address can match with, the following criteria are used:

  1. First, the more specific entry is matched. In other words, the entry with the smallest subnet mask is used.
  2. If the subnet mask is the same, then the entry with the lowest metric is used.
  3. If the metric is the same, then load balancing takes place.

Note that one would assume that the administrative distance (AD) also plays a role, and it does, but not in the choice of installed routes. The AD will be used to determine if a route will be installed in the routing table in the event that two identical routes, with identical prefix lengths, are learned from different sources. If this happens, the route with the lower AD will be installed. The other route will never be in the routing table, thus it is never an option for a packet coming into the router. See this Cisco documentation for more info.

Now, if we apply this to your case, you would have the following two entries in your routing table:

  • as connected
  • as static with a next-hop to a particular interface

Now, in this case, the prefix of the static route is more specific, therefore that static route will be matched. In this case, you should not use Null0 as the next-hop IP since any packets destined to this IP will simply be dropped. Use an exit interface to ensure that such packets will be routed correctly.

Once that static route is entered with a next-hop interface, that entry is in the routing table, therefore BGP will be able to advertise it.

I hope this has been helpful!