summaryrefslogtreecommitdiffhomepage
path: root/docs/sources/cli-command-syntax.md
blob: fdbfcac6f7a0a034474ecba01ef4377999bd086e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# CLI command syntax

This page explains gobgp client command syntax.



## basic command pattern
gobgp \<subcommand> \<object>  opts...

gobgp has three subcommands.
- global
- neighbor
- policy


## 1. global subcommand
### 1.1. Operations for Global-Rib - add/del/show -
#### - syntax
```shell
# add Route
% gobgp global rib add <prefix> [-a <address family>]
# delete a specific Route
% gobgp global rib del <prefix> [-a <address family>]
# show all Route information
% gobgp global rib [-a <address family>]
# show a specific route information
% gobgp global rib [<prefix>|<host>] [-a <address family>]
```

#### - example
If you want to add routes with the address of the ipv4 to global rib:
```shell
% gobgp global rib add 10.33.0.0 -a ipv4
```
If you want to remove routes with the address of the ipv6 from global rib:
```shell
% gobgp global rib del 2001:123:123:1::/64 -a ipv6
```

#### - option
The following options can be specified in the global subcommand:

| short  |long           | description                                |
|--------|---------------|--------------------------------------------|
|a       |address-family |specify the ipv4, ipv6, evpn, encap, or rtc |

<br>

## 2. neighbor subcommand
### 2.1. Show Neighbor Status
#### - syntax
```shell
# show neighbor's status as list
% gobgp neighbor
# show status of a specific neighbor
% gobgp neighbor <neighbor address>
```

### 2.2. Operations for neighbor - shutdown/reset/softreset/enable/disable -
#### - syntax
```shell
% gobgp neighbor <neighbor address> shutdown
% gobgp neighbor <neighbor address> reset
% gobgp neighbor <neighbor address> softreset [-a <address family>]
% gobgp neighbor <neighbor address> softresetin [-a <address family>]
% gobgp neighbor <neighbor address> softresetout [-a <address family>]
% gobgp neighbor <neighbor address> enable
% gobgp neighbor <neighbor address> disable
```
#### - option
  The following options can be specified in the neighbor subcommand:

| short  |long           | description                  |
|--------|---------------|------------------------------|
|a       |address-family |specify the ipv4 or ipv6      |


### 2.3. Show Rib - local-rib/adj-rib-in/adj-rib-out -
#### - syntax
```shell
# show all routes in [local|adj-in|adj-out] table
% gobgp neighbor <neighbor address> [local|adj-in|adj-out] [-a <address family>]
# show a specific route in [local|adj-in|adj-out] table
% gobgp neighbor <neighbor address> [local|adj-in|adj-out] [<prefix>|<host>] [-a <address family>]
```

#### - example
If you want to show the local rib of ipv4 that neighbor(10.0.0.1) has:
```shell
% gobgp neighbor 10.0.0.1 local -a ipv4
```

#### - option
The following options can be specified in the neighbor subcommand:

| short  |long           | description                  |
|--------|---------------|------------------------------|
|a       |address-family |specify the ipv4 or ipv6      |


### 2.4. Operations for Policy  - add/del/show -
#### - syntax
```shell
# add policy to import-policy configuration
% gobgp neighbor <neighbor address> policy add import <policy names> <default policy action>
# add policy to export-policy configuration
% gobgp neighbor <neighbor address> policy add export <policy names> <default policy action>
# add policy to distribute-policy configuration
% gobgp neighbor <neighbor address> policy add distribute <policy names> <default policy action>
# delete import-policy configuration from specific neighbor
% gobgp neighbor <neighbor address> policy del import
# delete export-policy configuration from specific neighbor
% gobgp neighbor <neighbor address> policy del export
# delete distribute-policy configuration from specific neighbor
% gobgp neighbor <neighbor address> policy del distribute
# show a specific policy information
% gobgp neighbor <neighbor address> policy
```

#### - example
If you want to add the import policy to neighbor(10.0.0.1):
```shell
% gobgp neighbor 10.0.0.1 policy add import policy1,policy2 accept
```
You can specify multiple policy to neighbor separated by commas.

\<default policy action> means the operation(accept | reject) in the case where the route does not match the conditions of the policy.


<br>

## 3. policy subcommand
### 3.1. Operations for PrefixSet - add/del/show -
#### - syntax
```shell
# add PrefixSet
% gobgp policy prefix add <prefix set name> <prefix> [<mask length range>]
# delete all PrefixSet
% gobgp policy prefix del all
# delete a specific PrefixSet
% gobgp policy prefix del <prefix set name> [<prefix> <mask length range>]
# show all PrefixSet information
% gobgp policy prefix
# show a specific PrefixSet
% gobgp policy prefix <prefix set name>
```

#### - example
If you want to add the PrefixSet:
```shell
% gobgp policy prefix add ps1 10.33.0.0/16 16..24
```
A PrefixSet it is possible to have multiple prefix, if you want to remove the PrefixSet to specify only PrefixSet name.
```shell
% gobgp policy prefix del ps1
```
If you want to remove one element(prefix) of PrefixSet, to specify a prefix in addition to the PrefixSet name.
```shell
% gobgp policy prefix del ps1 10.33.0.0/16
```

### 3.2. Operations for NeighborSet - add/del/show -
#### - syntax
```shell
# add NeighborSet
% gobgp policy neighbor add <neighbor set name> <neighbor address>
# delete all NeighborSet
% gobgp policy neighbor del all
# delete a specific NeighborSet
% gobgp policy neighbor del <neighbor set name> [<address>]
# show all NeighborSet information
% gobgp policy neighbor
# show a specific NeighborSet information
% gobgp policy neighbor <neighbor set name>
```

#### - example
If you want to add the NeighborSet:
```shell
% gobgp policy neighbor add ns1 10.0.0.1
```
A NeighborSet it is possible to have multiple address, if you want to remove the NeighborSet to specify only NeighborSet name.
```shell
% gobgp policy neighbor del ns1
```
If you want to remove one element(address) of NeighborSet, to specify a address in addition to the NeighborSet name.
```shell
% gobgp policy prefix del ns1 10.0.0.1
```

### 3.3. Operations for AsPathSet - add/del/show -
#### - syntax
```shell
# add AsPathSet
% gobgp policy aspath add <aspath set name> <as path>
# delete all AsPathSet
% gobgp policy aspath del all
# delete a specific AsPathSet
% gobgp policy aspath del <aspath set name> [<as path>]
# show all AsPathSet information
% gobgp policy aspath
# show a specific AsPathSet information
% gobgp policy aspath <aspath set name>
```

#### - example
If you want to add the AsPathSet:
```shell
% gobgp policy aspath add ass1 ^65100
```
   You can specify the position using regexp-like expression as follows:
   - From: "^65100" means the route is passed from AS 65100 directly.
   - Any: "65100" means the route comes through AS 65100.
   - Origin: "65100$" means the route is originated by AS 65100.
   - Only: "^65100$" means the route is originated by AS 65100 and comes from it directly.

An AsPathSet it is possible to have multiple as path, if you want to remove the AsPathSet to specify only AsPathSet name.
```shell
% gobgp policy aspath del ass1
```
If you want to remove one element(as path) of AsPathSet, to specify an as path in addition to the AsPathSet name.
```shell
% gobgp policy aspath del ass1 ^65100
```

### 3.4. Operations for CommunitySet - add/del/show -
#### - syntax
```shell
# add CommunitySet
% gobgp policy community add <community set name> <community>
# delete all CommunitySet
% gobgp policy community del all
# delete a specific CommunitySet
% gobgp policy community del <community set name> [<community>]
# show all CommunitySet information
% gobgp policy community
# show a specific CommunitySet information
% gobgp policy community <community set name>
```

#### - example
If you want to add the CommunitySet:
```shell
% gobgp policy community add cs1 65100:10
```
   You can specify the position using regexp-like expression as follows:
   - 6[0-9]+:[0-9]+
   - ^[0-9]*:300$

A CommunitySet it is possible to have multiple community, if you want to remove the CommunitySet to specify only CommunitySet name.
```shell
% gobgp policy neighbor del cs1
```
If you want to remove one element(community) of CommunitySet, to specify a address in addition to the CommunitySet name.
```shell
% gobgp policy prefix del cs1 65100:10
```

### 3.5. Operations for ExtCommunitySet - add/del/show -
#### - syntax
```shell
# add ExtCommunitySet
% gobgp policy extcommunity add <extended community set name> <extended community>
# delete all ExtCommunitySet
% gobgp policy extcommunity del all
# delete a specific ExtCommunitySet
% gobgp policy extcommunity del <extended community set name> [<extended community>]
# show all ExtCommunitySet information
% gobgp policy extcommunity
# show a specific ExtCommunitySet information
% gobgp policy extcommunity <extended community set name>
```

#### - example
If you want to add the ExtCommunitySet:
```shell
% gobgp policy extcommunity add ecs1 RT:65100:10
```
Extended community set as \<SubType>:\<Global Admin>:\<LocalAdmin>.

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.

You can specify the position using regexp-like expression as follows:
   - RT:[0-9]+:[0-9]+
   - SoO:10.0.10.10:[0-9]+

However, regular expressions for subtype can not be used, to use for the global admin and local admin.

A ExtCommunitySet it is possible to have multiple extended community, if you want to remove the ExtCommunitySet to specify only ExtCommunitySet name.
```shell
% gobgp policy neighbor del ecs1
```
If you want to remove one element(extended community) of ExtCommunitySet, to specify a address in addition to the ExtCommunitySet name.
```shell
% gobgp policy prefix del ecs1 RT:65100:10
```

### 3.6. Operations for RoutePolicy - add/del/show -
#### - syntax
```shell
# add RoutePolicy
% gobgp policy routepoilcy add <route policy name> <statement name> [<conditions and actions>]
# delete all RoutePolicy
% gobgp policy routepoilcy del all
# delete a specific RoutePolicy
% gobgp policy routepoilcy del <route policy name> [<statement name>]
# show all RoutePolicy information
% gobgp policy routepoilcy
# show a specific RoutePolicy information
% gobgp policy routepoilcy <route policy name>
```

#### - example
If you want to add the RoutePolicy:
```shell
% gobgp policy routepolicy add policy1 state1 --c-prefix=ps1 --c-neighbor=ns1 --c-aspath=ass1 --c-community=cs1 --c-extcommunity=ecs1 --c-aslen=eq,3 --c-option=all --a-route=reject --a-community=ADD[65100:20] --a-med=+100 --a-asprepend=65100,10
```
However, it is not necessary to specify all of the options at once.


A RoutePolicy it is possible to have multiple statement, if you want to remove the RoutePolicy to specify only RoutePolicy name.
```shell
% gobgp policy routepolicy del policy1
```
If you want to remove one element(statement) of RoutePolicy, to specify a statement name in addition to the RoutePolicy name.
```shell
% gobgp policy prefix del policy1 state1
```

#### - option
The following options can be specified in the policy subcommand:
  - options of condition

| short  |long           | description                                                                     |
|--------|---------------|---------------------------------------------------------------------------------|
|-       |c-prefix       |specify the name that added prefix set in PrefixSet subcommand                   |
|-       |c-neighbor     |specify the name that added neighbor set in NeighborSet subcommand               |
|-       |c-aspath       |specify the name that added as path set in AsPathSet subcommand                  |
|-       |c-community    |specify the name that added community set in CommunitySet subcommand             |
|-       |c-extcommunity |specify the name that added extended community set in ExtCommunitySet subcommand |
|-       |c-aslen        |specify the operator(eq, ge, le) and value(numric)                               |
|-       |c-option       |specify the match option(any, all, invert)                                       |

  - options of action

| short  |long        | description                                                                                                   |
|--------|------------|---------------------------------------------------------------------------------------------------------------|
|-       |a-route     |specify the action(accept, reject) of the route that match to the conditions                                   |
|-       |a-community |specify the community operation of the route that match to the conditions                                      |
|-       |a-med       |specify the med operation of the route that match to the conditions                                            |
|-       |a-asprepend |specify a combination of an AS number and repeat count(e.g. 65100,10) to prepend if the path matches conditions|