github.com/osrg/gobgp/v3@v3.30.0/docs/sources/cli-command-syntax.md (about) 1 # CLI command syntax 2 3 This page explains gobgp client command syntax. 4 5 ## basic command pattern 6 7 ```shell 8 gobgp <subcommand> <object> opts... 9 ``` 10 11 gobgp has the following subcommands. 12 13 - [global](#1-global-subcommand) 14 - [neighbor](#2-neighbor-subcommand) 15 - [policy](#3-policy-subcommand) 16 - [vrf](#4-vrf-subcommand) 17 - [monitor](#5-monitor-subcommand) 18 - [mrt](#6-mrt-subcommand) 19 20 ## 1. global subcommand 21 22 ### 1.1 Global Configuration 23 24 #### syntax 25 26 ```shell 27 # configure global setting and start acting as bgp daemon 28 % gobgp global as <VALUE> router-id <VALUE> [listen-port <VALUE>] [listen-addresses <VALUE>...] [mpls-label-min <VALUE>] [mpls-label-max <VALUE>] 29 # delete global setting and stop acting as bgp daemon (all peer sessions will be closed) 30 % gobgp global del all 31 # show global setting 32 % gobgp global 33 ``` 34 35 ### 1.2. Operations for Global-Rib - add/del/show - 36 37 #### - syntax 38 39 ```shell 40 # add Route 41 % gobgp global rib add <prefix> [-a <address family>] 42 # delete a specific Route 43 % gobgp global rib del <prefix> [-a <address family>] 44 # delete all locally generated routes 45 % gobgp global rib del all [-a <address family>] 46 # show all Route information 47 % gobgp global rib [-a <address family>] 48 # show a specific route information 49 % gobgp global rib [<prefix>|<host>] [rd <rd>] [longer-prefixes|shorter-prefixes] [-a <address family>] 50 # show table summary 51 % gobgp global rib summary [-a <address family>] 52 ``` 53 54 #### - example 55 56 If you want to add routes with the address of the ipv4 to global rib: 57 58 ```shell 59 % gobgp global rib add 10.33.0.0/16 -a ipv4 60 ``` 61 62 If you want to remove routes with the address of the ipv6 from global rib: 63 64 ```shell 65 % gobgp global rib del 2001:123:123:1::/64 -a ipv6 66 ``` 67 68 #### more examples 69 70 ```shell 71 % gobgp global rib add -a ipv4 10.0.0.0/24 origin igp 72 % gobgp global rib add -a ipv4 10.0.0.0/24 origin egp 73 % gobgp global rib add -a ipv4 10.0.0.0/24 aspath 10,20,100.100 74 % gobgp global rib add -a ipv4 10.0.0.0/24 aspath "10 20 {30,40} 50" 75 % gobgp global rib add -a ipv4 10.0.0.0/24 nexthop 20.20.20.20 76 % gobgp global rib add -a ipv4 10.0.0.0/24 med 10 77 % gobgp global rib add -a ipv4 10.0.0.0/24 local-pref 110 78 % gobgp global rib add -a ipv4 10.0.0.0/24 community 100:100 79 % gobgp global rib add -a ipv4 10.0.0.0/24 community 100:100,200:200 80 % gobgp global rib add -a ipv4 10.0.0.0/24 community no-export 81 % gobgp global rib add -a ipv4 10.0.0.0/24 community blackhole 82 % gobgp global rib add -a ipv4 10.0.0.0/24 aigp metric 200 83 % gobgp global rib add -a ipv4 10.0.0.0/24 large-community 100:100:100 84 % gobgp global rib add -a ipv4 10.0.0.0/24 large-community 100:100:100,200:200:200 85 % gobgp global rib add -a ipv4 10.0.0.0/24 identifier 10 86 % gobgp global rib add -a ipv4-mpls 10.0.0.0/24 100 87 % gobgp global rib add -a ipv4-mpls 10.0.0.0/24 100/200 88 % gobgp global rib add -a ipv4-mpls 10.0.0.0/24 100 nexthop 20.20.20.20 89 % gobgp global rib add -a ipv4-mpls 10.0.0.0/24 100 med 10 90 % gobgp global rib add -a vpnv4 10.0.0.0/24 label 10 rd 100:100 91 % gobgp global rib add -a vpnv4 10.0.0.0/24 label 10 rd 100.100:100 92 % gobgp global rib add -a vpnv4 10.0.0.0/24 label 10 rd 10.10.10.10:100 93 % gobgp global rib add -a vpnv4 10.0.0.0/24 label 10 rd 100:100 rt 100:200 94 % gobgp global rib add -a opaque key hello value world 95 ``` 96 97 #### - option 98 99 The following options can be specified in the global subcommand: 100 101 | short |long | description | default | 102 |--------|---------------|--------------------------------------------|---------| 103 |a |address-family |specify any one from among `ipv4`, `ipv6`, `vpnv4`, `vpnv6`, `ipv4-labeled`, `ipv6-labeled`, `evpn`, `encap`, `rtc`, `ipv4-flowspec`, `ipv6-flowspec`, `l2vpn-flowspec`, `ipv4-mup`, `ipv6-mup`, `opaque` | `ipv4` | 104 105 Also, refer to the following for the detail syntax of each address family. 106 107 - `evpn` address family: [CLI Syntax for EVPN](evpn.md#cli-syntax) 108 - `*-flowspec` address family: [CLI Syntax for Flow Specification](flowspec.md#cli-syntax) 109 - `*-mup` address family: [CLI Syntax for SRv6 MUP](srv6_mup.md#cli-syntax) 110 111 ## 2. neighbor subcommand 112 113 ### 2.1. Show Neighbor Status 114 115 #### - syntax 116 117 ```shell 118 # show neighbor's status as list 119 % gobgp neighbor 120 # show status of a specific neighbor 121 % gobgp neighbor <neighbor address> 122 ``` 123 124 ### 2.2. Operations for neighbor - shutdown/reset/softreset/enable/disable - 125 126 #### - syntax 127 128 ```shell 129 # add neighbor 130 % gobgp neighbor add { <neighbor address> | interface <ifname> } as <as number> [ local-as <as number> | vrf <vrf-name> | route-reflector-client [<cluster-id>] | route-server-client | allow-own-as <num> | remove-private-as (all|replace) | replace-peer-as | ebgp-multihop-ttl <ttl>] 131 # delete neighbor 132 % gobgp neighbor del { <neighbor address> | interface <ifname> } 133 % gobgp neighbor <neighbor address> softreset [-a <address family>] 134 % gobgp neighbor <neighbor address> softresetin [-a <address family>] 135 % gobgp neighbor <neighbor address> softresetout [-a <address family>] 136 % gobgp neighbor <neighbor address> enable 137 % gobgp neighbor <neighbor address> disable 138 % gobgp neighbor <neighbor address> reset 139 ``` 140 141 #### - option 142 143 The following options can be specified in the neighbor subcommand: 144 145 | short |long | description | default | 146 |--------|---------------|--------------------------------------------|---------| 147 |a |address-family |specify any one from among `ipv4`, `ipv6`, `vpnv4`, `vpnv6`, `ipv4-labeled`, `ipv6-labeld`, `evpn`, `encap`, `rtc`, `ipv4-flowspec`, `ipv6-flowspec`, `l2vpn-flowspec`, `ipv4-mup`, `ipv6-mup`, `opaque` | `ipv4` | 148 149 ### 2.3. Show Rib - local-rib/adj-rib-in/adj-rib-out - 150 151 #### - syntax 152 153 ```shell 154 # show all routes in [local|adj-in|adj-out] table 155 % gobgp neighbor <neighbor address> [local|adj-in|adj-out] [-a <address family>] 156 # show a specific route in [local|adj-in|adj-out] table 157 % gobgp neighbor <neighbor address> [local|adj-in|adj-out] [<prefix>|<host>] [rd <rd>] [longer-prefixes|shorter-prefixes] [-a <address family>] 158 # show table summary 159 % gobgp neighbor <neighbor address> [local|adj-in|adj-out] summary [-a <address family>] 160 # show RPKI detailed information in adj-in table 161 % gobgp neighbor <neighbor address> adj-in <prefix> validation 162 ``` 163 164 #### - example 165 166 If you want to show the local rib of ipv4 that neighbor(10.0.0.1) has: 167 168 ```shell 169 % gobgp neighbor 10.0.0.1 local -a ipv4 170 ``` 171 172 #### - option 173 174 The following options can be specified in the neighbor subcommand: 175 176 | short |long | description | default | 177 |--------|---------------|--------------------------------------------|---------| 178 |a |address-family |specify any one from among `ipv4`, `ipv6`, `vpnv4`, `vpnv6`, `ipv4-labeled`, `ipv6-labeld`, `evpn`, `encap`, `rtc`, `ipv4-flowspec`, `ipv6-flowspec`, `l2vpn-flowspec`, `ipv4-mup`, `ipv6-mup`,, `opaque` | `ipv4` | 179 180 ### 2.4. Operations for Policy - add/del/show - 181 182 #### Syntax 183 184 ```shell 185 # show neighbor policy assignment 186 % gobgp neighbor <neighbor address> policy { in | import | export } 187 # add policies to specific neighbor policy 188 % gobgp neighbor <neighbor address> policy { in | import | export } add <policy name>... [default { accept | reject }] 189 # set policies to specific neighbor policy 190 % gobgp neighbor <neighbor address> policy { in | import | export } set <policy name>... [default { accept | reject }] 191 # remove attached policies from specific neighbor policy 192 % gobgp neighbor <neighbor address> policy { in | import | export } del <policy name>... 193 # remove all policies from specific neighbor policy 194 % gobgp neighbor <neighbor address> policy { in | import | export } del 195 ``` 196 197 #### Example 198 199 If you want to add the import policy to neighbor(10.0.0.1): 200 201 ```shell 202 % gobgp neighbor 10.0.0.1 policy import add policy1 policy2 default accept 203 ``` 204 205 You can specify multiple policy to neighbor separated by commas. 206 207 `default <policy action>` means the operation `{accept | reject}` in the case where the route does not match the conditions of the policy. 208 209 ## 3. policy subcommand 210 211 ### 3.1. Operations for PrefixSet - add/del/show - 212 213 #### Syntax 214 215 ```shell 216 # add PrefixSet 217 % gobgp policy prefix add <prefix set name> <prefix> [<mask length range>] 218 # delete a PrefixSet 219 % gobgp policy prefix del <prefix set name> 220 # delete a prefix from specific PrefixSet 221 % gobgp policy prefix del <prefix set name> <prefix> [<mask length range>] 222 # show all PrefixSet information 223 % gobgp policy prefix 224 # show a specific PrefixSet 225 % gobgp policy prefix <prefix set name> 226 ``` 227 228 #### Example 229 230 If you want to add the PrefixSet: 231 232 ```shell 233 % gobgp policy prefix add ps1 10.33.0.0/16 16..24 234 ``` 235 236 A PrefixSet it is possible to have multiple prefix, if you want to remove the PrefixSet to specify only PrefixSet name. 237 238 ```shell 239 % gobgp policy prefix del ps1 240 ``` 241 242 If you want to remove one element(prefix) of PrefixSet, to specify a prefix in addition to the PrefixSet name. 243 244 ```shell 245 % gobgp policy prefix del ps1 10.33.0.0/16 246 ``` 247 248 ### 3.2. Operations for NeighborSet - add/del/show - 249 250 #### Syntax 251 252 ```shell 253 # add NeighborSet 254 % gobgp policy neighbor add <neighbor set name> <neighbor address/prefix> 255 # delete a NeighborSet 256 % gobgp policy neighbor del <neighbor set name> 257 # delete a neighbor from a NeighborSet 258 % gobgp policy neighbor del <neighbor set name> <address> 259 # show all NeighborSet information 260 % gobgp policy neighbor 261 # show a specific NeighborSet information 262 % gobgp policy neighbor <neighbor set name> 263 ``` 264 265 #### Example 266 267 If you want to add the NeighborSet: 268 269 ```shell 270 % gobgp policy neighbor add ns1 10.0.0.1 271 ``` 272 273 You can also specify a neighbor address range with the prefix representation: 274 275 ```shell 276 % gobgp policy neighbor add ns 10.0.0.0/24 277 ``` 278 279 A NeighborSet is possible to have multiple address, if you want to remove the NeighborSet to specify only NeighborSet name. 280 281 ```shell 282 % gobgp policy neighbor del ns1 283 ``` 284 285 If you want to remove one element(address) of NeighborSet, to specify a address in addition to the NeighborSet name. 286 287 ```shell 288 % gobgp policy prefix del ns1 10.0.0.1 289 ``` 290 291 ### 3.3. Operations for AsPathSet - add/del/show - 292 293 #### Syntax 294 295 ```shell 296 # add AsPathSet 297 % gobgp policy as-path add <aspath set name> <as path> 298 # delete a specific AsPathSet 299 % gobgp policy as-path del <aspath set name> 300 # delete an as-path from a AsPathSet 301 % gobgp policy as-path del <aspath set name> <as path> 302 # show all AsPathSet information 303 % gobgp policy as-path 304 # show a specific AsPathSet information 305 % gobgp policy as-path <aspath set name> 306 ``` 307 308 #### Example 309 310 If you want to add the AsPathSet: 311 312 ```shell 313 % gobgp policy as-path add ass1 ^65100 314 ``` 315 316 You can specify the position using regexp-like expression as follows: 317 318 - From: `^65100` means the route is passed from AS 65100 directly. 319 - Any: `_65100_` means the route comes through AS 65100. 320 - Origin: `_65100$` means the route is originated by AS 65100. 321 - Only: `^65100$` means the route is originated by AS 65100 and comes from it directly. 322 323 Further you can specify the consecutive aspath and use regexp in each element as follows: 324 325 - `^65100_65001` 326 - `65100_[0-9]+_.*$` 327 - `^6[0-9]_5.*_65.?00$` 328 329 An AsPathSet it is possible to have multiple as path, if you want to remove the AsPathSet to specify only AsPathSet name. 330 331 ```shell 332 % gobgp policy as-path del ass1 333 ``` 334 335 If you want to remove one element(as path) of AsPathSet, to specify an as path in addition to the AsPathSet name. 336 337 ```shell 338 % gobgp policy as-path del ass1 ^65100 339 ``` 340 341 ### 3.4. Operations for CommunitySet - add/del/show - 342 343 #### Syntax 344 345 ```shell 346 # add CommunitySet 347 % gobgp policy community add <community set name> <community> 348 # delete a specific CommunitySet 349 % gobgp policy community del <community set name> 350 # delete a community from a CommunitySet 351 % gobgp policy community del <community set name> <community> 352 # show all CommunitySet information 353 % gobgp policy community 354 # show a specific CommunitySet information 355 % gobgp policy community <community set name> 356 ``` 357 358 #### Example 359 360 If you want to add the CommunitySet: 361 362 ```shell 363 % gobgp policy community add cs1 65100:10 364 ``` 365 366 You can specify the position using regexp-like expression as follows: 367 368 - `6[0-9]+:[0-9]+` 369 - `^[0-9]*:300$` 370 371 A CommunitySet it is possible to have multiple community, if you want to remove the CommunitySet to specify only CommunitySet name. 372 373 ```shell 374 % gobgp policy neighbor del cs1 375 ``` 376 377 If you want to remove one element(community) of CommunitySet, to specify a address in addition to the CommunitySet name. 378 379 ```shell 380 % gobgp policy prefix del cs1 65100:10 381 ``` 382 383 ### 3.5. Operations for ExtCommunitySet - add/del/show - 384 385 #### Syntax 386 387 ```shell 388 # add ExtCommunitySet 389 % gobgp policy ext-community add <extended community set name> <extended community> 390 # delete a specific ExtCommunitySet 391 % gobgp policy ext-community del <extended community set name> 392 # delete a ext-community from a ExtCommunitySet 393 % gobgp policy ext-community del <extended community set name> <extended community> 394 # show all ExtCommunitySet information 395 % gobgp policy ext-community 396 # show a specific ExtCommunitySet information 397 % gobgp policy ext-community <extended community set name> 398 ``` 399 400 #### Example 401 402 If you want to add the ExtCommunitySet: 403 404 ```shell 405 % gobgp policy ext-community add ecs1 RT:65100:10 406 ``` 407 408 Extended community set as `<SubType>:<Global Admin>:<LocalAdmin>`. 409 410 If you read the [RFC4360](https://tools.ietf.org/html/rfc4360) and [RFC7153](https://tools.ietf.org/html/rfc7153), you can know more about Extended community. 411 412 You can specify the position using regexp-like expression as follows: 413 414 - `RT:[0-9]+:[0-9]+` 415 - `SoO:10.0.10.10:[0-9]+` 416 417 However, regular expressions for subtype can not be used, to use for the global admin and local admin. 418 419 A ExtCommunitySet it is possible to have multiple extended community, if you want to remove the ExtCommunitySet to specify only ExtCommunitySet name. 420 421 ```shell 422 % gobgp policy neighbor del ecs1 423 ``` 424 425 If you want to remove one element(extended community) of ExtCommunitySet, to specify a address in addition to the ExtCommunitySet name. 426 427 ```shell 428 % gobgp policy prefix del ecs1 RT:65100:10 429 ``` 430 431 ### 3.6. Operations for LargeCommunitySet - add/del/show - 432 433 #### Syntax 434 435 ```shell 436 # add LargeCommunitySet 437 % gobgp policy large-community add <set name> <large community>... 438 # delete a specific LargeCommunitySet 439 % gobgp policy large-community del <set name> 440 # delete a large-community from a LargeCommunitySet 441 % gobgp policy large-community del <set name> <large community> 442 # show all LargeCommunitySet information 443 % gobgp policy large-community 444 # show a specific LargeCommunitySet information 445 % gobgp policy large-community <set name> 446 ``` 447 448 #### Example 449 450 ```shell 451 % gobgp policy large-community add l0 100:100:100 452 % gobgp policy large-community add l0 ^100: 453 % gobgp policy large-community add l0 :100$ 454 % gobgp policy large-community del l0 100:100:100 455 % gobgp policy large-community add l0 200:100:100 456 % gobgp policy large-community 457 % gobgp policy large-community set l0 100:100:100 200:200:200 300:300:300 458 ``` 459 460 ### 3.7 Statement Operation - add/del/show - 461 462 #### Syntax 463 464 ```shell 465 # mod statement 466 % gobgp policy statement { add | del } <statement name> 467 # mod a condition to a statement 468 % gobgp policy statement <statement name> { add | del | set } condition { { prefix | neighbor | as-path | community | ext-community | large-community } <set name> [{ any | all | invert }] | as-path-length <len> { eq | ge | le } | rpki { valid | invalid | not-found } | next-hop-in-list <next-hop>[, <next-hop2>, ...] | afi-safi-in { <afi-safi>... } } 469 # mod an action to a statement 470 % gobgp policy statement <statement name> { add | del | set } action { reject | accept | { community | ext-community | large-community } { add | remove | replace } <value>... | med { add | sub | set } <value> | local-pref <value> | as-prepend { <asn> | last-as } <repeat-value> | next-hop { <next-hop> | self | unchanged } } 471 # show all statements 472 % gobgp policy statement 473 # show a specific statement 474 % gobgp policy statement <statement name> 475 ``` 476 477 ### 3.8 Policy Operation - add/del/show - 478 479 #### Syntax 480 481 ```shell 482 # mod policy 483 % gobgp policy { add | del | set } <policy name> [<statement name>...] 484 # show all policies 485 % gobgp policy 486 # show a specific policy 487 % gobgp policy <policy name> 488 ``` 489 490 ## 4. vrf subcommand 491 492 ### 4.1 Add/Delete/Show VRF 493 494 #### Syntax 495 496 ```shell 497 # add vrf 498 % gobgp vrf add <vrf name> rd <rd> rt {import|export|both} <rt>... 499 # del vrf 500 % gobgp vrf del <vrf name> 501 # show vrf 502 % gobgp vrf 503 ``` 504 505 #### Example 506 507 ```shell 508 % gobgp vrf add vrf1 rd 10.100:100 rt both 10.100:100 import 10.100:101 export 10.100:102 509 % gobgp vrf 510 Name RD Import RT Export RT 511 vrf1 10.100:100 10.100:100, 10.100:101 10.100:100, 10.100:102 512 % gobgp vrf del vrf1 513 % gobgp vrf 514 Name RD Import RT Export RT 515 ``` 516 517 ### 4.2 Add/Delete/Show VRF routes 518 519 #### Syntax 520 521 ```shell 522 # add routes to vrf 523 % gobgp vrf <vrf name> rib add <prefix> [-a <address family>] 524 # del routes from vrf 525 % gobgp vrf <vrf name> rib del <prefix> [-a <address family>] 526 # show routes in vrf 527 % gobgp vrf <vrf name> rib [-a <address family>] 528 ``` 529 530 #### Example 531 532 ```shell 533 % gobgp vrf vrf1 rib add 10.0.0.0/24 534 % gobgp vrf vrf1 rib add 2001::/64 -a ipv6 535 % gobgp vrf vrf1 rib 536 Network Next Hop AS_PATH Age Attrs 537 10.100:100:10.0.0.0/24 0.0.0.0 00:00:40 [{Origin: i} {Extcomms: [10.100:100], [10.100:101]}] 538 % gobgp vrf vrf1 rib -a ipv6 539 Network Next Hop AS_PATH Age Attrs 540 10.100:100:2001::/64 :: 00:00:00 [{Origin: i} {Extcomms: [10.100:100], [10.100:101]}] 541 % gobgp vrf vrf1 rib del 10.0.0.0/24 542 % gobgp vrf vrf1 rib del 2001::/64 543 ``` 544 545 ## 5. monitor subcommand 546 547 ### 5.1 monitor global rib 548 549 #### Syntax 550 551 ```shell 552 # monitor global rib 553 % gobgp monitor global rib [-a <address family>] [--current] 554 ``` 555 556 #### Example 557 558 ```shell 559 [TERM1] 560 % gobgp monitor global rib 561 [ROUTE] 10.0.0.0/24 via 0.0.0.0 aspath [] attrs [{Origin: i}] 562 563 [TERM2] 564 # monitor command blocks. add routes from another terminal 565 % gobgp global rib add 10.0.0.0/24 566 ``` 567 568 ### 5.2 monitor neighbor status 569 570 #### Syntax 571 572 ```shell 573 # monitor neighbor status 574 % gobgp monitor neighbor [--current] 575 # monitor specific neighbor status 576 % gobgp monitor neighbor <neighbor address> [--current] 577 ``` 578 579 #### Example 580 581 ```shell 582 [TERM1] 583 % gobgp monitor neighbor 584 [NEIGH] 192.168.10.2 fsm: BGP_FSM_IDLE admin: down 585 [NEIGH] 192.168.10.2 fsm: BGP_FSM_ACTIVE admin: up 586 [NEIGH] 192.168.10.2 fsm: BGP_FSM_OPENSENT admin: up 587 [NEIGH] 192.168.10.2 fsm: BGP_FSM_OPENCONFIRM admin: up 588 [NEIGH] 192.168.10.2 fsm: BGP_FSM_ESTABLISHED admin: up 589 590 [TERM2] 591 % gobgp neighbor 192.168.10.2 disable 592 % gobgp neighbor 192.168.10.2 enable 593 ``` 594 595 ### 5.3 monitor Adj-RIB-In 596 597 #### Syntax 598 599 ```shell 600 # monitor Adj-RIB-In 601 % gobgp monitor adj-in [-a <address family>] [--current] 602 # monitor Adj-RIB-In for specific neighbor 603 % gobgp monitor adj-in <neighbor address> [-a <address family>] [--current] 604 ``` 605 606 #### Example 607 608 ```shell 609 [GoBGP1] 610 % gobgp monitor adj-in 611 [ROUTE] 0:10.2.1.0/24 via 10.0.0.2 aspath [65002] attrs [{Origin: ?}] 612 [DELROUTE] 0:10.2.1.0/24 via <nil> aspath [] attrs [] 613 614 [GoBGP2] 615 % gobgp global rib -a ipv4 add 10.2.1.0/24 616 % gobgp global rib -a ipv4 del 10.2.1.0/24 617 ``` 618 619 ## 6. mrt subcommand 620 621 ### 6.1 inject mrt records 622 623 #### Syntax 624 625 ```shell 626 % gobgp mrt inject global <filename> [<count>] 627 ``` 628 629 #### Example 630 631 see [MRT](mrt.md).