Here's my scenario:

Redistribute ospf routes into bgp Create a route-map that matches on route-type=local and modifies the nexthop (to for example) Assign this route-map as outbound routemap (route policy out) for a bgp neighbor.

Will the routes advertised by BGP (the ones redistributed from ospf) have the nexthop changed to

What happens if this route-map was applied with the redistribute command?

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer. – Ron Maupin Apr 1 '18 at 23:06

Regardless of how the network is known by the router, in this case redistributed into BGP via OSPF, it'll follow the route-map specifications.

BGP is going to advertise the network it knows about via OSPF and the next hop will be that of the route-map statement. So yes, it'll still be

If you were to use this route-map on the redistribution itself, it would only be filtering which networks to redistribute from OSPF into BGP. It wouldn't have the power to set next hop or prepend or anything like that.

The difference here is using a route-map to change the next hop for specific networks or allowing certain prefixes to be redistributed in the first place.


Your question has two halves. The first is what prefixes the "route-type=local" will match. The second half is whether the next-hop can be set when the route-map is attached to a neighbor, versus a redistribution.

The first half is easy. The concept of a "local" route is a BGP concept, not an OSPF concept. So if you apply a route-map to a BGP neighbor that filters for local routes, it will match any prefixes that the local router is sourcing (by originating them with a network statement or redistribute statement) and not match any prefixes that were learned from some other BGP neighbor. Therfore, if you apply a route-map to a redistribute statement that brings OSPF into BGP, it will match nothing, since there is no such thing as an OSPF route where the type = local.

Regarding the second half, you got me very curious, so I grabbed a few routers and built this in the lab for myself. What I found is the following:

It is possible to use a route-map to set the next-hop IP address of a prefix by either attaching the route-map to a neighbor, or to a redistribution. When attached to the neighbor statement, the neighbor alone sees the next-hop (and he will subsequently advertise that downstream, if configured to do so). When attached to the redistribute statement, the local router will put the new next-hop into his own BGP table, and subsequently share that with neighbors, if configured to do so. (Take care that the next-hop is actually a reachable IP, since the router may not install the prefix if the next-hop is not reachable.)

As we can see, applying a route-map to a redistribute command is able to do more than just filter prefixes, but also affect the next-hop (for certain protocols). Here is a doc that shows you what match statements and set statements are supported in which protocols.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.