noharaのブログ

インフラエンジニアのブログ、ゆる~く

gobgp同士でebgp接続

gobgpのバイナリを落としてきてebgp接続するまでの手順

構成図

                      192.168.33.0/24
    AS65001                                AS65002
+----------------+                   +----------------+
|                |      ebgp         |                |
|                |  <------------>   |                |
|                |.21             .22|                |
|                +-------------------+                |
+----------------+                   +----------------+

wgetでバイナリを落とす

両ノードで以下のコマン打つ

$ wget https://github.com/osrg/gobgp/releases/download/v1.33/gobgp_1.33_linux_amd64.tar.gz
$ tar xzf gobgp_1.33_linux_amd64.tar.gz

gobgpd.confを書く

.21側

[global.config]
  as = 65001
  router-id = "192.168.33.21"

[[neighbors]]
  [neighbors.config]
    neighbor-address = "192.168.33.22"
    peer-as = 65002

.22側

[global.config]
  as = 65002
  router-id = "192.168.33.22"

[[neighbors]]
  [neighbors.config]
    neighbor-address = "192.168.33.21"
    peer-as = 65001

gobgpを起動する

両ノードで以下のコマンドを打つ

$  sudo -E ./gobgpd -f gobgpd.conf

動作確認

ネイバーが確立されている

$ ./gobgp neighbor
Peer             AS  Up/Down State       |#Received  Accepted
192.168.33.22 65002 00:03:01 Establ      |        0         0

keepaliveは30秒間隔

sudo tcpdump -i enp0s8 tcp port bgp -n
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on enp0s8, link-type EN10MB (Ethernet), capture size 262144 bytes
07:51:45.797742 IP 192.168.33.21.bgp > 192.168.33.22.57554: Flags [P.], seq 2993027708:2993027727, ack 2208320632, win 114, options [nop,nop,TS val 293637 ecr 6968370], length 19: BGP
07:51:45.798091 IP 192.168.33.22.57554 > 192.168.33.21.bgp: Flags [.], ack 19, win 115, options [nop,nop,TS val 6998159 ecr 293637], length 0
07:51:46.008469 IP 192.168.33.22.57554 > 192.168.33.21.bgp: Flags [P.], seq 1:20, ack 19, win 115, options [nop,nop,TS val 6998369 ecr 293637], length 19: BGP
07:51:46.008552 IP 192.168.33.21.bgp > 192.168.33.22.57554: Flags [.], ack 20, win 114, options [nop,nop,TS val 293848 ecr 6998369], length 0

07:53:15.798364 IP 192.168.33.21.bgp > 192.168.33.22.57554: Flags [P.], seq 57:76, ack 58, win 114, options [nop,nop,TS val 383638 ecr 7058370], length 19: BGP
07:53:15.798969 IP 192.168.33.22.57554 > 192.168.33.21.bgp: Flags [.], ack 76, win 115, options [nop,nop,TS val 7088114 ecr 383638], length 0
07:53:16.053562 IP 192.168.33.22.57554 > 192.168.33.21.bgp: Flags [P.], seq 58:77, ack 76, win 115, options [nop,nop,TS val 7088369 ecr 383638], length 19: BGP
07:53:16.053599 IP 192.168.33.21.bgp > 192.168.33.22.57554: Flags [.], ack 77, win 114, options [nop,nop,TS val 383893 ecr 7088369], length 0

07:52:45.797160 IP 192.168.33.21.bgp > 192.168.33.22.57554: Flags [P.], seq 38:57, ack 39, win 114, options [nop,nop,TS val 353637 ecr 7028370], length 19: BGP
07:52:45.797508 IP 192.168.33.22.57554 > 192.168.33.21.bgp: Flags [.], ack 57, win 115, options [nop,nop,TS val 7058128 ecr 353637], length 0
07:52:46.040236 IP 192.168.33.22.57554 > 192.168.33.21.bgp: Flags [P.], seq 39:58, ack 57, win 115, options [nop,nop,TS val 7058370 ecr 353637], length 19: BGP
07:52:46.040318 IP 192.168.33.21.bgp > 192.168.33.22.57554: Flags [.], ack 58, win 114, options [nop,nop,TS val 353880 ecr 7058370], length 0

動作環境

$ cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
$ ./gobgp --version
gobgp version 1.33