Ixbrforum10 Day3 Gobgp Tutorial
Ixbrforum10 Day3 Gobgp Tutorial
Ixbrforum10 Day3 Gobgp Tutorial
connecting router
Shu Sugimoto
IX.br Forum 10
2016/12/07(Wed)
Written in Golang
High performance
exploits multi-cores natively
Automation friendly
CLI Your
API first principle gobgp Software
API
CLI on top of API (gRPC)
gobgpd
full-featured CLI
Multiprotocol support
IPv4, IPv6, Labeled IPv4/IPv6, VPN IPv4/IPv6, EVPN,
flowspec IPv4/IPv6/L2
Flexible Policy
Graceful Restart
both restarting/helper speaker role
Route Reflector
Route Server
MRT dumping
BMP
RPKI validation
FIB manipulation
gRPC API
gobgpd
main daemon process which implements BGP
can be controlled via gRPC API
configuration file also supported
gobgp
full-featured CLI
convert human friendly commands into gRPC API call
and vice versa
show RIB
$ gobgp global rib
Network Next Hop AS_PATH Age
Attrs
*> 10.1.0.0/16 0.0.0.0 3d
08:06:32 [{Origin: i} {Med: 0}]
N*> 10.3.0.0/16 10.173.176.103 65003 3d
08:34:01 [{Origin: i} {Communities: 65001:1000}]
N* 10.3.0.0/16 10.173.176.103 65003
00:00:03 [{Origin: i} {Communities: 65001:1000}]
N*> 10.4.0.0/16 10.1.14.104 65004 3d
08:34:03 [{Origin: i} {LocalPref: 100}]
neighbor operations
### perform peer softresetin
$ gobgp neighbor 10.1.0.101 softresetin
### add route into RIB, which will then advertised to peers
$ gobgp global rib add -a ipv4 10.0.0.0/24 med 10 community 100:100
`-j` support
Every command supports json output
$ gobgp global rib 10.4.0.0/16 -j
{"10.4.0.0/16":[{"nlri":{"prefix":"10.4.0.0/16"},"attrs":[{"type":1,"val
ue":0},{"type":2,"as_paths":[{"segment_type":2,"num":1,"asns":[65004]}]}
,{"type":3,"nexthop":"10.1.14.104"},{"type":5,"value":100},{"type":8,"co
mmunities":[4259907539]}],"age":1480845275,"validation":"not-
found","source-id":"10.1.0.101","neighbor-ip":"10.1.0.101"}]}
Event monitoring
The data will be sent from gobgpd through the gRPC
connection channel when events occur
Push notification
One implementation of the event driven application
$ gobgp monitor global rib
[ROUTE] 10.3.0.0/16 via 10.173.176.103 aspath [65003] attrs [{Origin: i}
{Communities: 65001:1000, 65001:2003}]
[ROUTE] 10.4.0.0/16 via 10.1.14.104 aspath [65004] attrs [{Origin: i}
{LocalPref: 100} {Communities: 65001:2003}]
[DELROUTE] 10.3.0.0/16 via 10.173.176.103 aspath [65003] attrs [{Origin:
i} {Communities: 65001:1000, 65001:2003}]
[ROUTE] 10.3.0.0/16 via 10.173.176.103 aspath [65003] attrs [{Origin: i}
{Communities: 65001:1000, 65001:2003}]
[ROUTE] 10.3.0.0/16 via 10.173.176.103 aspath [65003] attrs [{Origin: i}
{Communities: 65001:1000, 65001:2003}]
(waiting for further events)
Monitoring compoment
FastNetMon
DoS/DDoS analyzer
BGPmon
BGP routing information monitor
Cloudwatt
is an OpenStack based public cloud service
They seems to be using it as a component of Looking
Glass
Test virtualization
ex.) One is using GoBGP to virtualize the Lab
environment for testing BGP routing policies
Only test target is a real router, everything else is VM
GoBGP is used as a route originator
gRPC API is used to generate arbitrary routes
http://www.slideshare.net/ssuser6a8d29/gobgp
in Japanese :P
Automation Friendliness
Its definitely easier to implement whatever comes up in
your mind
Everything is exposed through API
`gobgp -j` can be a good start point of thinking about
automation
can skip the painful output parsing part, which broke a
lot of peoples motivation
much easier to begin with for operators J
Performance
Especially in larger deploy
GoBGP is just a bgp daemon and itself does not contain any
functionality to modify routing table
https://github.com/osrg/goplane
CLI operation
vtysh vtysh
routing table
Linux kernel
gRPC
vtysh API
gobgpd acts as
ospfd gobgpd
one of zclient
vtysh zserv.api
zebra
routing table
Linux kernel
Target
g2 eth3
IX ge-0/0/1
r3
.102 .103
eth2
iBGP 10.173.176.0/24 lo: 10.3.0.103
.102
10.1.12.0/24
lo: 10.1.0.101
.101 OSPF Area 0 eBGP
ge-0/0/1
r1
redistribute Host OS Softwares
ge-0/0/2
direct r1 vSRX 12.1
.101
GoBGP
eBGP 10.1.14.0/24 10.254.0.0/24
g2 Debian 8
Quagga (zebra/ospfd)
r3 vSRX 12.1
.104 g2
ge-0/0/1
.102 eth1 r4 vSRX 12.1
r4 rs Debian 8 GoBGP (Route Server)
AS65004 .250 eth1
10.4.0.0/16 Ryu BMP server
util util Debian 8
lo: 10.4.0.104 influxdb
Vagrant 1.8.1
vagrant-host-shell 0.0.4
vagrant-junos 0.2.1
VirtualBox 5.0.28
RAM
> 16GB
Recommend 32GB or more if you handle IPv4 full
routes = 600k routes with multiple eBGP peers
This is by design
No extensive tweaks, keep it simple, just buy memory
CPU
> 2cores
The more, the better performance
VM is fine
If forwarding is not the issue
[Service]
Type=simple
PermissionsStartOnly=yes
User=quagga
ExecStartPre=/sbin/setcap 'cap_net_bind_service=+ep'
/usr/local/sbin/gobgpd
ExecStart=/usr/local/sbin/gobgpd -f /etc/gobgp/gobgpd.conf -t yaml --
cpus=2
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target
EOF
g2 $ systemctl daemon-reload
[[neighbors]]
[neighbors.config]
neighbor-address = 10.173.176.103
peer-as = 65003
[[neighbors]]
[neighbors.config]
neighbor-address = 10.1.0.101
peer-as = 65001
[neighbors.transport.config]
local-address = 10.1.0.102
neighbors:
- config:
neighbor-address: 10.173.176.103
peer-as: 65003
Caveats: you need to use `-j` option and see in json format to
see more detailed attributes like router-id or source (from
which neighbor the route has received)
Feel free to open an issue at GitHub J
defined-sets:
neighbor-sets:
- neighbor-set-name: ixp-neighbors
neighbor-info-list:
- 10.173.176.103
zebra:
config:
enabled: true
url: "unix:/var/run/quagga/zserv.api"
redistribute-route-type-list: []
zebra:
config:
enabled: true
url: "unix:/var/run/quagga/zserv.api"
redistribute-route-type-list:
- static
`redistribute-route-type-list`
Specify from which protocol gobgpd imports routes
defined-sets:
prefix-sets:
- prefix-set-name: my-prefixes
prefix-list:
- ip-prefix: 10.1.0.0/16
policy-definitions:
- name: zebra-import-my-prefixes
statements:
- conditions:
bgp-conditions:
route-type: local
match-prefix-set:
prefix-set: my-prefixes
match-set-options: invert
actions:
route-disposition: reject-route
global:
config:
as: 65001
router-id: 10.1.0.102
apply-policy:
config:
import-policy-list:
- zebra-import-my-prefixes
- tag-ixp-neighbors
default-import-policy: accept-route
This seems to be just a policy change but you still need to restart
gobgpd to get routes injected from zebra installed into BGP RIB
currently a kind of `soft reset in` from zebra is not supported!
If you really dont like to restart gobgpd, then delete/re-add those
static routes in zebra console
and open an issue at GitHub J
neighbors:
- config:
neighbor-address: 10.1.0.101
peer-as: 65001
transport:
config:
local-address: 10.1.0.102
defined-sets:
bgp-defined-sets:
community-sets:
- community-set-name: from-ixp-neighbors
community-list:
- "65001:1000"
policy-definitions:
- name: set-next-hop-self
statements:
- conditions:
bgp-conditions:
match-community-set:
community-set: from-ixp-neighbors
actions:
bgp-actions:
set-next-hop: self
global:
apply-policy:
config:
export-policy-list:
- set-next-hop-self
default-export-policy: accept-route
Caveats: currently after `softresetout` gobgpd will send ALL NLRIs in the
RIB to peers, not only updated NLRIs
Maybe problematic with huge number of prefixes
Open an issue at GitHub :P
neighbors:
- config:
neighbor-address: 10.173.176.211
peer-as: 64686
auth-password: pass65001
defined-sets:
neighbor-sets:
- neighbor-set-name: ixp-neighbors
neighbor-info-list:
- 10.173.176.103
- 10.173.176.211
ASN meaning
0:N Do not advertise to N
64686:N Advertise to N
0:64686 Do not advertise to ANY peer
defined-sets:
neighbor-sets:
- neighbor-set-name: ixp-rs
neighbor-info-list:
- 10.173.176.211
policy-definitions:
- name: rs-no-export-to-as65003
statements:
- conditions:
match-neighbor-set:
neighbor-set: ixp-rs
actions:
bgp-actions:
set-community:
options: add
set-community-method:
communities-list:
- "0:65003"
global:
config:
as: 65001
router-id: 10.1.0.102
apply-policy:
config:
import-policy-list:
- zebra-import-my-prefixes
- tag-ixp-neighbors
default-import-policy: accept-route
export-policy-list:
- set-next-hop-self
- rs-no-export-to-as65003
default-export-policy: accept-route
rpki-servers:
- config:
address: 210.173.170.254
port: 323
Local originating route will not be validated, only received routes are
policy-definitions:
- name: tag-rpki-validation
statements:
- conditions:
bgp-conditions:
rpki-validation-result: valid
actions:
bgp-actions:
set-community:
options: add
set-community-method:
communities-list:
- "65001:2001
# ...
# contd
- conditions:
bgp-conditions:
rpki-validation-result: invalid
actions:
bgp-actions:
set-community:
options: add
set-community-method:
communities-list:
- "65001:2002"
- conditions:
bgp-conditions:
rpki-validation-result: not-found
actions:
bgp-actions:
set-community:
options: add
set-community-method:
communities-list:
- "65001:2003"
global:
apply-policy:
config:
import-policy-list:
- zebra-import-my-prefixes
- tag-ixp-neighbors
- tag-rpki-validation
mrt-dump:
- config:
dump-type: updates
file-name: /tmp/updates.2006-01-02_1504.mrt
rotation-interval: 180
- config:
dump-type: table
file-name: /tmp/table.mrt
dump-interval: 60
g2 $ ls -al /tmp/*.mrt
-rw-r--r-- 1 quagga quagga 1768 Dec 3 11:36 /tmp/table.mrt
-rw-r--r-- 1 quagga quagga 241 Dec 3 11:28 /tmp/updates.2016-12-
03_1128.mrt
-rw-r--r-- 1 quagga quagga 0 Dec 3 11:31 /tmp/updates.2016-12-
03_1131.mrt
-rw-r--r-- 1 quagga quagga 0 Dec 3 11:34 /tmp/updates.2016-12-
03_1134.mrt
bmp-servers:
- config:
address: 10.254.0.250
port: 11019
: (snip)
collector:
config:
url: http://10.254.0.250:8086
db-name: gobgpd
There is a bug!
If you enable this, import policy against zebra will not
work properly