Ryu BGPSpeakerの実践活用へのチャレンジ 〜BMPの基本確認編〜
以前、Ryu BGPSpeakerを活用して、OpenFlowベースのBGPルータとして動作するところまで確認できました。
詳細は、slideshareにアップしておきました。
今回は、BGPプロトコルのモニタリング機能を試してみます。
◆BGPネットワーク環境準備
本来、BMPクライアントが動作可能なBGPルータ機器を手に入れるには、金銭面で相当ハードルが高いところです。
ところが、Ryu BGPSpeakerでは、すでに、BMP(BGP Monitoring Protocol)機能が利用できます。
以下に、Ryu BGPSpeakerを活用したBMP環境構築の一例を記載しておきます。
simpleRouter/README.md at v0.4 · ttsubo/simpleRouter · GitHub
◆Ryuアプリ"bmpstation.py"を試してみる
本家、Ryuプロジェクトでは、すでにBMP Serverがリリースされております。
Ryu BMP Server
早速、BMPを動かしてみます。カレントディレクトリに、ryu_bmp.log が保存されます。
確かに、BGPプロトコルのモニタリングは可能みたいですが、知りたい情報が直感的に把握しずらいのが難点です。
(BGPメッセージが実際にやりとりされたタイムスタンプも確認しずらい...)
$ ryu-manager --verbose bmpstation.py loading app bmpstation.py instantiating app bmpstation.py of BMPStation BRICK bmpstation listening on 0.0.0.0:11019 BMP client connected, ip=192.168.0.101, port=57509 2014 Dec 28 08:54:48 | 192.168.0.101 | BMPInitiation(info=[{'type': 0, 'value': u'This is Ryu BGP BMP message', 'len': 27}],len=37,type=4,version=3) 2014 Dec 28 08:54:48 | 192.168.0.101 | BMPPeerUpNotification(is_post_policy=False,len=162,local_address='192.168.201.101',local_port=59505,peer_address='192.168.201.1',peer_as=65001,peer_bgp_id='10.0.0.1',peer_distinguisher=0,peer_type=0,received_open_message=BGPOpen(bgp_identifier='10.0.0.1',hold_time=180,len=53,my_as=65001,opt_param=[BGPOptParamCapabilityMultiprotocol(afi=1,cap_code=1,cap_length=4,length=6,reserved=0,safi=1,type=2), BGPOptParamCapabilityCiscoRouteRefresh(cap_code=128,cap_length=0,length=2,type=2), BGPOptParamCapabilityRouteRefresh(cap_code=2,cap_length=0,length=2,type=2), BGPOptParamCapabilityFourOctetAsNumber(as_number=65001,cap_code=65,cap_length=4,length=6,type=2)],opt_param_len=24,type=1,version=4),remote_port=179,sent_open_message=BGPOpen(bgp_identifier='10.0.1.1',hold_time=40,len=41,my_as=65002,opt_param=[BGPOptParamCapabilityMultiprotocol(afi=1,cap_code=1,cap_length=4,length=6,reserved=0,safi=1,type=2), BGPOptParamCapabilityRouteRefresh(cap_code=2,cap_length=0,length=2,type=2)],opt_param_len=12,type=1,version=4),timestamp=1419720539.120414,type=3,version=3) 2014 Dec 28 08:54:48 | 192.168.0.101 | BMPRouteMonitoring(bgp_update=BGPUpdate(len=54,nlri=[BGPNLRI(addr='192.168.0.0',length=24)],path_attributes=[BGPPathAttributeNextHop(flags=64,length=4,type=3,value='192.168.201.101'), BGPPathAttributeOrigin(flags=64,length=1,type=1,value=2), BGPPathAttributeAsPath(flags=64,length=6,type=2,value=[[65002, 65001]]), BGPPathAttributeMultiExitDisc(flags=128,length=4,type=4,value=100)],total_path_attribute_len=27,type=2,withdrawn_routes=[],withdrawn_routes_len=0),is_post_policy=True,len=102,peer_address='192.168.201.1',peer_as=65001,peer_bgp_id='10.0.0.1',peer_distinguisher=0,peer_type=0,timestamp=1419720540.0,type=0,version=3) 2014 Dec 28 08:54:48 | 192.168.0.101 | BMPRouteMonitoring(bgp_update=BGPUpdate(len=55,nlri=[BGPNLRI(addr='10.0.0.1',length=32)],path_attributes=[BGPPathAttributeNextHop(flags=64,length=4,type=3,value='192.168.201.101'), BGPPathAttributeOrigin(flags=64,length=1,type=1,value=2), BGPPathAttributeAsPath(flags=64,length=6,type=2,value=[[65002, 65001]]), BGPPathAttributeMultiExitDisc(flags=128,length=4,type=4,value=100)],total_path_attribute_len=27,type=2,withdrawn_routes=[],withdrawn_routes_len=0),is_post_policy=True,len=103,peer_address='192.168.201.1',peer_as=65001,peer_bgp_id='10.0.0.1',peer_distinguisher=0,peer_type=0,timestamp=1419720540.0,type=0,version=3) 2014 Dec 28 08:54:48 | 192.168.0.101 | BMPRouteMonitoring(bgp_update=BGPUpdate(len=54,nlri=[BGPNLRI(addr='172.16.101.0',length=24)],path_attributes=[BGPPathAttributeNextHop(flags=64,length=4,type=3,value='192.168.201.101'), BGPPathAttributeOrigin(flags=64,length=1,type=1,value=2), BGPPathAttributeAsPath(flags=64,length=6,type=2,value=[[65002, 65001]]), BGPPathAttributeMultiExitDisc(flags=128,length=4,type=4,value=100)],total_path_attribute_len=27,type=2,withdrawn_routes=[],withdrawn_routes_len=0),is_post_policy=True,len=102,peer_address='192.168.201.1',peer_as=65001,peer_bgp_id='10.0.0.1',peer_distinguisher=0,peer_type=0,timestamp=1419720540.0,type=0,version=3) ... snip
◆自作サンプル"sample_bmpServer.py"を試してみる
本家、RyuプロジェクトのBMP Serverでは、詳細なログ保存としての活用シーンを想定しているみたいです。
手軽にBGP経路情報を確認してみたいという活用シーンでは、ちょっと、つらいところです。
そこで、自作サンプルを試してみます。vpnv4には未対応ですけど。
simpleRouter/sample_bmpServer.py at v0.4 · ttsubo/simpleRouter · GitHub
自分が知りたいBGP経路情報について、直感的に把握しやすいように、表示項目を絞ってみました。
ちなみに、表示項目のタイムスタンプは、BMP情報を受信した時刻ではなく、BGPメッセージ受信時のタイムスタンプを表示しております。
$ cd simpleRouter/other/ $ python sample_bmpServer.py Start BMP session!! [192.168.0.101] 192.168.0.101 | 2014/12/28 07:48:59 65001 10.0.0.1 | BGP_PeerUp 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:192.168.0.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:10.0.0.1/32 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:172.16.101.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:192.168.201.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:172.16.104.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:172.16.102.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:192.168.202.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:0.0.0.0/0 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:172.16.103.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:192.168.100.0/24 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:00 65001 10.0.0.1 | BGP_Update(add_prefix:10.0.0.2/32 , nexthop:192.168.201.101) 192.168.0.101 | 2014/12/28 07:49:04 65002 10.0.1.3 | BGP_PeerUp 192.168.0.101 | 2014/12/28 07:49:05 65002 10.0.1.3 | BGP_Update(add_prefix:192.168.0.0/24 , nexthop:172.16.201.101 ) 192.168.0.101 | 2014/12/28 07:49:05 65002 10.0.1.3 | BGP_Update(add_prefix:172.16.202.0/24 , nexthop:172.16.201.101 ) 192.168.0.101 | 2014/12/28 07:49:05 65002 10.0.1.3 | BGP_Update(add_prefix:10.0.1.3/32 , nexthop:172.16.201.101 ) 192.168.0.101 | 2014/12/28 07:49:05 65002 10.0.1.3 | BGP_Update(add_prefix:172.16.201.0/24 , nexthop:172.16.201.101 ) 192.168.0.101 | 2014/12/28 07:49:05 65002 10.0.1.3 | BGP_Update(add_prefix:192.168.101.0/24 , nexthop:172.16.201.101 ) 192.168.0.101 | 2014/12/28 07:49:05 65002 10.0.1.3 | BGP_Update(add_prefix:172.16.205.0/24 , nexthop:172.16.201.101 )
[追記(2015.3.7)]
Ryu BMPクライアント側でのBGPモニタリング情報の通知内容として、誤ったUPDATEメッセージを送信してしまう場合が発覚しましたが、すでにbug-fix済みです。それに伴い、自作ツールも修正しました。さらにvpnv4にも対応しておりますよ!
simpleRouter/sample_bmpServer.py at master · ttsubo/simpleRouter · GitHub