Created on
‎01-27-2025
07:56 AM
Edited on
‎11-23-2025
10:29 PM
By
Jean-Philippe_P
| Description | This article describes how to perform initial diagnostics for non-working BGP over IPsec. |
| Scope | FortiOS v6.x, v7.x. |
| Solution |
BGP is a widely used dynamic routing protocol. It allows running over IPsec tunnels, which makes it very useful to advertise routes over IPsec tunnels or in ADVPN.
First step when troubleshooting BGP is to list the BGP peers using the command below:
get router info bgp summary VRF 0 BGP router identifier 192.168.2.1, local AS number 65551 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
The first line shows the IP address (192.168.2.2) of the remote BGP peer, which is configured as a remote peer; the second value is the AS of the remote peer, which is 65551. The output also shows that the BGP is UP and running, and the TCP session is established. If the option 'set passive' is not configured on any of the FortiGates, this means that every one of the peers will start to initiate a TCP session. The easiest way to find which peer initiated the BGP session is to use the command below, which filters the session list by the BGP peer:
get system session list | grep 192.168.2.2
The output shows that the session is locally from FG_1 towards remote BGP peer 192.168.2.2, with this info could be used as a filter to filter by source/destination IP the session list, which will give more information for the ingress/egress interface, duration of the session, and other useful information.
diagnose sys session filter dst 192.168.2.2 diagnose sys session list
session info: proto=6 proto_state=01 duration=403 expire=3583 timeout=3600 refresh_dir=both flags=00000000 socktype=0 sockport=0 av_idx=0 use=3
The field duration shows before how many seconds this session was created, the field dev=14->19/19->14 shows the ingress and egress interface. This field indicates originating traffic flow from dev 14->19 and replying traffic flow from 19->14. Dev=14 and dev=19 are not the names of the interfaces; they are the device_ID of interfaces, which are assigned by FortiOS. The command below shows how to find the names of the interfaces assigned to this device_id:
get router info kernel | grep dev=14
get router info kernel | grep dev=19
The output below shows that the BGP session with peer 192.168.2.2 is down:
get router info bgp summary VRF 0 BGP router identifier 192.168.2.1, local AS number 65551 Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
The state 'Connect' means that the local FortiGate is trying to open a TCP session with the remote peer, but there is no reply back from that peer. The first step is to perform a sniffer and notice if there is traffic to this peer and if it is routed via the correct interface:
diagnose sniffer packet any " host 192.168.2.1 or host 192.168.2.2" 4
The sniffer above shows that FortiGate is trying to open a TCP session with peer 192.168.2.2 (local IP address is 192.168.2.1), but the remote side is also trying to open a TCP session with source IP 192.168.2.3. This one could indicate a problem with the wrong BGP peer IP address. Because there is a mismatch between the local and remote BGP peers, the local FortiGate sends an RST packet.
Another potential factor to look out for when BGP is running on top of IPsec is to make sure that the local and remote BGP peer IP addresses are included in phase-2 selectors. The sniffer below shows this problem. The local BGP peer IP address is sending TCP SYN packets, but there are no received packets:
diagnose sniffer packet any " host 192.168.2.1" 8.353618 VPN_1 out 192.168.2.1.11324 -> 192.168.2.2.179: syn 41379263
Using the command 'fnsysctl ifconfig VPN_1' could show if there are dropped packets on the exit interface:
fnsysctl ifconfig VPN_1
fnsysctl ifconfig VPN_1
The errors indicate a problem with traffic that should be sent out to the remote peer: it is dropped instead. Using debug flow, information may be gained on why traffic is dropped:
diagnose debug reset
id=65308 trace_id=8 func=print_pkt_detail line=5998 msg="vd-root:0 received a packet(proto=6, 192.168.2.1:11364->192.168.2.2:179) tun_id=0.0.0.0 from local. flag [S], seq 634790851, ack 0, win 27600"
The error indicates that there is a problem with the encryption domain, and IPsec phase-2 selectors need to be checked on both sides of the IPSec tunnel. When BGP runs over IPSec is good practice to check if the VPN is UP and running using the commands below :
diagnose vpn ike gateway list name VPN_1 vd: root/0 id/spi: 14 faa9b69ef23aa946/0000000000000000
diagnose vpn tunnel list name VPN_1 proxyid_num=1 child_num=0 refcnt=4 ilast=1176 olast=1176 ad=/0
diagnose sniffer packet any " host 192.168.2.1" 4
Because the IPsec is down, FortiGate is trying to reach the remote BGP peer using the default route via port1. Another useful set of commands that can be used for troubleshooting the BGP is as follows:
SSH No1:
diagnose ip router bgp all enable
To disable BGP debugs:
diagnose ip router bgp all disable diagnose ip router bgp level none diagnose debug reset
SSH No2:
diagnose sniffer packet any "host x.x.x.x and host y.y.y.y and port 179" 6 <----- Where x.x.x.x and y.y.y.y are the BGP peering involved. |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.