I have this route on my Juniper Router and some destinations have two routes: OSPF and BGP. I want to change the administrative distance for the BGP route so that it will be smaller than the OSPF route.

How do I do it?

enter image description here

  • You should post your current routing configuration from your device.
    – user36472
    Apr 8, 2019 at 6:29
  • 3
    Why would you want to do that? Changing these preferences may break your entire network.
    – Teun Vink
    Apr 8, 2019 at 7:01
  • @TeunVink considenring the routes to (from and to I bet this is a test setup.
    – JFL
    Apr 8, 2019 at 7:51
  • 2
    Sure, but changing AD for protocols is usually not the solution to any problem.
    – Teun Vink
    Apr 8, 2019 at 7:52

1 Answer 1


You can use the command

set protocols bgp group <group name> preference <value>

or you can also use a routing policy to change preference for specific routes within BGP.

However as commented by @TeunVink, there's only limited cases where you would tweak administrative distances. There's generally better options, or that would mean your network design is somewhat flawed.

Also you must be aware of how Juniper handle external BGP vs internal BGP and OSPF.

From the page Example: Configuring the Preference Value for BGP Routes

By default, the routing software assigns a preference of 170 to routes that originated from BGP. Of all the routing protocols, BGP has the highest default preference value, which means that routes learned by BGP are the least likely to become the active route.

Some vendors have a preference (distance) of 20 for external BGP (EBGP) and a distance of 200 for internal BGP (IGBP). Junos OS uses the same value (170) for both EBGP and IBGP. However, this difference between vendors has no operational impact because Junos OS always prefers EBGP routes over IBGP routes.

Another area in which vendors differ is in regard to IGP distance compared to BGP distance. For example, some vendors assign a distance of 110 to OSPF routes. This is higher than the EBGP distance of 20 , and results in the selection of an EBGP route over an equivalent OSPF route. In the same scenario, Junos OS chooses the OSPF route, because of the default preference 10 for an internal OSPF route and 150 for an external OSPF route, which are both lower than the 170 preference assigned to all BGP routes.

  • I managed to do it with that command: set protocols bgp preference 2
    – Aviv Shaar
    Apr 10, 2019 at 10:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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