1.\" $OpenBSD: bgpctl.8,v 1.97 2021/05/06 09:23:42 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 6 2021 $ 18.Dt BGPCTL 8 19.Os 20.Sh NAME 21.Nm bgpctl 22.Nd control the Border Gateway Protocol daemon 23.Sh SYNOPSIS 24.Nm bgpctl 25.Op Fl jn 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.El 64.Pp 65The commands are as follows: 66.Bl -tag -width xxxxxx 67.It Xo 68.Cm fib 69.Op Cm table Ar number 70.Cm couple 71.Xc 72Insert the learned routes into the specified Forwarding Information Base 73a.k.a. the kernel routing table. 74.It Xo 75.Cm fib 76.Op Cm table Ar number 77.Cm decouple 78.Xc 79Remove the learned routes from the specified Forwarding Information Base 80a.k.a. the kernel routing table. 81.It Cm log brief 82Disable verbose debug logging. 83.It Cm log verbose 84Enable verbose debug logging. 85.It Cm neighbor Ar peer Cm clear Op Ar reason 86Stop and restart the BGP session to the specified neighbor. 87If a 88.Ar reason 89is provided, the 90.Ar reason 91is sent as Administrative Shutdown Communication to the neighbor. 92.Ar peer 93may be the neighbor's address, description or the word 94.Cm group 95followed by a group description. 96.It Cm neighbor Ar peer Cm destroy 97Destroy a previously cloned peer. 98The peer must be down before calling this function. 99.Ar peer 100may be the neighbor's address, description or the word 101.Cm group 102followed by a group description. 103.It Cm neighbor Ar peer Cm down Op Ar reason 104Take the BGP session to the specified neighbor down. 105If a 106.Ar reason 107is provided, the 108.Ar reason 109is sent as Administrative Shutdown Communication to the neighbor. 110.Ar peer 111may be the neighbor's address, description or the word 112.Cm group 113followed by a group description. 114.It Cm neighbor Ar peer Cm refresh 115Request the neighbor to re-send all routes. 116Note that the neighbor is not obliged to re-send all routes, or any routes at 117all, even if it announced the route refresh capability. 118.Ar peer 119may be the neighbor's address, description or the word 120.Cm group 121followed by a group description. 122.It Cm neighbor Ar peer Cm up 123Bring the BGP session to the specified neighbor up. 124.Ar peer 125may be the neighbor's address, description or the word 126.Cm group 127followed by a group description. 128.It Cm network add Ar prefix Op Ar arguments 129Add the specified prefix to the list of announced networks. 130It is possible to set various path attributes with additional 131.Ar arguments . 132Adding a prefix will replace an existing equal prefix, including 133prefixes loaded from the configuration. 134.It Xo 135.Cm network bulk 136.Op Ar arguments 137.Op Cm add 138.Xc 139Bulk add specified prefixes to the list of announced networks. 140Prefixes should be sent via stdin. 141It is possible to set various path attributes with additional 142.Ar arguments . 143If neither 144.Cm add 145or 146.Cm delete 147is given, 148.Cm add 149is the default. 150.It Cm network bulk delete 151Bulk remove the specified prefixes from the list of announced networks. 152Prefixes should be sent via stdin. 153.It Cm network delete Ar prefix 154Remove the specified prefix from the list of announced networks. 155.It Cm network flush 156Remove all dynamically (i.e. with 157.Nm Cm network add ) 158added prefixes from the list of announced networks. 159.It Cm network mrt file Ar file filter 160Import networks from an MRT table dump for debugging purposes. 161.Ar filter 162can be specified similarly to the 163.Ar show mrt 164command. 165Only networks matching the filter will be imported. 166.It Cm network show Ar family 167Show all announced networks. 168.Ar family , 169if given, limits the output to the given address family. 170The supported families are 171.Em inet 172and 173.Em inet6 . 174.It Cm reload Op reason 175Reload the configuration file. 176Changes to the following neighbor options in 177.Xr bgpd.conf 5 178only take effect when the session is reset: 179.Ic ipsec 180and 181.Ic tcp md5sig . 182.It Cm show fib Ar filter 183Show routes from 184.Xr bgpd 8 Ns 's 185view of the Forwarding Information Base. 186.Ar filter 187can be an IP address, in which case the route to this address is shown, 188or a flag: 189.Pp 190.Bl -tag -width tableXnumber -compact 191.It Cm connected 192Show only connected routes. 193.It Cm static 194Show only static routes. 195.It Cm bgp 196Show only routes originating from 197.Xr bgpd 8 198itself. 199.It Cm nexthop 200Show only routes required to reach a BGP nexthop. 201.It Cm inet 202Show only IPv4 routes. 203.It Cm inet6 204Show only IPv6 routes. 205.It Cm table Ar number 206Show the routing table with ID 207.Ar number 208instead of the default routing table with ID 0. 209.El 210.It Cm show interfaces 211Show the interface states. 212.It Xo 213.Cm show mrt 214.Op Ar options 215.Ar filter 216.Xc 217Show routes from an MRT table dump file. 218.Ar filter 219can be an IP address, a CIDR prefix, an AS filter, a combination or nothing: 220.Pp 221.Bl -tag -width "address/len or-shorter" -compact 222.It Ar address 223Show best matching route for address. 224.It Ar address Ns Li / Ns Ar len 225Show RIB entry for this CIDR prefix. 226.It Xo 227.Ar address Ns Li / Ns Ar len 228.Cm all 229.Xc 230Show all entries in the specified range. 231.\".It Ar address/len Cm longer-prefixes 232.It Xo 233.Ar address Ns Li / Ns Ar len 234.Cm or-shorter 235.Xc 236Show all entries covering and including the specified prefix. 237.It Cm as Ar as 238Show all entries with 239.Ar as 240anywhere in the AS path. 241.It Cm empty-as 242Show all entries that are internal routes with no AS's in the AS path. 243.It Cm neighbor Ar ip 244Show only entries from the specified peer. 245.It Cm peer-as Ar as 246Show all entries with 247.Ar as 248as leftmost AS. 249.It Cm source-as Ar as 250Show all entries with 251.Ar as 252as rightmost AS. 253.It Cm transit-as Ar as 254Show all entries with 255.Ar as 256anywhere but rightmost. 257.El 258.Pp 259Additionally, the following 260.Ar options 261are defined: 262.Pp 263.Bl -tag -width "file name" -compact 264.It Cm detail 265Show more detailed output for matching routes. 266.It Ar family 267Limit the output to the given address family. 268.It Cm file Ar name 269Read the MRT dump from file 270.It Cm peers 271Print the neighbor table of MRT TABLE_DUMP_V2 dumps. 272Using this on other table dumps will only show the neighbor of the first entry. 273.Ar name 274instead of using stdin. 275.El 276.Pp 277Multiple options and filters can be used at the same time. 278.It Cm show neighbor Ar peer modifier 279Show detailed information about the neighbor identified by 280.Ar peer , 281according to the given 282.Ar modifier : 283.Pp 284.Bl -tag -width messages -compact 285.It Cm messages 286Show statistics about sent and received BGP messages. 287.It Cm terse 288Show statistics in an easily parseable terse format. 289The printed numbers are the sent and received open, sent and received 290notifications, sent and received updates, sent and received keepalives, and 291sent and received route refresh messages plus the current and maximum 292prefix count, the number of sent and received updates, sent and 293received withdraws, the neighbor's address (or subnet, for a template), 294AS number, and finally description. 295.It Cm timers 296Show the BGP timers. 297.El 298.Ar peer 299may be the neighbor's address, description or the word 300.Cm group 301followed by a group description. 302.It Cm show nexthop 303Show the list of BGP nexthops and the result of their validity check. 304.It Xo 305.Cm show rib 306.Op Ar options 307.Ar filter 308.Xc 309Show routes from the 310.Xr bgpd 8 311Routing Information Base. 312.Ar filter 313can be an IP address, a CIDR prefix, an AS filter or nothing: 314.Pp 315.Bl -tag -width "address/len or-shorter" -compact 316.It Ar address 317Show best matching route for address. 318.It Ar address Ns Li / Ns Ar len 319Show RIB entry for this CIDR prefix. 320.It Xo 321.Ar address Ns Li / Ns Ar len 322.Cm all 323.Xc 324Show all entries in the specified range. 325.\".It Ar address/len Cm longer-prefixes 326.It Xo 327.Ar address Ns Li / Ns Ar len 328.Cm or-shorter 329.Xc 330Show all entries covering and including the specified prefix. 331.It Cm as Ar as 332Show all entries with 333.Ar as 334anywhere in the AS path. 335.It Cm community Ar community 336Show all entries with community 337.Ar community . 338.It Cm large-community Ar large-community 339Show all entries with large-community 340.Ar large-community . 341.It Cm empty-as 342Show all entries that are internal routes with no AS's in the AS path. 343.It Cm memory 344Show RIB memory statistics. 345.It Cm neighbor Ar peer 346Show only entries from the specified peer. 347.It Cm neighbor group Ar description 348Show only entries from the specified peer group. 349.It Cm peer-as Ar as 350Show all entries with 351.Ar as 352as leftmost AS. 353.It Cm source-as Ar as 354Show all entries with 355.Ar as 356as rightmost AS. 357.It Cm summary 358This is the same as the 359.Ic show summary 360command. 361.It Cm table Ar rib 362Show only entries from the specified RIB table. 363.It Cm transit-as Ar as 364Show all entries with 365.Ar as 366anywhere but rightmost. 367.It Cm ovs Pq Ic valid | not-found | invalid 368Show all entries with matching Origin Validation State (OVS). 369.El 370.Pp 371Additionally, the following 372.Ar options 373are defined: 374.Pp 375.Bl -tag -width "selected" -compact 376.It Cm best 377Alias for 378.Ic selected . 379.It Cm error 380Show only prefixes which are marked invalid and were treated as withdrawn. 381.It Cm selected 382Show only selected routes. 383.It Cm ssv 384Show each RIB entry as a single line, with fields separated by semicolons. 385Only works if 386.Cm detail 387is specified. 388.It Cm detail 389Show more detailed output for matching routes. 390.It Ar family 391Limit the output to the given address family. 392.It Cm in 393Show routes from the unfiltered Adj-RIB-In. 394The 395.Cm neighbor 396needs to be specified. 397.It Cm out 398Show the filtered routes sent to a neighbor. 399The 400.Cm neighbor 401needs to be specified. 402.El 403.Pp 404Options are silently ignored when used together with 405.Ar summary 406or 407.Ar memory . 408Multiple options can be used at the same time and the 409.Ar neighbor 410filter can be combined with other filters. 411.It Cm show rtr 412Show a list of all 413.Em RTR 414sessions, including information about the session state. 415.It Cm show sets 416Show a list summarizing all 417.Em roa-set , 418.Em as-set , 419.Em prefix-set , 420and 421.Em origin-set 422tables. 423.It Cm show summary 424Show a list of all neighbors, including information about the session state 425and message counters: 426.Pp 427.Bl -tag -width xxxxxxxxxxxxxx -compact 428.It Neighbor 429Description of the neighbor. 430.It AS 431Autonomous system number. 432.It MsgRcvd 433Number of messages received from the neighbor. 434.It MsgSent 435Number of messages sent to the neighbor. 436.It OutQ 437Number of outgoing messages queued. 438.It Up/Down 439Number of days and hours that the session has been up. 440.It State/PrfRcvd 441State of the session / Number of routes received. 442The session is up if there is no information for the State column 443(Established is not displayed). 444.El 445.It Cm show summary terse 446Show a list of all neighbors, including information about the session state, 447in a terse format. 448.It Cm show tables 449Show a list of all currently loaded fib routing tables. 450.El 451.Sh FILES 452.Bl -tag -width "/var/run/bgpd.sockXXX" -compact 453.It Pa /etc/bgpd.conf 454default 455.Xr bgpd 8 456configuration file 457.It Pa /var/run/bgpd.sock 458default 459.Xr bgpd 8 460control socket 461.El 462.Sh SEE ALSO 463.Xr bgpd.conf 5 , 464.Xr bgpd 8 , 465.Xr bgplg 8 , 466.Xr bgplgsh 8 467.Sh STANDARDS 468.Rs 469.%A C. Alaettinoglu 470.%A C. Villamizar 471.%A E. Gerich 472.%A D. Kessens 473.%A D. Meyer 474.%A T. Bates 475.%A D. Karrenberg 476.%A M. Terpstra 477.%D June 1999 478.%R RFC 2622 479.%T Routing Policy Specification Language (RPSL) 480.Re 481.Sh HISTORY 482The 483.Nm 484program first appeared in 485.Ox 3.5 . 486