Skip to main content
alif
Staff
Staff
December 9, 2020

Technical Tip: BGP distance modification on learned routes from neighbors

  • April 16, 2026 at 12:49 PM
  • 0 replies
  • 10522 views

Description

 

This article describes how to modify the distance of iBGP or eBGP routes learned from BGP neighbors.

 

Scope

 

FortiGate.

Solution

 

Consider the following example. There is an eBGP neighborship between two FortiGate devices.

FGT-I.

 

config router bgp
    set as 65101
    set router-id 1.1.1.1
        config neighbor
            edit "10.5.20.134"
                set soft-reconfiguration enable
                set remote-as 65102
            next
        end
        config redistribute "connected"
            set status enable
        end
end

 

FGT-II.

 

config router bgp
    set as 65102
    set router-id 2.2.2.2
        config neighbor
            edit "10.5.19.83"
                set soft-reconfiguration enable
                set remote-as 65101
            next
        end
        config redistribute "connected"
            set status enable
        end
end

 

Since connected routes are advertised over BGP peers, FGT-I is learning a BGP route 10.0.0.0/20 from FGT II as shown in the routing table below.

 

FGT-I # get router info routing-table all
B       10.0.0.0/20 [20/0] via 10.5.20.134, wan1, 00:00:04

 

On FGT-I, the external distance of 50 will be defined as shown below.

 

config router bgp
    set distance-external 50
end
end

 

After making changes, it is advised to perform a soft BGP reset.

 

FGT-I # execute router clear bgp all soft

 

The route learned from eBGP peer will be advertised now with a distance of 50.

 

FGT-I # get router info routing-table all
B       10.0.0.0/20 [50/0] via 10.5.20.134, wan1, 00:00:00

distance-external Distance for routes external to the AS. integer Minimum value: 1 Maximum value: 255 Default: 20 (eBGP)
distance-internal Distance for routes internal to the AS. integer Minimum value: 1 Maximum value: 255 Deafault: 200 (iBGP)

 

Likewise, if a route is learned from an iBGP peer, the default distance is set to a value of 200.
This can be modified to another distance value by 'set distance-internal' under BGP settings.

 

config router bgp

    set distance-internal 100

end

 

Related document:

FortiGate CLI reference: router bgp

Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
Thought Leadership. Security Summit. Thursday, October 8th. Disney's Grand Californian Hotel & SPA, Anaheim, CA.
Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT