LoginSignup
22
19

More than 5 years have passed since last update.

インターネットのフルルートをGoBGPからVyOSに注入してみた

Last updated at Posted at 2016-05-03

インターネットのフルルート(59万経路)をVyOSにGoBGP経由で注入してみました。VyOSとGoBGP間でBGPピアを張り、GoBGPにフルルートを注入し、GoBGPからVyOSにフルルートを広報しました。

本記事はインターネットのフルルートをGoBGPで注入してみたの続きです。GoBGPのインストールやフルルートの注入方法は割愛していますので、前回の記事を参照してください。

関連投稿
その1:インターネットのフルルートをGoBGPで注入してみた
その2:インターネットのフルルートをGoBGPからVyOSに注入してみた(本記事)

はじめに

インターネットのフルルートと戯れたくて、自宅でフルルートを取り扱う方法を探して、記事としてまとめました。
VyOSには直接MRTデータを注入できないため、高速なGoBGPして注入・広報しています。

vyos1.png
図. フルルートの注入・広報

環境

BGPのフルルート注入は下記の環境で実施しました。

  • Intel NUC, NUC5i5RY(Core i5-5250U)
  • Oracle VM VirtualBox 5.0.18
    • 仮想マシン:gobgp(xenial1)ホストにメモリ4GB割当(gobgpdで結構メモリ使います)
    • 仮想マシン:vyos(helium1)ホストにメモリ2GB割当
    • シリアルポート1を有効化しています
  • gobgp(xenial1仮想マシン)
    • Ubuntu 16.04 LTS(ubuntu-16.04-server-amd64.iso)
    • Golang 1.6
    • GoBGP v1.6
    • IPアドレス:192.168.88.121/24
    • BGP AS番号:AS65121
  • vyos(helium1仮想マシン)
    • VyOS (helium) 1.1.7(vyos-1.1.7-amd64.iso)
    • IPアドレス:192.168.88.122/24
    • BGP AS番号:AS65122

Screenshot from 2016-05-03 18-50-11.png
図. vyos(helium1仮想マシン)の設定

VyOSの設定

VyOSのインストール方法はユーザーガード - VyOS jpを参照してください。
今回はinstall systemで内蔵ディスクにインストールしています。

下記の通り、IPアドレスの設定とBGPピアの設定をします。

# VyOSのバージョン
vyos@vyos:~$ show version
Version:      VyOS 1.1.7
Description:  VyOS 1.1.7 (helium)
Copyright:    2016 VyOS maintainers and contributors
Built by:     maintainers@vyos.net
Built on:     Wed Feb 17 09:57:31 UTC 2016
Build ID:     1602170957-4459750
System type:  x86 64-bit
Boot via:     image
Hypervisor:   KVM
HW model:     VirtualBox
HW S/N:       0
HW UUID:      5A0EB465-F756-40D7-919A-F804911A72F7
Uptime:       07:57:21 up 10 min,  2 users,  load average: 0.00, 0.02, 0.02

# 設定モード
vyos@vyos:~$ configure

# IPアドレスとSSHの設定
vyos@vyos# set interfaces ethernet eth0 address 192.168.88.122/24
vyos@vyos# set service ssh

# BGPピアの設定
vyos@vyos# set protocols bgp 65122 parameters router-id 192.168.88.122
vyos@vyos# set protocols bgp 65122 neighbor 192.168.88.121 remote-as 65121
vyos@vyos# set protocols bgp 65122 neighbor 192.168.88.121 soft-reconfiguration inbound

# 設定反映
vyos@vyos# commit
vyos@vyos# save
vyos@vyos# exit

GoBGPの設定

固定IPアドレスを設定し、vyosとBGPピアを張る設定で、GoBGPを起動します。

# IPアドレスの変更、インタフェース名はenp0s3
kooshin@gobgp:~$ sudo ifdown enp0s3
kooshin@gobgp:~$ sudo -H vi /etc/network/interfaces
auto enp0s3
iface enp0s3 inet static
    address 192.168.88.121
    netmask 255.255.255.0
    gateway 192.168.88.1
    dns-nameserver 192.168.88.1
kooshin@gobgp:~$ sudo ifup enp0s3

# GoBGPの設定ファイル作成
kooshin@gobgp:~$ cat <<EOF > gobgpd.conf
[global.config]
  as = 65121
  router-id = "192.168.88.121"

[[neighbors]]
[neighbors.config]
  neighbor-address = "192.168.88.122"
  peer-as = 65122
EOF

# GoBGPの起動
kooshin@gobgp:~$ sudo $HOME/go/bin/gobgpd -f gobgpd.conf
{"level":"info","msg":"gobgpd started","time":"2016-05-03T17:08:47+09:00"}
{"level":"info","msg":"finished reading the config file","time":"2016-05-03T17:08:47+09:00"}
{"level":"info","msg":"Peer 192.168.88.122 is added","time":"2016-05-03T17:08:47+09:00"}
{"level":"info","msg":"Add a peer configuration for 192.168.88.122","time":"2016-05-03T17:08:47+09:00"}
{"Key":"192.168.88.122","State":"BGP_FSM_OPENCONFIRM","Topic":"Peer","level":"info","msg":"Peer Up","time":"2016-05-03T17:09:02+09:00"}

GoBGPにフルルートの注入

前回の記事と同様の方法で、GoBGPにフルルートを注入します。
今回はvyos - gobgp間でBGPピアを張った状態のため、2倍の180秒程度時間がかかっています。

kooshin@gobgp:~$ time gobgp mrt inject global rib.20160502.1400

real    2m37.165s
user    0m13.076s
sys     0m4.696s

VyOSのネクストホップの設定

GoBGPでフルルートを注入し終わって、VyOSでshow ip bgp summaryを実行すると下記のとおりとなります。
MsgRcvd列を確認すると、フルルートに近い59万経路(メッセージ)を受信していることがわかります。しかしながら、State/PfxRcd列を確認すると0となります。
原因は、GoBGPから経路広報する際に、ネクストホップがMRTデータのまま広報されるためです。VyOSでネクストホップに到達できないと判断され、VyOSのBGPテーブルに反映されないことが原因です。

vyos@vyos:~$ show ip bgp summary 
BGP router identifier 192.168.88.122, local AS number 65122
IPv4 Unicast - max multipaths: ebgp 1 ibgp 1
RIB entries 1081447, using 99 MiB of memory
Peers 1, using 4560 bytes of memory

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.88.121  4 65121  590583★    28        0    0    0 00:10:50        0★

Total number of neighbors 1

このままではネクストホップに到達できないため、BGPテーブルに反映されません。
今回はVyOSでダミーのIPアドレス202.248.2.1/24を割当、到達できるように見せかけます。
ダミーのIPアドレスを割り当ててもBGPテーブルに反映されないため、BGPソフトリセットを実施します。

# ダミーインタフェースにIPアドレスを割当
vyos@vyos:~$ configure
vyos@vyos# set interfaces dummy dum1 address 202.249.2.1/24
vyos@vyos# commit
vyos@vyos# exit

## BGPのソフトリセット
vyos@vyos:~$ reset ip bgp 192.168.88.121 soft in 
vyos@vyos:~$ show ip bgp summary 
BGP router identifier 192.168.88.122, local AS number 65122
IPv4 Unicast - max multipaths: ebgp 1 ibgp 1
RIB entries 1081447, using 99 MiB of memory
Peers 1, using 4560 bytes of memory

Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.168.88.121  4 65121  590584      29        0    0    0 00:11:11   590558★

Total number of neighbors 1

実行結果

GoBGPでは確認できるコマンドが限られていましたが、VyOSでは各種のコマンドでフルルートの経路確認ができます。

# BGPテーブルのフルルートを20行表示
vyos@vyos:~$ show ip bgp | head -n20
BGP table version is 0, local router ID is 192.168.88.122
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 1.0.4.0/24       202.249.2.169                          0 65121 7500 2497 4637 1221 38803 56203 i
*> 1.0.5.0/24       202.249.2.169                          0 65121 7500 2497 4637 1221 38803 56203 i
*> 1.0.6.0/24       202.249.2.169                          0 65121 7500 2497 4637 1221 38803 56203 56203 56203 i
*> 1.0.38.0/24      202.249.2.169                          0 65121 2497 10026 24155 i
*> 1.0.64.0/18      202.249.2.169                          0 65121 2497 7670 7670 7670 18144 i
*> 1.0.128.0/17     202.249.2.169                          0 65121 2497 38040 9737 i
*> 1.0.128.0/18     202.249.2.169                          0 65121 2497 38040 9737 i
*> 1.0.128.0/19     202.249.2.169                          0 65121 2497 38040 9737 i
*> 1.0.128.0/24     202.249.2.169                          0 65121 2497 38040 9737 23969 i
*> 1.0.129.0/24     202.249.2.169                          0 65121 7500 2497 38040 9737 23969 i
*> 1.0.139.0/24     202.249.2.169                          0 65121 7500 2497 38040 9737 23969 i
*> 1.0.142.0/24     202.249.2.169                          0 65121 7500 2497 38040 9737 23969 i
*> 1.0.144.0/20     202.249.2.169                          0 65121 2497 38040 9737 23969 i
*> 1.0.160.0/19     202.249.2.169                          0 65121 2497 38040 9737 i

# RIBのフルルートを20行表示
vyos@vyos:~$ show ip route | head -n20
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF,
       I - ISIS, B - BGP, > - selected route, * - FIB route

B>* 1.0.4.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.5.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.6.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.38.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.64.0/18 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.128.0/17 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.128.0/18 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.128.0/19 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.128.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.129.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.139.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.142.0/24 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.144.0/20 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.160.0/19 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.160.0/21 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.168.0/21 [20/0] via 202.249.2.169, dum1, 00:06:35
B>* 1.0.176.0/20 [20/0] via 202.249.2.169, dum1, 00:06:35

# IPアドレスをRIBで確認
vyos@vyos:~$ show ip route 8.8.8.8
Routing entry for 8.8.8.0/24
  Known via "bgp", distance 20, metric 0, best
  Last update 00:16:21 ago
  * 202.249.2.169, via dum1

# IPアドレスをBGPテーブルで確認
vyos@vyos:~$ show ip bgp 8.8.8.8
BGP routing table entry for 8.8.8.0/24
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  65121 2497 15169
    202.249.2.169 from 192.168.88.121 (192.168.88.121)
      Origin IGP, localpref 100, valid, external, best
      Last update: Tue May  3 08:20:09 2016

# Origin ASがAS15169を10行だけ表示
vyos@vyos:~$ show ip bgp regexp _15169$ | head 
BGP table version is 0, local router ID is 192.168.88.122
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 8.8.4.0/24       202.249.2.169                          0 65121 2497 15169 i
*> 8.8.8.0/24       202.249.2.169                          0 65121 2497 15169 i
*> 8.34.208.0/21    202.249.2.169                          0 65121 2497 15169 i
*> 8.34.216.0/21    202.249.2.169                          0 65121 2497 15169 i

# Origin ASがAS2510を10行だけ表示
vyos@vyos:~$ show ip bgp regexp _2510$ | head 
BGP table version is 0, local router ID is 192.168.88.122
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, R Removed
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 58.0.0.0/15      202.249.2.169                          0 65121 2497 2510 i
*> 61.121.0.0/17    202.249.2.169                          0 65121 2497 2510 i
*> 61.124.0.0/16    202.249.2.169                          0 65121 2497 2510 i
*> 61.210.0.0/16    202.249.2.169                          0 65121 2497 2510 i

VyOSのメモリ消費

VyOSは全体として820MB程度を消費しています。内、bgpdが314MB、zebraが199Mを消費しています。

Screenshot from 2016-05-03 17-30-55.png
図. VyOS上のtop画面

おわりに

今回はGoBGPにフルルートを注入し、GoBGPからVyOSにフルルートを広報しました。
VyOSで1ピアからフルルートを受け取る場合に必要なメモリは1GB程度あれば良いことがわかりました。

付録

GoBGPのコンフィグ

[global.config]
  as = 65121
  router-id = "192.168.88.121"

[[neighbors]]
[neighbors.config]
  neighbor-address = "192.168.88.122"
  peer-as = 65122

VyOSのコンフィグ

vyos@vyos:~$ show configuration 
interfaces {
    dummy dum1 {
        address 202.249.2.1/24
    }
    ethernet eth0 {
        address 192.168.88.122/24
        hw-id 08:00:27:59:cb:85
    }
    loopback lo {
    }
}
protocols {
    bgp 65122 {
        neighbor 192.168.88.121 {
            remote-as 65121
            soft-reconfiguration {
                inbound
            }
        }
        parameters {
            router-id 192.168.88.122
        }
    }
}
service {
    ssh {
    }
}
system {
    config-management {
        commit-revisions 20
    }
    console {
        device ttyS0 {
            speed 9600
        }
    }
    login {
        user vyos {
            authentication {
                encrypted-password ****************
                plaintext-password ****************
            }
            level admin
        }
    }
    ntp {
        server 0.pool.ntp.org {
        }
        server 1.pool.ntp.org {
        }
        server 2.pool.ntp.org {
        }
    }
    package {
        repository community {
            components main
            distribution helium
            url http://packages.vyos.net/vyos
        }
    }
    syslog {
        global {
            facility all {
                level notice
            }
            facility protocols {
                level debug
            }
        }
    }
}
22
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
19