FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
lgupta
Staff
Staff
Article Id 305018
Description This article describes how to modify route preference using Local-Preference Attribute in BGP.
Scope FortiOS.
Solution

Local Peer: 10.9.26.94 configurations:

On this FortiGate, there are two BGP peers: 10.9.17.42 and 10.9.26.163.

 

get router info bgp summary

VRF 0 BGP router identifier 10.9.26.94, local AS number 65005

Neighbor    V         AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd

10.9.17.42  4      65005      10       9        2    0    0 00:00:42        1

10.9.26.163 4      65005      28      24        2    0    0 00:00:42        1

Total number of neighbors 2

 

Note that in the example below, the local peer (10.9.26.94) is receiving 10.10.10.0/24 from both the peers.

 

get router info bgp network

VRF 0 BGP table version is 3, local router ID is 10.9.26.94

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric     LocPrf Weight RouteTag Path

*>i10.10.10.0/24    10.9.17.42      0             100      0        0 i <-/1>

* i                 10.9.26.163     0             100      0        0 i <-/->

 

Total number of prefixes 1

 

This shows that the best route is installed in the routing-table via peer 10.9.17.42.

 

Suppose the goal is for 10.9.26.163 to have the preference over other peers, and it is necessary to to configure this preference parameter on the 10.9.26.163 itself. To do this, use the local-preference attribute. When the local peer (10.9.26.94) learns the routes, it also learns the value of local-preference and then installs the routing-table accordingly.

 

Remote peer: 10.9.26.163 configurations:

 

First, it is necessary to configure the prefix-list to match all (or specific prefix if required) IPs. After, configure Route-Map to refer to the prefix-list and configure a local-preference of 200 (which is higher than the default value of 100). Finally, use this route-map in route-map-out in the BGP configs for the peer 10.9.26.94.

 

config router prefix-list   <- Configuring prefix-list.

    edit "prefix-list"

        config rule

            edit 1

                set prefix 10.10.10.0 255.255.255.0

                unset ge

                unset le

            next

        end

    next

end

 

config router route-map   <- Configuring route-map.

    edit "route-map-pref-200"

        config rule

            edit 1

                set match-ip-address "prefix-list"   <- Referring to prefix-list to match the IP(s).

                set set-local-preference 200   <- Allocating the preference.

            next

        end

    next

end

 

config router bgp

set as 65005

set router-id 10.9.26.163

config neighbor

edit "10.9.26.94"

set capability-graceful-restart enable

set soft-reconfiguration enable

set remote-as 65005

set route-map-out "route-map-pref-200"   <- Referred route-map-out for advertised networks (10.10.10.0/24).

next

end

 

Now, upon resetting or soft resetting the BGP on the local peer (10.9.26.94), the newly installed BGP routes will have 10.9.26.163 as the best route because of the higher local-preference.

 

get router info bgp network

VRF 0 BGP table version is 1, local router ID is 10.9.26.94

Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,

              S Stale

Origin codes: i - IGP, e - EGP, ? - incomplete

 

   Network          Next Hop            Metric     LocPrf Weight RouteTag Path

* i10.10.10.0/24    10.9.17.42      0             100      0        0 i <-/->

*>i                 10.9.26.163     0             200      0        0 i <-/1>

 

Total number of prefixes 1

Comments
vdaniell
Staff
Staff

Please note, this article shows setting local preference outbound. This only works for iBGP. If your neighbor is eBGP this will not work. If you want your remote eBGP neighbor to prefer a particular path towards you they would have to set the local preference inbound for the desired routes they receive from you.

 

Alternatively, you could manipulate another BGP metric (like AS-PATH or MED) to instruct them how best to get to your AS.

 

Vin Daniell

Fortinet SE

 

 

 

Contributors