github.com/osrg/gobgp@v2.0.0+incompatible/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>] [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`, `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 110 ## 2. neighbor subcommand 111 112 ### 2.1. Show Neighbor Status 113 114 #### - syntax 115 116 ```shell 117 # show neighbor's status as list 118 % gobgp neighbor 119 # show status of a specific neighbor 120 % gobgp neighbor <neighbor address> 121 ``` 122 123 ### 2.2. Operations for neighbor - shutdown/reset/softreset/enable/disable - 124 125 #### - syntax 126 127 ```shell 128 # add neighbor 129 % gobgp neighbor add { <neighbor address> | interface <ifname> } 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>] 130 # delete neighbor 131 % gobgp neighbor delete { <neighbor address> | interface <ifname> } 132 % gobgp neighbor <neighbor address> softreset [-a <address family>] 133 % gobgp neighbor <neighbor address> softresetin [-a <address family>] 134 % gobgp neighbor <neighbor address> softresetout [-a <address family>] 135 % gobgp neighbor <neighbor address> enable 136 % gobgp neighbor <neighbor address> disable 137 % gobgp neighbor <neighbor address> reset 138 ``` 139 140 #### - option 141 142 The following options can be specified in the neighbor subcommand: 143 144 | short |long | description | default | 145 |--------|---------------|--------------------------------------------|---------| 146 |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`, `opaque` | `ipv4` | 147 148 ### 2.3. Show Rib - local-rib/adj-rib-in/adj-rib-out - 149 150 #### - syntax 151 152 ```shell 153 # show all routes in [local|adj-in|adj-out] table 154 % gobgp neighbor <neighbor address> [local|adj-in|adj-out] [-a <address family>] 155 # show a specific route in [local|adj-in|adj-out] table 156 % gobgp neighbor <neighbor address> [local|adj-in|adj-out] [<prefix>|<host>] [longer-prefixes|shorter-prefixes] [-a <address family>] 157 # show table summary 158 % gobgp neighbor <neighbor address> [local|adj-in|adj-out] summary [-a <address family>] 159 # show RPKI detailed information in adj-in table 160 % gobgp neighbor <neighbor address> adj-in <prefix> validation 161 ``` 162 163 #### - example 164 165 If you want to show the local rib of ipv4 that neighbor(10.0.0.1) has: 166 167 ```shell 168 % gobgp neighbor 10.0.0.1 local -a ipv4 169 ``` 170 171 #### - option 172 173 The following options can be specified in the neighbor subcommand: 174 175 | short |long | description | default | 176 |--------|---------------|--------------------------------------------|---------| 177 |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`, `opaque` | `ipv4` | 178 179 ### 2.4. Operations for Policy - add/del/show - 180 181 #### Syntax 182 183 ```shell 184 # show neighbor policy assignment 185 % gobgp neighbor <neighbor address> policy { in | import | export } 186 # add policies to specific neighbor policy 187 % gobgp neighbor <neighbor address> policy { in | import | export } add <policy name>... [default { accept | reject }] 188 # set policies to specific neighbor policy 189 % gobgp neighbor <neighbor address> policy { in | import | export } set <policy name>... [default { accept | reject }] 190 # remove attached policies from specific neighbor policy 191 % gobgp neighbor <neighbor address> policy { in | import | export } del <policy name>... 192 # remove all policies from specific neighbor policy 193 % gobgp neighbor <neighbor address> policy { in | import | export } del 194 ``` 195 196 #### Example 197 198 If you want to add the import policy to neighbor(10.0.0.1): 199 200 ```shell 201 % gobgp neighbor 10.0.0.1 policy import add policy1 policy2 default accept 202 ``` 203 204 You can specify multiple policy to neighbor separated by commas. 205 206 `default <policy action>` means the operation `{accept | reject}` in the case where the route does not match the conditions of the policy. 207 208 ## 3. policy subcommand 209 210 ### 3.1. Operations for PrefixSet - add/del/show - 211 212 #### Syntax 213 214 ```shell 215 # add PrefixSet 216 % gobgp policy prefix add <prefix set name> <prefix> [<mask length range>] 217 # delete a PrefixSet 218 % gobgp policy prefix del <prefix set name> 219 # delete a prefix from specific PrefixSet 220 % gobgp policy prefix del <prefix set name> <prefix> [<mask length range>] 221 # show all PrefixSet information 222 % gobgp policy prefix 223 # show a specific PrefixSet 224 % gobgp policy prefix <prefix set name> 225 ``` 226 227 #### Example 228 229 If you want to add the PrefixSet: 230 231 ```shell 232 % gobgp policy prefix add ps1 10.33.0.0/16 16..24 233 ``` 234 235 A PrefixSet it is possible to have multiple prefix, if you want to remove the PrefixSet to specify only PrefixSet name. 236 237 ```shell 238 % gobgp policy prefix del ps1 239 ``` 240 241 If you want to remove one element(prefix) of PrefixSet, to specify a prefix in addition to the PrefixSet name. 242 243 ```shell 244 % gobgp policy prefix del ps1 10.33.0.0/16 245 ``` 246 247 ### 3.2. Operations for NeighborSet - add/del/show - 248 249 #### Syntax 250 251 ```shell 252 # add NeighborSet 253 % gobgp policy neighbor add <neighbor set name> <neighbor address/prefix> 254 # delete a NeighborSet 255 % gobgp policy neighbor del <neighbor set name> 256 # delete a neighbor from a NeighborSet 257 % gobgp policy neighbor del <neighbor set name> <address> 258 # show all NeighborSet information 259 % gobgp policy neighbor 260 # show a specific NeighborSet information 261 % gobgp policy neighbor <neighbor set name> 262 ``` 263 264 #### Example 265 266 If you want to add the NeighborSet: 267 268 ```shell 269 % gobgp policy neighbor add ns1 10.0.0.1 270 ``` 271 272 You can also specify a neighbor address range with the prefix representation: 273 274 ```shell 275 % gobgp policy neighbor add ns 10.0.0.0/24 276 ``` 277 278 A NeighborSet is possible to have multiple address, if you want to remove the NeighborSet to specify only NeighborSet name. 279 280 ```shell 281 % gobgp policy neighbor del ns1 282 ``` 283 284 If you want to remove one element(address) of NeighborSet, to specify a address in addition to the NeighborSet name. 285 286 ```shell 287 % gobgp policy prefix del ns1 10.0.0.1 288 ``` 289 290 ### 3.3. Operations for AsPathSet - add/del/show - 291 292 #### Syntax 293 294 ```shell 295 # add AsPathSet 296 % gobgp policy as-path add <aspath set name> <as path> 297 # delete a specific AsPathSet 298 % gobgp policy as-path del <aspath set name> 299 # delete an as-path from a AsPathSet 300 % gobgp policy as-path del <aspath set name> <as path> 301 # show all AsPathSet information 302 % gobgp policy as-path 303 # show a specific AsPathSet information 304 % gobgp policy as-path <aspath set name> 305 ``` 306 307 #### Example 308 309 If you want to add the AsPathSet: 310 311 ```shell 312 % gobgp policy as-path add ass1 ^65100 313 ``` 314 315 You can specify the position using regexp-like expression as follows: 316 317 - From: `^65100` means the route is passed from AS 65100 directly. 318 - Any: `_65100_` means the route comes through AS 65100. 319 - Origin: `_65100$` means the route is originated by AS 65100. 320 - Only: `^65100$` means the route is originated by AS 65100 and comes from it directly. 321 322 Further you can specify the consecutive aspath and use regexp in each element as follows: 323 324 - `^65100_65001` 325 - `65100_[0-9]+_.*$` 326 - `^6[0-9]_5.*_65.?00$` 327 328 An AsPathSet it is possible to have multiple as path, if you want to remove the AsPathSet to specify only AsPathSet name. 329 330 ```shell 331 % gobgp policy as-path del ass1 332 ``` 333 334 If you want to remove one element(as path) of AsPathSet, to specify an as path in addition to the AsPathSet name. 335 336 ```shell 337 % gobgp policy as-path del ass1 ^65100 338 ``` 339 340 ### 3.4. Operations for CommunitySet - add/del/show - 341 342 #### Syntax 343 344 ```shell 345 # add CommunitySet 346 % gobgp policy community add <community set name> <community> 347 # delete a specific CommunitySet 348 % gobgp policy community del <community set name> 349 # delete a community from a CommunitySet 350 % gobgp policy community del <community set name> <community> 351 # show all CommunitySet information 352 % gobgp policy community 353 # show a specific CommunitySet information 354 % gobgp policy community <community set name> 355 ``` 356 357 #### Example 358 359 If you want to add the CommunitySet: 360 361 ```shell 362 % gobgp policy community add cs1 65100:10 363 ``` 364 365 You can specify the position using regexp-like expression as follows: 366 367 - `6[0-9]+:[0-9]+` 368 - `^[0-9]*:300$` 369 370 A CommunitySet it is possible to have multiple community, if you want to remove the CommunitySet to specify only CommunitySet name. 371 372 ```shell 373 % gobgp policy neighbor del cs1 374 ``` 375 376 If you want to remove one element(community) of CommunitySet, to specify a address in addition to the CommunitySet name. 377 378 ```shell 379 % gobgp policy prefix del cs1 65100:10 380 ``` 381 382 ### 3.5. Operations for ExtCommunitySet - add/del/show - 383 384 #### Syntax 385 386 ```shell 387 # add ExtCommunitySet 388 % gobgp policy ext-community add <extended community set name> <extended community> 389 # delete a specific ExtCommunitySet 390 % gobgp policy ext-community del <extended community set name> 391 # delete a ext-community from a ExtCommunitySet 392 % gobgp policy ext-community del <extended community set name> <extended community> 393 # show all ExtCommunitySet information 394 % gobgp policy ext-community 395 # show a specific ExtCommunitySet information 396 % gobgp policy ext-community <extended community set name> 397 ``` 398 399 #### Example 400 401 If you want to add the ExtCommunitySet: 402 403 ```shell 404 % gobgp policy ext-community add ecs1 RT:65100:10 405 ``` 406 407 Extended community set as `<SubType>:<Global Admin>:<LocalAdmin>`. 408 409 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. 410 411 You can specify the position using regexp-like expression as follows: 412 413 - `RT:[0-9]+:[0-9]+` 414 - `SoO:10.0.10.10:[0-9]+` 415 416 However, regular expressions for subtype can not be used, to use for the global admin and local admin. 417 418 A ExtCommunitySet it is possible to have multiple extended community, if you want to remove the ExtCommunitySet to specify only ExtCommunitySet name. 419 420 ```shell 421 % gobgp policy neighbor del ecs1 422 ``` 423 424 If you want to remove one element(extended community) of ExtCommunitySet, to specify a address in addition to the ExtCommunitySet name. 425 426 ```shell 427 % gobgp policy prefix del ecs1 RT:65100:10 428 ``` 429 430 ### 3.6. Operations for LargeCommunitySet - add/del/show - 431 432 #### Syntax 433 434 ```shell 435 # add LargeCommunitySet 436 % gobgp policy large-community add <set name> <large community>... 437 # delete a specific LargeCommunitySet 438 % gobgp policy large-community del <set name> 439 # delete a large-community from a LargeCommunitySet 440 % gobgp policy large-community del <set name> <large community> 441 # show all LargeCommunitySet information 442 % gobgp policy large-community 443 # show a specific LargeCommunitySet information 444 % gobgp policy large-community <set name> 445 ``` 446 447 #### Example 448 449 ```shell 450 % gobgp policy large-community add l0 100:100:100 451 % gobgp policy large-community add l0 ^100: 452 % gobgp policy large-community add l0 :100$ 453 % gobgp policy large-community del l0 100:100:100 454 % gobgp policy large-community add l0 200:100:100 455 % gobgp policy large-community 456 % gobgp policy large-community set l0 100:100:100 200:200:200 300:300:300 457 ``` 458 459 ### 3.7 Statement Operation - add/del/show - 460 461 #### Syntax 462 463 ```shell 464 # mod statement 465 % gobgp policy statement { add | del } <statement name> 466 # mod a condition to a statement 467 % 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>... } } 468 # mod an action to a statement 469 % 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> } 470 # show all statements 471 % gobgp policy statement 472 # show a specific statement 473 % gobgp policy statement <statement name> 474 ``` 475 476 ### 3.8 Policy Operation - add/del/show - 477 478 #### Syntax 479 480 ```shell 481 # mod policy 482 % gobgp policy { add | del | set } <policy name> [<statement name>...] 483 # show all policies 484 % gobgp policy 485 # show a specific policy 486 % gobgp policy <policy name> 487 ``` 488 489 ## 4. vrf subcommand 490 491 ### 4.1 Add/Delete/Show VRF 492 493 #### Syntax 494 495 ```shell 496 # add vrf 497 % gobgp vrf add <vrf name> rd <rd> rt {import|export|both} <rt>... 498 # del vrf 499 % gobgp vrf del <vrf name> 500 # show vrf 501 % gobgp vrf 502 ``` 503 504 #### Example 505 506 ```shell 507 % gobgp vrf add vrf1 rd 10.100:100 rt both 10.100:100 import 10.100:101 export 10.100:102 508 % gobgp vrf 509 Name RD Import RT Export RT 510 vrf1 10.100:100 10.100:100, 10.100:101 10.100:100, 10.100:102 511 % gobgp vrf del vrf1 512 % gobgp vrf 513 Name RD Import RT Export RT 514 ``` 515 516 ### 4.2 Add/Delete/Show VRF routes 517 518 #### Syntax 519 520 ```shell 521 # add routes to vrf 522 % gobgp vrf <vrf name> rib add <prefix> [-a <address family>] 523 # del routes from vrf 524 % gobgp vrf <vrf name> rib del <prefix> [-a <address family>] 525 # show routes in vrf 526 % gobgp vrf <vrf name> rib [-a <address family>] 527 ``` 528 529 #### Example 530 531 ```shell 532 % gobgp vrf vrf1 rib add 10.0.0.0/24 533 % gobgp vrf vrf1 rib add 2001::/64 -a ipv6 534 % gobgp vrf vrf1 rib 535 Network Next Hop AS_PATH Age Attrs 536 10.100:100:10.0.0.0/24 0.0.0.0 00:00:40 [{Origin: i} {Extcomms: [10.100:100], [10.100:101]}] 537 % gobgp vrf vrf1 rib -a ipv6 538 Network Next Hop AS_PATH Age Attrs 539 10.100:100:2001::/64 :: 00:00:00 [{Origin: i} {Extcomms: [10.100:100], [10.100:101]}] 540 % gobgp vrf vrf1 rib del 10.0.0.0/24 541 % gobgp vrf vrf1 rib del 2001::/64 542 ``` 543 544 ## 5. monitor subcommand 545 546 ### 5.1 monitor global rib 547 548 #### Syntax 549 550 ```shell 551 # monitor global rib 552 % gobgp monitor global rib [-a <address family>] [--current] 553 ``` 554 555 #### Example 556 557 ```shell 558 [TERM1] 559 % gobgp monitor global rib 560 [ROUTE] 10.0.0.0/24 via 0.0.0.0 aspath [] attrs [{Origin: i}] 561 562 [TERM2] 563 # monitor command blocks. add routes from another terminal 564 % gobgp global rib add 10.0.0.0/24 565 ``` 566 567 ### 5.2 monitor neighbor status 568 569 #### Syntax 570 571 ```shell 572 # monitor neighbor status 573 % gobgp monitor neighbor [--current] 574 # monitor specific neighbor status 575 % gobgp monitor neighbor <neighbor address> [--current] 576 ``` 577 578 #### Example 579 580 ```shell 581 [TERM1] 582 % gobgp monitor neighbor 583 [NEIGH] 192.168.10.2 fsm: BGP_FSM_IDLE admin: down 584 [NEIGH] 192.168.10.2 fsm: BGP_FSM_ACTIVE admin: up 585 [NEIGH] 192.168.10.2 fsm: BGP_FSM_OPENSENT admin: up 586 [NEIGH] 192.168.10.2 fsm: BGP_FSM_OPENCONFIRM admin: up 587 [NEIGH] 192.168.10.2 fsm: BGP_FSM_ESTABLISHED admin: up 588 589 [TERM2] 590 % gobgp neighbor 192.168.10.2 disable 591 % gobgp neighbor 192.168.10.2 enable 592 ``` 593 594 ### 5.3 monitor Adj-RIB-In 595 596 #### Syntax 597 598 ```shell 599 # monitor Adj-RIB-In 600 % gobgp monitor adj-in [-a <address family>] [--current] 601 # monitor Adj-RIB-In for specific neighbor 602 % gobgp monitor adj-in <neighbor address> [-a <address family>] [--current] 603 ``` 604 605 #### Example 606 607 ```shell 608 [GoBGP1] 609 % gobgp monitor adj-in 610 [ROUTE] 0:10.2.1.0/24 via 10.0.0.2 aspath [65002] attrs [{Origin: ?}] 611 [DELROUTE] 0:10.2.1.0/24 via <nil> aspath [] attrs [] 612 613 [GoBGP2] 614 % gobgp global rib -a ipv4 add 10.2.1.0/24 615 % gobgp global rib -a ipv4 del 10.2.1.0/24 616 ``` 617 618 ## 6. mrt subcommand 619 620 ### 6.1 dump mrt records 621 622 #### Syntax 623 624 ```shell 625 % gobgp mrt dump rib global [<interval>] 626 % gobgp mrt dump rib neighbor <neighbor address> [<interval>] 627 ``` 628 629 #### Options 630 631 | short |long | description | 632 |--------|--------|--------------------------------| 633 | f | format | filename format | 634 | o | outdir | output directory of dump files | 635 636 #### Example 637 638 see [MRT](mrt.md). 639 640 ### 6.2 inject mrt records 641 642 #### Syntax 643 644 ```shell 645 % gobgp mrt inject global <filename> [<count>] 646 ``` 647 648 #### Example 649 650 see [MRT](mrt.md).