Is it possible to import a /20 from one BGP neighbor (example: 172.16.0.0/20) and advertise just one host (/32) out of that /20 to another BGP neighbor (example: 172.16.5.55/32) ? If so, how do I do it?
I know that I could create a static route and export that but I am looking for another way. I was looking into a generate route but so far I am not able to make it work in my lab.
Any help would be much appreciated!
The /20 will not be a contributing route for a /32 generated route. If you just want to advertise a route to another customer use static with next-hop discard and no-install. This will allow BGP to advertise it but it will not be used for packet forwarding.
Hmm, ok thanks for the info!
In order for BGP to advertise a route that specific route would need to be in the routing table.
In this case the route in the routing table is the /20 so you will NOT be able to advertise a /32 because that route is not actually in the routing table. A route policy does not create routes to be advertised it only compares rules to routes that exist in the routing table.
You could create the /32 as a static route so that this is in the table for export to the neighbor.
then create a condition that looks to see if the /20 route exists in the routing table.
Your policy then exports the /32 on the condition that the /20 exists in the routing table. If the condition is not met than the route will not be sent.
Here is a policy example using the condition object.
Thanks Steve, this is what I will implement.
While Steve's way is the "canonical" way to do it in JUNOS, there is another, somewhat simpler one.
All You need to do is to force NH resolution for the /32 via network or broadcast address of overlapping /20:
set routing-options static route 172.16.5.55/32 next-hop 172.16.0.0 resolve
Then, when there is a /20 in the table, /32 will "float up" and You can redistribute it into a routing protocol of Your choice. If /20 is absent, then /32 will sink and disappear from the table.
Obviously , this would work only if You don't have a default (0/0) route.
If You do have one, then You'd need to prevent NH resolution via it which is extra 5-10 lines of config.