Network Automation Reference

FortiGate SD-WAN Hub and Spoke with BGP on Loopback (FortiOS 7.6)

This FortiGate SD-WAN BGP on loopback design runs one iBGP session per spoke over two IPsec overlays. The peers use loopback addresses, so a tunnel can go down without forcing a BGP reset if the other tunnel still carries the session. In this FortiOS 7.6.7 example, a FortiGate 400F hub reflects branch routes and each spoke uses an SD-WAN performance SLA to steer matching traffic.

The design is easiest to understand from Branch-2’s routing table. It learns 10.10.2.0/27 with Branch-1’s loopback as the BGP next hop. That next hop resolves through two tunnels to the hub. The sample output below shows both paths installed and explains what to measure during a failover test.

FortiGate SD-WAN BGP on Loopback topology and addressing

This example uses one hub, two MPLS underlays and one iBGP session per spoke in AS 65500. Both IPsec overlays carry traffic through the hub. The diagram shows three representative branches. The BGP summary later in the guide shows five peers in the range 10.255.100.11 through 10.255.100.15.

FortiGate SD-WAN BGP on Loopback topology with a hub, three spokes and dual IPsec overlays
Dual MPLS underlays carry two IPsec overlays. The diagram shows three representative branches.

Use the NetConfig network diagram maker to map your underlay interfaces and tunnel IDs before adapting the example.

DeviceLoopbackOverlay mappingLAN prefixes
Hub (FortiGate 400F)10.255.100.2/32H1-INET1 on port1 (10.255.1.5) and H1-INET2 on port2 (10.255.0.6)Six 172.20.x.x prefixes listed in the hub CLI
Branch-110.255.100.11/32Both overlays10.10.2.0/27 is used for verification
Branch-210.255.100.13/32H1-INET1 on lan2 via 10.255.1.21. H1-INET2 on lan1 via 10.255.0.21.10.30.3.0/27, 10.30.4.0/27, 10.30.6.0/27
Branch-310.255.100.15/32Both overlays10.50.3.0/27, 10.50.4.0/27, 10.50.6.0/27

The tunnel numbers and physical interface numbers are easy to mix up at Branch-2. lan1 reaches the hub at 10.255.0.6 and carries H1-INET2. lan2 reaches 10.255.1.5 and carries H1-INET1. Match the remote gateway and network ID to the correct uplink before testing either tunnel.

How BGP on loopback uses both overlays

With BGP per overlay, 50 spokes with two tunnels each can mean 100 iBGP sessions to one hub. Loopback peering brings that example to 50 sessions. The tunnel transports the TCP session, while the local and remote loopback addresses identify the peers. Fortinet recommends loopback peering for new 7.6 designs. See the Fortinet SD-WAN route exchange guide.

Two lookups make this design work. First, IKEv2 exchanges the loopback addresses, so the hub learns a host route to each connected branch loopback. Second, a receiving spoke resolves the unchanged BGP next hop for a remote branch LAN against a static route for the loopback pool. That static route points to the overlay zone, so the remote branch LAN can resolve through either available hub tunnel.

Configure the FortiGate SD-WAN hub

The snippets assume the example VDOM, WAN and LAN interfaces, base routing, address objects and firewall zones are available where referenced. Replace interface names, route and member IDs, gateways and pre-shared key placeholders with values from your deployment. The CLI is organized in deployment order so you can verify the transport before adding BGP.

Before applying the example, save the current configuration and record the existing routing and policy state. Check whether route IDs, SD-WAN member IDs and the BGP AS are already in use. An edit command with an existing ID changes that entry, so map the sample IDs to unused ones or merge changes into the intended objects. The sample configurations are adapted from the original walkthrough. The screenshots and CLI captures illustrate the routing state, while the steps below explain how to validate it in your own deployment.

1. Create the hub loopback

Use 10.255.100.2/32 as the router ID, BGP update source and SLA target. The example enables ping for SLA probes. Use a dedicated management path for SSH and HTTPS.

config system interface
    edit "LOOPBACK"
        set vdom "root"
        set ip 10.255.100.2 255.255.255.255
        set allowaccess ping
        set type loopback
        set role lan
    next
end
FortiGate hub loopback interface with IP address 10.255.100.2/32
The hub loopback provides the iBGP endpoint and the branch SLA target.

2. Configure the two dial-up IPsec tunnels

Each hub Phase 1 listens on its own MPLS interface. A spoke uses network ID 1 for H1-INET1 and network ID 2 for H1-INET2. Keep the proposals, Diffie–Hellman groups and key material consistent between each hub listener and its spoke peers.

config vpn ipsec phase1-interface
    edit "H1-INET1"
        set type dynamic
        set interface "port1"
        set ike-version 2
        set keylife 28800
        set peertype any
        set net-device disable
        set exchange-ip-addr4 10.255.100.2
        set proposal aes256-sha256
        set add-route disable
        set dpd on-idle
        set dhgrp 14
        set auto-discovery-sender enable
        set network-overlay enable
        set network-id 1
        set transport auto
        set psksecret <PRE-SHARED-KEY>
        set dpd-retrycount 2
        set dpd-retryinterval 3
    next
    edit "H1-INET2"
        set type dynamic
        set interface "port2"
        set local-gw 10.255.0.6
        set ike-version 2
        set keylife 28800
        set peertype any
        set net-device disable
        set exchange-ip-addr4 10.255.100.2
        set proposal aes256-sha256
        set add-route disable
        set dpd on-idle
        set dhgrp 14
        set auto-discovery-sender enable
        set network-overlay enable
        set network-id 2
        set transport auto
        set psksecret <PRE-SHARED-KEY>
        set dpd-retryinterval 5
    next
end

config vpn ipsec phase2-interface
    edit "H1-INET1"
        set phase1name "H1-INET1"
        set proposal aes256-sha256
        set dhgrp 14
        set keepalive enable
        set keylifeseconds 1800
    next
    edit "H1-INET2"
        set phase1name "H1-INET2"
        set proposal aes256-sha256
        set dhgrp 14
        set keepalive enable
        set keylifeseconds 1800
    next
end
  • set net-device disable uses a shared dial-up interface per hub listener in this design.
  • set add-route disable prevents automatic installation of selector-derived routes. With broad Phase 2 selectors, check that the hub does not acquire an unintended default route.
  • set exchange-ip-addr4 10.255.100.2 advertises the hub loopback in IKEv2. The matching spoke setting advertises the spoke’s own loopback.
  • set network-overlay enable and the matching network IDs distinguish the two overlays during negotiation.
Hub H1-INET1 dial-up IPsec Phase 1 settings with network ID 1
H1-INET1 uses IKEv2 with network ID 1 and automatic selector-route installation disabled.

3. Add the hub tunnels to an SD-WAN zone

Put both logical dial-up interfaces in Overlay. You can then reference the zone in firewall policy while the member interfaces identify individual paths.

config system sdwan
    set status enable
    config zone
        edit "Overlay"
        next
    end
    config members
        edit 1
            set interface "H1-INET1"
            set zone "Overlay"
        next
        edit 2
            set interface "H1-INET2"
            set zone "Overlay"
        next
    end
end

4. Configure iBGP and route reflection

For this FortiGate SD-WAN BGP on loopback configuration, the advpn neighbor group listens for iBGP peers in the 10.255.100.0/24 loopback pool. Each branch acts as a route-reflector client. The hub can then re-advertise branch LAN prefixes to the other spokes with the original branch loopback as next hop. The neighbor range matches peer addresses. The network statements originate the hub’s own LAN prefixes.

config router bgp
    set as 65500
    set router-id 10.255.100.2
    set ibgp-multipath enable
    set graceful-restart enable
    config neighbor-group
        edit "advpn"
            set advertisement-interval 1
            set capability-graceful-restart enable
            set link-down-failover enable
            set soft-reconfiguration enable
            set interface "LOOPBACK"
            set remote-as 65500
            set update-source "LOOPBACK"
            set route-reflector-client enable
        next
    end
    config neighbor-range
        edit 1
            set prefix 10.255.100.0 255.255.255.0
            set neighbor-group "advpn"
        next
    end
    config network
        edit 1
            set prefix 172.20.20.0 255.255.255.0
        next
        edit 2
            set prefix 172.20.21.0 255.255.255.0
        next
        edit 3
            set prefix 172.20.22.0 255.255.255.0
        next
        edit 4
            set prefix 172.20.23.0 255.255.255.240
        next
        edit 5
            set prefix 172.20.24.0 255.255.255.0
        next
        edit 6
            set prefix 172.20.25.0 255.255.255.240
        next
    end
end

Verify that each advertised hub LAN prefix exists with the exact mask in the hub routing table. The spoke static routes below supply reachability to the loopback pool, so this example omits a BGP advertisement for the shared /24. Fortinet also documents a design where the hub advertises a loopback summary. See the Fortinet route reflection and dynamic BGP comparison.

Hub FortiGate BGP neighbor group and loopback neighbor range
The hub accepts branch loopback peers through the neighbor group and neighbor range.

5. Allow BGP, SLA probes and branch transit

Use separate policy scopes for traffic destined to the hub loopback and traffic forwarded between sites. Permit TCP 179 between the intended peer loopbacks and ICMP from approved SLA sources. Check any local-in restrictions as well. For the routed LAN traffic shown here, keep NAT disabled so transit preserves the site addresses.

  • Overlay to core LAN permits branch access to the approved hub subnets behind port3.
  • Core LAN to overlay permits hub-originated user sessions from those subnets to permitted branch services.
  • Overlay to overlay permits approved spoke-to-spoke traffic through the hub. Limit the source, destination and services to the intended branch paths.
Hub firewall policy list with overlay-to-LAN and overlay-to-overlay policies
The hub policy list shows the overlay-to-overlay path used for branch transit.

Configure Branch-2

Branch-2 uses 10.255.100.13/32. For another branch, change the loopback, underlay interfaces and gateways, advertised LAN prefixes and policy objects. Keep the AS and remote hub loopback consistent with the hub configuration.

1. Create the spoke loopback

config system interface
    edit "LOOPBACK"
        set vdom "root"
        set ip 10.255.100.13 255.255.255.255
        set allowaccess ping
        set type loopback
        set role lan
    next
end

2. Configure the two IPsec tunnels

The spoke initiates both tunnels to fixed hub underlay addresses. Confirm that the underlay routing reaches each hub address through its corresponding MPLS gateway. Install the two Phase 2 entries after the Phase 1 interfaces exist.

config vpn ipsec phase1-interface
    edit "H1-INET1"
        set interface "lan2"
        set ike-version 2
        set keylife 28800
        set peertype any
        set net-device enable
        set exchange-ip-addr4 10.255.100.13
        set proposal aes256-sha256
        set dpd on-idle
        set dhgrp 14
        set auto-discovery-receiver enable
        set network-overlay enable
        set network-id 1
        set transport udp
        set remote-gw 10.255.1.5
        set psksecret <PRE-SHARED-KEY>
        set dpd-retryinterval 5
    next
    edit "H1-INET2"
        set interface "lan1"
        set ike-version 2
        set keylife 28800
        set peertype any
        set net-device enable
        set exchange-ip-addr4 10.255.100.13
        set proposal aes256-sha256
        set dpd on-idle
        set dhgrp 14
        set auto-discovery-receiver enable
        set network-overlay enable
        set network-id 2
        set transport udp
        set remote-gw 10.255.0.6
        set psksecret <PRE-SHARED-KEY>
        set dpd-retryinterval 5
    next
end

config vpn ipsec phase2-interface
    edit "H1-INET1"
        set phase1name "H1-INET1"
        set proposal aes256-sha256
        set dhgrp 14
        set keepalive enable
        set keylifeseconds 1800
    next
    edit "H1-INET2"
        set phase1name "H1-INET2"
        set proposal aes256-sha256
        set dhgrp 14
        set keepalive enable
        set keylifeseconds 1800
    next
end

3. Configure the SD-WAN zones, SLA and rule

Members 1 and 2 are the underlay interfaces. Member 3 is H1-INET1 and member 4 is H1-INET2. The SLA sends probes from 10.255.100.13 to the hub loopback across both overlays. Its targets are 100 ms latency, 20 ms jitter and 2% loss. Adjust them to the traffic’s requirements and the circuits’ baseline.

Create CORPORATE_OVERLAY_DESTINATIONS as an address group for the routed hub and remote branch LANs. The three source objects in the rule must also exist. This scopes steering to traffic expected to cross the overlays.

config system sdwan
    set status enable
    config zone
        edit "UNDERLAY-MPLS"
        next
        edit "Overlay"
        next
    end
    config members
        edit 1
            set interface "lan1"
            set zone "UNDERLAY-MPLS"
            set gateway 10.255.0.21
        next
        edit 2
            set interface "lan2"
            set zone "UNDERLAY-MPLS"
            set gateway 10.255.1.21
        next
        edit 3
            set interface "H1-INET1"
            set zone "Overlay"
        next
        edit 4
            set interface "H1-INET2"
            set zone "Overlay"
        next
    end
    config health-check
        edit "HUB_LOOPBACK_SLA"
            set server "10.255.100.2"
            set update-static-route disable
            set source 10.255.100.13
            set members 4 3
            config sla
                edit 1
                    set link-cost-factor latency jitter packet-loss
                    set latency-threshold 100
                    set jitter-threshold 20
                    set packetloss-threshold 2
                next
            end
        next
    end
    config service
        edit 1
            set name "CORP_OVERLAY_TRAFFIC"
            set mode sla
            set dst "CORPORATE_OVERLAY_DESTINATIONS"
            set src "Vlan_400 address" "Vlan_500 address" "Vlan_10 address"
            config sla
                edit "HUB_LOOPBACK_SLA"
                    set id 1
                next
            end
            set priority-members 4 3
        next
    end
end

The rule uses mode sla. In the example, H1-INET2 stays selected even when H1-INET1 measures lower latency. Check that both members meet the SLA and verify their configured costs and priority order. With equal member cost, the eligible preferred member appears first in the order 4 3. See Fortinet’s lowest-cost SLA strategy.

The SLA has update-static-route disable. That leaves the overlay pool route in place when a member misses probes, while the service rule evaluates eligible paths for matching traffic. Inspect the selected member and route resolution separately when testing a failure.

Branch FortiGate SD-WAN zones and member interfaces
Branch underlays and overlays are in separate SD-WAN zones.
Branch service rule selecting H1-INET2
The service rule shows H1-INET2 selected for matching traffic.
Branch performance SLA latency graph for both VPN overlays
The performance SLA measures both paths to the hub loopback.

4. Route the loopback pool through the overlay

The example uses the underlay zone for its default route and sends 10.255.100.0/24 to Overlay. Keep the underlay path to the hub’s MPLS addresses reachable. Where your existing underlay routes are more specific, retain them and add the overlay pool route under an unused route ID.

config router static
    edit 1
        set distance 1
        set sdwan-zone "UNDERLAY-MPLS"
    next
    edit 2
        set dst 10.255.100.0 255.255.255.0
        set distance 1
        set sdwan-zone "Overlay"
    next
end

On Branch-2, check the hub loopback 10.255.100.2 and the remote spoke loopback 10.255.100.11. The hub loopback is the iBGP peer. The second is the next hop of Branch-1 LAN prefixes. Both must resolve through the overlay.

5. Establish iBGP with the hub

Bind the neighbor to LOOPBACK and enable recursive next-hop resolution. Advertise the three local branch LANs. Keep BGP’s network import check in place so a LAN goes out in BGP only when the matching prefix is in the routing table.

config router bgp
    set as 65500
    set router-id 10.255.100.13
    set ibgp-multipath enable
    set recursive-next-hop enable
    set graceful-restart enable
    config neighbor
        edit "10.255.100.2"
            set advertisement-interval 1
            set capability-graceful-restart enable
            set soft-reconfiguration enable
            set interface "LOOPBACK"
            set remote-as 65500
            set update-source "LOOPBACK"
        next
    end
    config network
        edit 2
            set prefix 10.30.3.0 255.255.255.224
        next
        edit 3
            set prefix 10.30.4.0 255.255.255.224
        next
        edit 4
            set prefix 10.30.6.0 255.255.255.224
        next
    end
end
Branch BGP neighbor with the loopback selected as update source
Branch-2 uses its loopback as the update source for the hub peer.

6. Permit branch LAN traffic and loopback services

Apply the branch equivalents of the hub policies. Allow the approved local VLANs to reach corporate prefixes through Overlay, and add the reverse initiation policy if the deployment requires it. Scope traffic destined for LOOPBACK to the trusted peer addresses and required BGP and ICMP services. See Fortinet’s loopback peering and policy example.

Verify IPsec, BGP and failover

Check tunnel state first, then loopback reachability, then BGP, and finally application traffic. A failure at each layer narrows the diagnosis. For example, an established IKE session does not establish that Phase 2 carries the traffic you expect. An established BGP session does not establish that a branch LAN prefix was advertised, accepted and installed.

1. Confirm both IPsec overlays are up

Check the Phase 1 and Phase 2 entries on Branch-2 and the corresponding dial-up entries on the hub. Tunnel counters show that traffic has crossed a tunnel. To identify the path a new flow takes, check the SD-WAN rule and the flow during the same test.

FortiGate hub VPN tunnel monitor showing active dial-up tunnels
The hub tunnel monitor shows the dial-up overlays.
Branch-2 IPsec monitor showing H1-INET1 and H1-INET2
Branch-2 has IPsec associations on both overlays.

2. Check the hub routes to the branch loopback

Look up Branch-2’s 10.255.100.13/32 on the hub. The sample marks the route as static with distance 15 and shows two tunnel paths. Here those paths are installed by IKE after exchanging the loopback addresses. Compare the routing entry with the configured static routes if you need to determine the origin of a similar entry on your firewall.

HUB-FIREWALL # get router info routing-table details 10.255.100.13


Routing table for VRF=0
Routing entry for 10.255.100.13/32
  Known via "static", distance 15, metric 0, best
  * via H1-INET2 tunnel 10.0.0.3 vrf 0, tun_id
  * via H1-INET1 tunnel 10.255.100.13 vrf 0, tun_id
Hub routing table showing two tunnel paths to 10.255.100.13/32
The hub has two IKE-learned paths to Branch-2’s loopback.

3. Check the BGP session and reflected prefixes

On the hub, run get router info bgp summary and confirm the intended branch peers have established sessions. On Branch-2, inspect a route received from the hub. Branch-1’s 10.10.2.0/27 should show 10.255.100.11 as the BGP next hop.

Hub BGP summary showing five established branch loopback peers
The hub BGP summary shows five branch neighbors.

4. Confirm recursive paths and measure failover

BRANCH-2-FW # get router info routing-table details 10.10.2.0/27


Routing table for VRF=0
Routing entry for 10.10.2.0/27
  Known via "bgp", distance 200, metric 0, best
  Last update 03:14:06 ago
  * vrf 0 10.255.100.11 priority 1 (recursive via H1-INET2 tunnel 10.255.0.6)
                                   (recursive via H1-INET1 tunnel 10.255.1.5)

This output shows one BGP next hop and two resolved tunnel paths. It confirms the routing state at the moment of capture. To measure failover, record the BGP uptime and start a test flow between the branch LANs. Disable one underlay at a time during a maintenance window. Record packet loss, the selected SD-WAN member and whether the BGP uptime resets. Restore the first path before testing the second. Use the FortiOS 7.6.7 SD-WAN diagnostic commands to inspect member and SLA state.

Repeat the test with a new session and an existing session if your applications depend on session continuity. Compare the results before and after the primary member returns. If BGP uptime resets, check when loopback reachability was lost relative to the peer’s hold timer. If only the application stops, compare the policy match, the selected member and the return path at the far end. Save those observations with the baseline and the FortiOS build so another engineer can reproduce the test.

Troubleshoot four BGP on loopback symptoms

1. A remote loopback resolves through the MPLS underlay

A route to the remote LAN may be present in BGP while its next hop uses the underlay default route. On the receiving spoke, look up the remote loopback directly and verify that 10.255.100.0/24 points to Overlay. If traffic is dropped by reverse-path checking, compare the source-route lookup and ingress interface using the NetConfig FortiGate debug flow reference.

For a hub-transit path, check both directions. Branch-2 needs a route to Branch-1’s LAN and the hub needs a route to each branch loopback. Branch-1 also needs the return route to the source LAN at Branch-2. A one-way prefix advertisement can leave the tunnel and BGP session looking healthy while traffic fails.

2. The BGP neighbor stays in Active or Connect

Ping the hub loopback from the spoke loopback, then capture TCP 179 while the neighbor attempts to connect. If the source is wrong, check update-source. If the session uses the correct source and receives no reply, check the return route, hub neighbor range and the policies for traffic to each loopback. If TCP connects and BGP then closes, check the AS and any configured neighbor authentication.

3. The hub learns an unexpected default route when the first spoke connects

Inspect the new route and its originating tunnel before changing the setup. If the route was installed from a broad Phase 2 selector, check add-route on the associated hub dial-up listener. The NetConfig FortiGate IPsec and packet-flow debug guide includes commands for tracing the negotiation and forwarding path.

4. BGP learns the prefix but the routing table has no usable path

Inspect the next hop for that exact BGP prefix and compare it with the routing table. Check recursive-next-hop, the overlay pool route and tunnel availability. If the next hop is reachable, check whether a competing route or an inbound route policy is preventing the expected path from being installed.

Frequently asked questions

Does FortiGate SD-WAN BGP on loopback require eBGP multihop?

No. Both peers use AS 65500, so this is an iBGP session. The iBGP session depends on reachability between the loopbacks and the correct update source on each peer.

Why does the hub have no static route for the full loopback pool?

IKE installs a /32 route to each connected spoke loopback. The hub uses those routes for return reachability. The spokes use the pool route to the overlay zone to resolve remote loopbacks through the hub.

Why doesn’t Branch-2 advertise the shared loopback pool?

The spoke’s pool route is for next-hop resolution. Branch-2 owns its assigned loopback and advertises its own LAN prefixes. If you adopt the Fortinet design with a BGP-advertised loopback summary, originate the summary at the hub and validate how it interacts with the spokes’ static routes.

Do the ADVPN sender and receiver settings enable direct shortcuts on their own?

Treat direct shortcuts as a separate design and test. This guide verifies paths through the hub. Before relying on shortcuts, choose the ADVPN and route exchange method for your release, then verify that the shortcut forms, routes resolve over it and traffic follows the inspection path you intend.

Advertisement

Leave a Comment

Sign in with Google to comment — verifies you're a real person. No WordPress account is created; nothing beyond your name and email is used.

✓ Signed in — you can comment below.