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
|
# Running GoBGP
This page explains how to run GoBGP. This example sets up GoBGP to
connect with two eBGP peers for IPv4 routes. Even if you are
interested in other GoBGP use cases (such as IPv6 routes, EVPN, and
Route Server), this example gives you the basics of GoBGP usage.
## Prerequisites
You need to install [Go 1.3 or later](http://golang.org/doc/install). After installing Go, make sure that `$GOPATH/bin` in included in your `$PATH`.
## Installing GoBGP
```bash
$ go get github.com/osrg/gobgp/gobgpd
$ go get github.com/osrg/gobgp/gobgp
```
Finished. No dependency hell (library, package, etc) thanks to Go.
The first command installs GoBGP daemon (speaking BGP protocol). The
second one installs GoBGP CLI. The CLI isn't a must but handy whey you
play with GoBGP.
In addition, if you use Bash shell, you can enjoy CLI's tab completion:
```bash
$ wget https://raw.githubusercontent.com/osrg/gobgp/master/tools/completion/gobgp-completion.bash
$ source gobgp-completion.bash
```
## Configuration
Currently, GoBGP can be configured via a configuration file. This example
uses the following very simple configuration file, `gobgpd.conf`:
```
$ cat gobgpd.conf
[Global]
As = 64512
RouterId = "192.168.255.1"
[[NeighborList]]
NeighborAddress = "10.0.255.1"
PeerAs = 65001
[[NeighborList]]
NeighborAddress = "10.0.255.2"
PeerAs = 65002
```
## Starting GoBGP
Let's start gobgpd:
```
$ sudo -E gobgpd -f gobgpd.conf
{"level":"info","msg":"Peer 10.0.255.1 is added","time":"2015-04-06T20:32:28+09:00"}
{"level":"info","msg":"Peer 10.0.255.2 is added","time":"2015-04-06T20:32:28+09:00"}
```
Let's show the information of all the peers.
```
$ gobgp neighbor
Peer AS Up/Down State |#Advertised Received Accepted
10.0.255.1 65001 00:00:14 Establ | 1 5 5
10.0.255.2 65002 00:00:14 Establ | 5 2 2
```
Want to the details of a particular peer?
```
$ gobgp neighbor 10.0.255.1
BGP neighbor is 10.0.255.1, remote AS 65001
BGP version 4, remote router ID 192.168.0.1
BGP state = BGP_FSM_ESTABLISHED, up for 00:01:49
BGP OutQ = 0, Flops = 0
Neighbor capabilities:
MULTIPROTOCOL: advertised and received
ROUTE_REFRESH: advertised and received
FOUR_OCTET_AS_NUMBER: advertised and received
ROUTE_REFRESH_CISCO: received
Message statistics:
Sent Rcvd
Opens: 2 1
Notifications: 0 0
Updates: 1 1
Keepalives: 4 5
Route Refesh: 0 0
Discarded: 0 0
Total: 7 7
```
Note that the tab completion works for both peer names and commands.
Check out the global table.
```
$ gobgp global rib
Network Next Hop AS_PATH Age Attrs
*> 10.3.0.0/16 10.0.255.1 [65001] 00:05:41 [{Origin: 0} {Med: 0}]
*> 10.3.0.0/24 10.0.255.1 [65001] 00:05:41 [{Origin: 0} {Med: 0}]
* 10.3.0.0/24 10.0.255.2 [65002] 00:05:41 [{Origin: 0} {Med: 111} {Community: [65001:65002 NO_EXPORT]}]
*> 10.3.0.0/32 10.0.255.1 [65001] 00:05:41 [{Origin: 0} {Med: 0}]
*> 10.3.0.1/32 10.0.255.1 [65001] 00:05:41 [{Origin: 0} {Med: 0}]
*> 10.33.0.0/16 10.0.255.1 [65001] 00:05:41 [{Origin: 0} {Med: 0}]
*> 192.168.2.0/24 10.0.255.2 [65002] 00:05:41 [{Origin: 0} {Med: 111} {Community: [65001:65002 NO_EXPORT]}]
```
You also can look at adjacent rib-in and rib-out:
```
$ gobgp neighbor 10.0.255.1 adj-in
Network Next Hop AS_PATH Age Attrs
10.3.0.0/16 10.0.255.1 [65001] 00:06:55 [{Origin: 0} {Med: 0}]
10.3.0.0/24 10.0.255.1 [65001] 00:06:55 [{Origin: 0} {Med: 0}]
10.3.0.0/32 10.0.255.1 [65001] 00:06:55 [{Origin: 0} {Med: 0}]
10.3.0.1/32 10.0.255.1 [65001] 00:06:55 [{Origin: 0} {Med: 0}]
10.33.0.0/16 10.0.255.1 [65001] 00:06:55 [{Origin: 0} {Med: 0}]
$ gobgp neighbor 10.0.255.1 adj-out
Network Next Hop AS_PATH Attrs
192.168.2.0/24 10.0.255.254 [64512 65002] [{Origin: 0} {Community: [65001:65002 NO_EXPORT]}]
```
|