Troubleshooting Tip: BGP debug shows the error 'Incorrect leftmost AS number'
| Description | This article describes the workaround for the issue on FortiGate when seeing 'Incorrect leftmost AS number' in BGP debugs |
| Scope | FortiGate. |
| Solution | By default, FortiGate enforces RFC 8212, enforce-first-as (enabled by default since FortiOS v6.2 and newer). This check rejects any BGP UPDATE where the leftmost (first) AS in the AS_PATH is not exactly equal to the configured remote-as of the sending peer. This is a security feature to prevent certain forms of route leaks and AS_PATH spoofing, but it can break specific legitimate scenarios.
Enable BGP debugs:
diagnose ip router bgp all enable diagnose ip router bgp level info diagnose debug enable
To disable BGP debugs:
diagnose ip router bgp all disable diagnose ip router bgp level none diagnose debug reset
Note: Starting from v7.2.0+, it is possible to collect BGP debugs for a specific neighbor by using the filter command 'diagnose ip router bgp set-filter neighbor <neighbor address>'. Follow this KB article for more details: Technical Tip: Capture BGP debugs for a specific neighbor.
The following would show up in debugs:
BGP: 10.10.10.2-Outgoing [DECODE] Update: Starting UPDATE decoding... Bytes To Read (4005), msg_size (86)
When performing a packet capture on Wireshark, it is possible to see this event: Internet Protocol Version 4, Src: 10.68.15.2, Dst: 10.68.15.10
While the BGP router configuration for the reported neighbor is defined as: config router bgp BGP debug on the FortiGate side shows the error and withdraws the received prefixes: BGP: 10.68.15.2-Outgoing [DECODE] Msg-Hdr: type 2, length 58
Check on the BGP peer to find out why FortiGate is receiving the 'incorrect AS number' error.
When this setting is enabled, BGP does a comparison between the remote AS and several BGP peers configured locally with the first AS in the path of received routes. Disabling this will resolve the issue. |
