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.
subramanis
Staff
Staff
Article Id 394004
Description

This article describes the behavior of a FortiGate during route advertisement to an external BGP (eBGP) peer.

 

By default, when advertising a route to an eBGP peer, the FortiGate modifies the NEXT_HOP attribute to its IP address. This behavior ensures reachability through the advertising FortiGate.

 

However, when the set attribute-unchanged next-hop option is configured, the FortiGate preserves the original NEXT_HOP attribute and advertises the route without modification. This is useful in deployments where maintaining the original next-hop information is required for proper routing decisions or end-to-end path visibility.

Scope FortiGate.
Solution

Diagram:

FGT1 (Port2 172.16.1.2)-------(172.16.1.1 Port2) FGT2.

 

FGT1 # show router bgp
config router bgp
    set as 65555
    set router-id 172.16.1.2
        config neighbor
            edit "172.16.1.1"
                set soft-reconfiguration enable
                set remote-as 65444
            next
        end
        config network
        end
        config redistribute "connected"
        end

        config redistribute "rip"
        end
        config redistribute "ospf"
        end
        config redistribute "static"
            set status enable <-------
        end

FGT1 # show router static
config router static
    edit 1
        set dst 4.4.4.4 255.255.255.255
        set gateway 10.254.1.100
        set device "port1"
    next
end

 

The FortiGate modifies the NEXT_HOP attribute to its own IP address(172.16.1.2):

 

FGT1 # get router info bgp neighbors 172.16.1.1 advertised-routes
VRF 0 BGP table version is 1, local router ID is 172.16.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight RouteTag Path
*> 4.4.4.4/32 172.16.1.2 32768 0 ? <-/->
Total number of prefixes 1

 

The objective is to modify the NEXT_HOP attribute to 10.254.1.100 when FGT1 advertises the prefix 4.4.4.4 to its eBGP peer FGT2. By default, it is not possible.

 

FGT1 # show router bgp
config neighbor
    edit "172.16.1.1"
        set attribute-unchanged next-hop  <-------
    next
end

 

FGT1 # get router info bgp neighbors 172.16.1.1 advertised-routes
VRF 0 BGP table version is 1, local router ID is 172.16.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight RouteTag Path
*> 4.4.4.4/32 10.254.1.100 32768 0 ? <-/->

Total number of prefixes 1

 

After configuring 'set attribute-unchanged next-hop', the original next hop (10.254.1.100) was advertised to the eBGP neighbor.

 

The next-hop can be changed to any IP address and does not need to match the static route's gateway. For example,
even if the prefix 4.4.4.4/32 is configured with a static route pointing to 10.254.1.100, it is still possible to change the
next hop to 192.168.1.1 by configuring a route map in the outbound direction, as shown in the example below.

This is also valid when advertising the network using the network statement

 

FGT1 # show router bgp
config router bgp
    config neighbor
        edit "172.16.1.1"
            set route-map-out "nexthop"
        next
end

 

FGT1 # show router route-map
config router route-map
    edit "nexthop"
        config rule
            edit 1
                set match-ip-address "4.4.4.4"
                set set-ip-nexthop 192.168.1.1
                unset set-ip-prefsrc
            next
        end
    next
end

 

FGT1 # show router prefix-list
config router prefix-list
    edit "4.4.4.4"
        config rule
            edit 1
                set prefix 4.4.4.4 255.255.255.255
                unset ge
                unset le
            next
        end
    next
end


FGT1 # get router info bgp neighbors 172.16.1.1 advertised-routes
VRF 0 BGP table version is 1, local router ID is 172.16.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight RouteTag Path
*> 4.4.4.4/32 192.168.1.1 32768 0 ? <-/->

Total number of prefixes 1