Recently was asked a question on how to advertise specific routes over BGP when the prefix is not in the routing table. We decided to add static Null0 routes and advertise them over the BGP link. I was also provided the below points in choosing the route in the table.
First the administrative distance (AD) is examined. If there are two entries that the IP address matches with, the entry with the lower AD will be used.
If the AD is the same, then the more specific entry, that is, the entry with the smallest subnet mask is used.
If the subnet mask is the same, then the entry with the lowest metric is used.
If the metric is the same, then load balancing takes place.
The above order seems to be wrong according to some Cisco docs as in.
Should the prefix length triumph over AD ?
Example : 192.168.1.0/24 as connected vs 192.168.1.2/32 as static discarded/Null0 route.
Both the /24 and /32 are on the same switch.
I think 192.168.1.2/32 is preferred over the /24 and the return traffic destined to 192.168.1.2 will come back and the router drops it because /32 is chosen as it’s a Null route.
Yes, you are correct, the order of criteria checked is incorrect. This was a post I had posted, but I have since corrected it. The corrected post can be found here:
Thus, if you use a Null route, any traffic going to 192.168.1.2 will be dropped. However, in order to correctly configure this, you should configure a static route to 192.168.1.2/32 with an exit interface like so:
ip route 192.168.1.2 255.255.255.255 gigabitethernet0/0
That way, any traffic that is destined for 192.168.1.2 will match this route, and be sent out of the appropriate interface. Thus, such traffic will not be dropped.
Hi Laz, thanks for correcting the earlier info. I think I have another problem with routing. I thought of using the exit interface after I figured Null0 won’t work but apparently because the server subnet ( the /24 from my earlier post ) is being redistributed into OSPF the router connecting the exit interface is going to send the packets right back to this device and again the static route will take effect pushing the packet back to the exit interface creating a routing loop.
to make it simple I tried my best to explain what’s happening below.
R1 —OSPF --Gigabit 0/0-- R2 — connected as 192.168.1.0/24 and 192.168.1.2/32 static route to Gigabit 0/0
Our server subnet ( /24 ) and the customer uplink ( BGP ) is local to R2
R2 has /24 as connected route redistributed into OSPF so R1 knows abt it.
When you write a static route for the /32 the traffic destined to .2 goes out to Gigabit 0/0 and reaches R1. R1 has route in its routing table for /24 alone pointing it back to R2. This is a routing loop I assume preventing traffic to .2 to never go to the proper interface where it is connected on the router.
My impression was that the 192.168.1.0/24 network, to which the server with the IP address of 192.168.1.2 belongs to, is a directly connected network to R2. If this is the case, then any traffic destined for either the connected route or the static route should exit the same interface. Even if it is redistributed, it shouldn’t send it back out an incorrect interface, as long as you are using the correct exit interface for the static route.
It could be that I am not clear on your topology. Can you clarify and include a diagram with subnets as well as your OSPF config?