1+ # SPDX-License-Identifier: GPL-3.0-or-later
2+ #
3+ # GNS3-Skills - Packet analysis rules for BGP
4+ #
5+ # Copyright (C) 2025 Yue Guobin
6+ #
7+
8+ name : " BGP Packet Analysis"
9+ description : " BGP-4 packet analysis for session establishment, route exchange, and notification errors"
10+ protocol : " bgp"
11+ display_filter : " bgp"
12+
13+ fields :
14+ - label : " Frame Number"
15+ field : " frame.number"
16+ description : " Packet sequence number in capture"
17+
18+ - label : " Source IP"
19+ field : " ip.src"
20+ description : " BGP speaker source address (TCP 179 source or destination)"
21+
22+ - label : " Destination IP"
23+ field : " ip.dst"
24+ description : " BGP peer destination address"
25+
26+ - label : " BGP Message Type"
27+ field : " bgp.type"
28+ description : " BGP message type: 1=Open, 2=Update, 3=Notification, 4=Keepalive, 5=RouteRefresh"
29+
30+ - label : " BGP Message Length"
31+ field : " bgp.length"
32+ description : " Total BGP message length in bytes (header + data)"
33+
34+ - label : " BGP Marker"
35+ field : " bgp.marker"
36+ description : " BGP marker (all 0xFF for IPv4, used for synchronization)"
37+
38+ - label : " Open - BGP Identifier"
39+ field : " bgp.router_id"
40+ description : " BGP Router-ID (advertised in OPEN message)"
41+
42+ - label : " Open - AS Number"
43+ field : " bgp.as_path"
44+ description : " AS number from OPEN message (2-byte or 4-byte)"
45+
46+ - label : " Open - Hold Time"
47+ field : " bgp.hold_time"
48+ description : " Hold time advertised in OPEN (negotiated to lower of the two)"
49+
50+ - label : " Open - Optional Parameters"
51+ field : " bgp.optional_parameter.type"
52+ description : " Capabilities advertised: 2=4-byte AS, 64=Graceful Restart, 6=RouteRefresh, 1=Add-Path"
53+
54+ - label : " Update - Withdrawn Routes"
55+ field : " bgp.withdrawn_prefix"
56+ description : " Prefixes being withdrawn in UPDATE message"
57+
58+ - label : " Update - NLRI Prefixes"
59+ field : " bgp.nlri_prefix"
60+ description : " Prefixes being advertised in UPDATE message"
61+
62+ - label : " Update - Next Hop"
63+ field : " bgp.next_hop"
64+ description : " Next-hop IP address in UPDATE path attributes"
65+
66+ - label : " Update - AS Path"
67+ field : " bgp.as_path"
68+ description : " AS path attribute (AS sequence or AS set)"
69+
70+ - label : " Update - Origin"
71+ field : " bgp.origin"
72+ description : " Origin attribute: 0=IGP, 1=EGP, 2=Incomplete"
73+
74+ - label : " Update - Local Preference"
75+ field : " bgp.local_pref"
76+ description : " Local preference attribute (only within AS)"
77+
78+ - label : " Update - Multi-Exit Discriminator"
79+ field : " bgp.med"
80+ description : " MED attribute for inbound path selection"
81+
82+ - label : " Update - Communities"
83+ field : " bgp.community"
84+ description : " BGP community attribute"
85+
86+ - label : " Notification - Error Code"
87+ field : " bgp.notification.code"
88+ description : " Notification error code: 1=MsgHeader, 2=Open, 3=Update, 4=HoldTimer, 5=FSM, 6=Cease"
89+
90+ - label : " Notification - Error Subcode"
91+ field : " bgp.notification.subcode"
92+ description : " Notification error subcode (specific reason)"
93+
94+ - label : " Notification - Data"
95+ field : " bgp.notification.data"
96+ description : " Notification data (hex dump of offending data)"
97+
98+ - label : " Keepalive Interval"
99+ field : " bgp.keepalive"
100+ description : " Keepalive interval derived from negotiated hold time"
101+
102+ - label : " Route Refresh - AFI"
103+ field : " bgp.route_refresh.afi"
104+ description : " Address Family Identifier in Route Refresh"
105+
106+ - label : " Route Refresh - SAFI"
107+ field : " bgp.route_refresh.safi"
108+ description : " Subsequent AFI in Route Refresh"
109+
110+ checks :
111+ - name : " bgp_open_error"
112+ severity : critical
113+ message : " BGP OPEN error from {ip.src} to {ip.dst}: code {bgp.notification.code}, subcode {bgp.notification.subcode}"
114+ condition : " bgp.type == 1 and followed by bgp.type == 3 (Notification)"
115+
116+ - name : " bgp_hold_timer_expired"
117+ severity : critical
118+ message : " BGP hold timer expired for session {ip.src}<->{ip.dst}, session reset"
119+ condition : " bgp.notification.code == 4 (Hold Timer Expired)"
120+
121+ - name : " bgp_update_error"
122+ severity : critical
123+ message : " BGP UPDATE error from {ip.src}: code {bgp.notification.code}, subcode {bgp.notification.subcode}"
124+ condition : " bgp.type == 2 and followed by bgp.type == 3 with notification.code == 3"
125+
126+ - name : " bgp_as_path_loop"
127+ severity : critical
128+ message : " AS path loop detected: AS_PATH {bgp.as_path} from {ip.src}"
129+ condition : " bgp.type == 2 and AS path repeated across multiple UPDATEs (route withdrawn after previous advertisement)"
130+
131+ - name : " bgp_nexthop_unreachable"
132+ severity : major
133+ message : " BGP next-hop {bgp.next_hop} from {ip.src} may not be reachable via IGP"
134+ condition : " bgp.type == 2 and subsequent routing table state shows NHL not resolved in RIB"
135+
136+ - name : " bgp_route_flap"
137+ severity : minor
138+ message : " BGP route flapping: prefix {bgp.nlri_prefix} withdrawn and re-advertised repeatedly by {ip.src}"
139+ condition : " Same bgp.nlri_prefix appears in both withdrawn_prefix and nlri_prefix from same source in short interval"
140+
141+ - name : " bgp_notification_cease"
142+ severity : critical
143+ message : " BGP session terminated: Cease notification from {ip.src} (subcode {bgp.notification.subcode})"
144+ condition : " bgp.notification.code == 6"
145+
146+ - name : " bgp_admin_reset"
147+ severity : major
148+ message : " BGP session administratively reset from {ip.src} to {ip.dst} (Cease subcode 2)"
149+ condition : " bgp.notification.code == 6 and bgp.notification.subcode == 2"
150+
151+ - name : " bgp_max_prefix_exceeded"
152+ severity : major
153+ message : " BGP maximum prefix limit exceeded, session reset from {ip.src}"
154+ condition : " bgp.notification.code == 6 and bgp.notification.subcode == 3 (max prefix reached)"
155+
156+ - name : " bgp_capability_mismatch"
157+ severity : major
158+ message : " BGP capability mismatch between {ip.src} and {ip.dst}: MISSING capability {bgp.optional_parameter.type}"
159+ condition : " bgp.type == 1 and capabilities advertised differ between peers"
0 commit comments