1.\" $OpenBSD: bgpctl.8,v 1.111 2023/05/09 13:26:27 claudio Exp $ 2.\" 3.\" Copyright (c) 2003 Henning Brauer <henning@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: May 9 2023 $ 18.Dt BGPCTL 8 19.Os 20.Sh NAME 21.Nm bgpctl 22.Nd control the BGP routing daemon 23.Sh SYNOPSIS 24.Nm bgpctl 25.Op Fl jnV 26.Op Fl s Ar socket 27.Ar command 28.Op Ar argument ... 29.Sh DESCRIPTION 30The 31.Nm 32program controls the 33.Xr bgpd 8 34daemon. 35Commands may be abbreviated to the minimum unambiguous prefix; for example, 36.Cm s su 37for 38.Cm show summary . 39.Pp 40The options are as follows: 41.Bl -tag -width Ds 42.It Fl j 43Create output as JSON object. 44.It Fl n 45Show neighbors' IP addresses instead of their description. 46.It Fl s Ar socket 47Use 48.Ar socket 49to communicate with 50.Xr bgpd 8 51instead of the default 52.Pa /var/run/bgpd.sock.<rdomain> 53where 54.Ar <rdomain> 55is the routing domain 56.Nm 57is running in. 58To administer 59.Xr bgpd 8 60in a different routing domain, run 61.Nm 62in said routing domain. 63.It Fl V 64Show the version and exit. 65.El 66.Pp 67The commands are as follows: 68.Bl -tag -width xxxxxx 69.It Xo 70.Cm fib 71.Op Cm table Ar number 72.Cm couple 73.Xc 74Insert the learned routes into the specified Forwarding Information Base 75a.k.a. the kernel routing table. 76.It Xo 77.Cm fib 78.Op Cm table Ar number 79.Cm decouple 80.Xc 81Remove the learned routes from the specified Forwarding Information Base 82a.k.a. the kernel routing table. 83.It Cm flowspec add Ar family rule Op Cm set Ar argument ... 84Add the specified flowspec rule to the list of announced rules. 85Currently 86.Ar family 87can be either 88.Cm inet 89or 90.Cm inet6 . 91It is possible to set various path attributes with additional arguments. 92Adding a rule will replace an existing equal rule, including rules loaded 93from the configuration. 94See 95.Xr bgpd.conf 5 96for information on how to write a flowspec rule. 97.It Cm flowspec delete Ar family rule 98Remove the specified flowspec rule from the list of announced rules. 99.It Cm flowspec flush 100Remove all dynamically added (i.e. with 101.Nm Cm flowspec add ) 102flowspec rules from the list of announced rules. 103.It Cm flowspec show Ar family 104Show all announced flowspec rules. 105.Ar family , 106if given, limits the output to the given address family. 107The supported families are 108.Em inet 109and 110.Em inet6 . 111.It Cm log brief 112Disable verbose debug logging. 113.It Cm log verbose 114Enable verbose debug logging. 115.It Cm neighbor Ar peer Cm clear Op Ar reason 116Stop and restart the BGP session to the specified neighbor. 117If a 118.Ar reason 119is provided, the 120.Ar reason 121is sent as Administrative Shutdown Communication to the neighbor. 122.Ar peer 123may be the neighbor's address, description or the word 124.Cm group 125followed by a group description. 126.It Cm neighbor Ar peer Cm destroy 127Destroy a previously cloned peer. 128The peer must be down before calling this function. 129.Ar peer 130may be the neighbor's address, description or the word 131.Cm group 132followed by a group description. 133.It Cm neighbor Ar peer Cm down Op Ar reason 134Take the BGP session to the specified neighbor down. 135If a 136.Ar reason 137is provided, the 138.Ar reason 139is sent as Administrative Shutdown Communication to the neighbor. 140.Ar peer 141may be the neighbor's address, description or the word 142.Cm group 143followed by a group description. 144.It Cm neighbor Ar peer Cm refresh 145Request the neighbor to re-send all routes. 146Note that the neighbor is not obliged to re-send all routes, or any routes at 147all, even if it announced the route refresh capability. 148.Ar peer 149may be the neighbor's address, description or the word 150.Cm group 151followed by a group description. 152.It Cm neighbor Ar peer Cm up 153Bring the BGP session to the specified neighbor up. 154.Ar peer 155may be the neighbor's address, description or the word 156.Cm group 157followed by a group description. 158.It Cm network add Ar prefix Op Ar argument ... 159Add the specified prefix to the list of announced networks. 160It is possible to set various path attributes with additional arguments. 161Adding a prefix will replace an existing equal prefix, including 162prefixes loaded from the configuration. 163.It Xo 164.Cm network bulk add 165.Op Ar argument ... 166.Xc 167Bulk add specified prefixes to the list of announced networks. 168Prefixes should be sent via stdin. 169It is possible to set various path attributes with additional arguments. 170.It Cm network bulk delete 171Bulk remove the specified prefixes from the list of announced networks. 172Prefixes should be sent via stdin. 173.It Cm network delete Ar prefix 174Remove the specified prefix from the list of announced networks. 175.It Cm network flush 176Remove all dynamically added (i.e. with 177.Nm Cm network add ) 178prefixes from the list of announced networks. 179.It Cm network mrt file Ar file filter 180Import networks from an MRT table dump for debugging purposes. 181.Ar filter 182can be specified similarly to the 183.Ar show mrt 184command. 185Only networks matching the filter will be imported. 186.It Cm network show Ar family 187Show all announced networks. 188.Ar family , 189if given, limits the output to the given address family. 190The supported families are 191.Em inet 192and 193.Em inet6 . 194.It Cm reload Op reason 195Reload the configuration file. 196Changes to the following neighbor options in 197.Xr bgpd.conf 5 198only take effect when the session is reset: 199.Ic ipsec 200and 201.Ic tcp md5sig . 202.It Cm show fib Ar filter 203Show routes from 204.Xr bgpd 8 Ns 's 205view of the Forwarding Information Base. 206.Ar filter 207can be an IP address, in which case the route to this address is shown, 208or a flag: 209.Pp 210.Bl -tag -width tableXnumber -compact 211.It Cm bgp 212Show only routes originating from 213.Xr bgpd 8 214itself. 215.It Cm connected 216Show only connected routes. 217.It Cm inet 218Show only IPv4 routes. 219.It Cm inet6 220Show only IPv6 routes. 221.It Cm nexthop 222Show only routes required to reach a BGP nexthop. 223.It Cm static 224Show only static routes. 225.It Cm table Ar number 226Show the routing table with ID 227.Ar number 228instead of the default routing table with ID 0. 229.El 230.It Cm show interfaces 231Show the interface states. 232.It Cm show metrics 233Dump various BGP statistics in OpenMetrics format. 234.It Xo 235.Cm show mrt 236.Op Ar options 237.Ar filter 238.Xc 239Show routes from an MRT table dump file. 240.Ar filter 241can be an IP address, a CIDR prefix, an AS filter, a combination or nothing: 242.Pp 243.Bl -tag -width "address/len or-shorter" -compact 244.It Ar address 245Show best matching route for address. 246.It Ar address Ns Li / Ns Ar len 247Show RIB entry for this CIDR prefix. 248.It Xo 249.Ar address Ns Li / Ns Ar len 250.Cm all 251.Xc 252Show all entries in the specified range. 253.\".It Ar address/len Cm longer-prefixes 254.It Xo 255.Ar address Ns Li / Ns Ar len 256.Cm or-shorter 257.Xc 258Show all entries covering and including the specified prefix. 259.It Cm as Ar as 260Show all entries with 261.Ar as 262anywhere in the AS path. 263.It Cm empty-as 264Show all entries that are internal routes with no AS's in the AS path. 265.It Cm neighbor Ar ip 266Show only entries from the specified peer. 267.It Cm peer-as Ar as 268Show all entries with 269.Ar as 270as leftmost AS. 271.It Cm source-as Ar as 272Show all entries with 273.Ar as 274as rightmost AS. 275.It Cm transit-as Ar as 276Show all entries with 277.Ar as 278anywhere but rightmost. 279.El 280.Pp 281Additionally, the following 282.Ar options 283are defined: 284.Pp 285.Bl -tag -width "file name" -compact 286.It Cm detail 287Show more detailed output for matching routes. 288.It Ar family 289Limit the output to the given address family. 290.It Cm file Ar name 291Read the MRT dump from file 292.Ar name 293instead of using stdin. 294.It Cm peers 295Print the neighbor table of MRT TABLE_DUMP_V2 dumps. 296Using this on other table dumps will only show the neighbor of the first entry. 297.El 298.Pp 299Multiple options and filters can be used at the same time. 300.It Cm show neighbor Ar peer modifier 301Show detailed information about the neighbor identified by 302.Ar peer , 303according to the given 304.Ar modifier : 305.Pp 306.Bl -tag -width messages -compact 307.It Cm messages 308Show statistics about sent and received BGP messages. 309.It Cm terse 310Show statistics in an easily parseable terse format. 311The printed numbers are the sent and received open, sent and received 312notifications, sent and received updates, sent and received keepalives, and 313sent and received route refresh messages plus the current and maximum 314prefix count, the number of sent and received updates, sent and 315received withdraws, the neighbor's address (or subnet, for a template), 316AS number, and finally description. 317.It Cm timers 318Show the BGP timers. 319.El 320.Ar peer 321may be the neighbor's address, description or the word 322.Cm group 323followed by a group description. 324.It Cm show nexthop 325Show the list of BGP nexthops and the result of their validity check. 326.It Xo 327.Cm show rib 328.Op Ar options 329.Ar filter 330.Xc 331Show routes from the 332.Xr bgpd 8 333Routing Information Base. 334.Ar filter 335can be an IP address, a CIDR prefix, an AS filter or nothing: 336.Pp 337.Bl -tag -width "address/len or-shorter" -compact 338.It Ar address 339Show best matching route for address. 340.It Ar address Ns Li / Ns Ar len 341Show RIB entry for this CIDR prefix. 342.It Xo 343.Ar address Ns Li / Ns Ar len 344.Cm all 345.Xc 346Show all entries in the specified range. 347.\".It Ar address/len Cm longer-prefixes 348.\".It Ar address/len Cm or-longer 349.It Xo 350.Ar address Ns Li / Ns Ar len 351.Cm or-shorter 352.Xc 353Show all entries covering and including the specified prefix. 354.It Cm as Ar as 355Show all entries with 356.Ar as 357anywhere in the AS path. 358.It Cm avs Pq Ic valid | unknown | invalid 359Show all entries with matching ASAP Validation State (AVS). 360.It Cm community Ar community 361Show all entries with community 362.Ar community . 363.It Cm empty-as 364Show all entries that are internal routes with no AS's in the AS path. 365.It Cm large-community Ar large-community 366Show all entries with large-community 367.Ar large-community . 368.It Cm memory 369Show RIB memory statistics. 370.It Cm neighbor Ar peer 371Show only entries from the specified peer. 372.It Cm neighbor group Ar description 373Show only entries from the specified peer group. 374.It Cm ovs Pq Ic valid | not-found | invalid 375Show all entries with matching Origin Validation State (OVS). 376.It Cm path-id Ar pathid 377Show only entries which match the specified 378.Ar pathid . 379Must be used together with either 380.Cm neighbor 381or 382.Cm out . 383.It Cm peer-as Ar as 384Show all entries with 385.Ar as 386as leftmost AS. 387.It Cm source-as Ar as 388Show all entries with 389.Ar as 390as rightmost AS. 391.It Cm summary 392This is the same as the 393.Ic show summary 394command. 395.It Cm table Ar rib 396Show only entries from the specified RIB table. 397.It Cm transit-as Ar as 398Show all entries with 399.Ar as 400anywhere but rightmost. 401.El 402.Pp 403Additionally, the following 404.Ar options 405are defined: 406.Pp 407.Bl -tag -width "disqualified" -compact 408.It Cm best 409Alias for 410.Ic selected . 411.It Cm detail 412Show more detailed output for matching routes. 413.It Cm disqualified 414Show only routes which are not eligible. 415.It Cm error 416Show only prefixes which are marked invalid and were treated as withdrawn. 417.It Ar family 418Limit the output to the given address family. 419.It Cm in 420Show routes from the unfiltered Adj-RIB-In. 421The 422.Cm neighbor 423needs to be specified. 424.It Cm leaked 425Show only routes where a route leak was detected. 426.It Cm out 427Show the filtered routes sent to a neighbor. 428The 429.Cm neighbor 430needs to be specified. 431.It Cm selected 432Show only selected routes. 433.It Cm ssv 434Show each RIB entry as a single line, with fields separated by semicolons. 435Only works if 436.Cm detail 437is specified. 438.El 439.Pp 440Options are silently ignored when used together with 441.Ar summary 442or 443.Ar memory . 444Multiple options can be used at the same time and the 445.Ar neighbor 446filter can be combined with other filters. 447.It Cm show rtr 448Show a list of all 449.Em RTR 450sessions, including information about the session state. 451.It Cm show sets 452Show a list summarizing all 453.Em roa-set , 454.Em as-set , 455.Em prefix-set , 456and 457.Em origin-set 458tables. 459.It Cm show summary 460Show a list of all neighbors, including information about the session state 461and message counters: 462.Pp 463.Bl -tag -width xxxxxxxxxxxxxx -compact 464.It Neighbor 465Description of the neighbor. 466.It AS 467Autonomous system number. 468.It MsgRcvd 469Number of messages received from the neighbor. 470.It MsgSent 471Number of messages sent to the neighbor. 472.It OutQ 473Number of outgoing messages queued. 474.It Up/Down 475Number of days and hours that the session has been up. 476.It State/PrfRcvd 477State of the session / Number of routes received. 478The session is up if there is no information for the State column 479(Established is not displayed). 480.El 481.It Cm show summary terse 482Show a list of all neighbors, including information about the session state, 483in a terse format. 484.It Cm show tables 485Show a list of all currently loaded fib routing tables. 486.El 487.Sh FILES 488.Bl -tag -width "/var/run/bgpd.sockXXX" -compact 489.It Pa /etc/bgpd.conf 490default 491.Xr bgpd 8 492configuration file 493.It Pa /var/run/bgpd.sock 494default 495.Xr bgpd 8 496control socket 497.El 498.Sh SEE ALSO 499.Xr bgpd.conf 5 , 500.Xr bgpd 8 , 501.Xr bgplg 8 , 502.Xr bgplgsh 8 503.Sh HISTORY 504The 505.Nm 506program first appeared in 507.Ox 3.5 . 508