Upload
tomoya-hibi
View
1.617
Download
0
Embed Size (px)
Citation preview
Copyright©2014 NTT corp. All Rights Reserved.
Lagopusで試すFirewall
OpenFlow1.3で実現する
FW運用のテストツール試作
2015/09/29
hibitomo
1 Copyright©2014 NTT corp. All Rights Reserved.
はじめに
今回の内容はTremaday#7で発表した内容+αです.
Tremadayでのリクエストにお応えして,ACLのテスト駆動をデモします.
2 Copyright©2014 NTT corp. All Rights Reserved.
Agenda
Lagopus/OpenFlowについて
お約束
TremaDayの内容
聞いたことある人はごめんなさい
テスト駆動なFW
アーキテクチャ
Ryu certificationと おまじない
デモ
3 Copyright©2014 NTT corp. All Rights Reserved.
コントローラ
SDN?OpenFlow?Lagopus?
レガシーなネットワーク装置
ルータ
コントロールプレーン
データプレーン
ファイアーウォール
コントロールプレーン
データプレーン
ロードバランサ
コントロールプレーン
データプレーン
SDN
スイッチ
データプレーン
スイッチ
データプレーン
スイッチ
コントロールプレーン
データプレーン
アプリ
コントローラ
コントロールプレーン
アプリ
プログラマブルAPI
OpenFlowプロトコル
4 Copyright©2014 NTT corp. All Rights Reserved.
OpenFlow?
どういうパケットだったら
受信ポート番号,パケットヘッダの値(宛先,ソース,各種ID...)
どういう処理をする
パケットヘッダの追加,削除,編集
転送(ユニキャスト,マルチキャスト,ロードバランシング...)
コントローラにパケットを転送して処理も可能
OpenFlow コントローラ
コントロールプレーン
OpenFlow プロトコル
OpenFlow スイッチ
データプレーン
Flow Table
フローパターン アクション
フローパターン アクション カウンター
カウンター
Flow Table #2
Flow Table #3
Flow Table #4
5 Copyright©2014 NTT corp. All Rights Reserved.
Lagopus
OpenFlowスイッチのソフトウェア実装
汎用x86サーバで動作可能
高速なパケット処理と幅広いプロトコルに対応
> 10Gbps
OpenFlow仕様に幅広く対応
OpenFlow コントローラ
コントロールプレーン
OpenFlow プロトコル
OpenFlow スイッチ
データプレーン
Flow Table
フローパターン アクション
フローパターン アクション カウンター
カウンター
Flow Table #2
Flow Table #3
Flow Table #4
6 Copyright©2014 NTT corp. All Rights Reserved.
ユースケースの例
SDN Japan 2014での実証実験
アクセスポイント
■ A Pの識別(V LA N )
■ V ID毎にQoS制御
PoEスイッチ
インターネット
アクセスポイント( AP)
La g op u sの役割
7 Copyright©2014 NTT corp. All Rights Reserved.
オープンソース
2014年7月31日に公開
http://lagopus.github.io/
開発への参加
コードの提供 -> GitHub Pull Request
バグレポート -> GitHub Issues
議論 -> Developers ML
8 Copyright©2014 NTT corp. All Rights Reserved.
Copyright©2014 NTT corp. All Rights Reserved.
Lagopusで試すFirewall
OpenFlow1.3で実現する
FW運用のテストツール試作
2015/09/29
hibitomo
10 Copyright©2014 NTT corp. All Rights Reserved.
ところで
ご覧になったことありますか?
@stereocatさん, Tremaday #4
http://www.slideshare.net/stereocat55/tremafirewall
11 Copyright©2014 NTT corp. All Rights Reserved.
@stereocatさんのスライドです
http://www.slideshare.net/stereocat55/tremafirewall
12 Copyright©2014 NTT corp. All Rights Reserved.
@stereocatさんのスライドです
http://www.slideshare.net/stereocat55/tremafirewall
13 Copyright©2014 NTT corp. All Rights Reserved.
@stereocatさんのスライドです
http://www.slideshare.net/stereocat55/tremafirewall
14 Copyright©2014 NTT corp. All Rights Reserved.
ところで,,,,
実装はOpenFlow1.0ベース
RangeはBitmaskでどう表現するの???
そもそもL4はbitmask掛けれない...
FWをOpenFlowで表現するのは無理?
簡単なテストにしか使えない?
Copyright©2014 NTT corp. All Rights Reserved.
Lagopusで試すFirewall
OpenFlow1.3で実現する
FW運用のテストツール試作
Copyright©2014 NTT corp. All Rights Reserved.
Lagopusで試すFirewall
OpenFlow1.3で実現する
FW運用のテストツール試作
ココが違う
17 Copyright©2014 NTT corp. All Rights Reserved.
Agenda
OpenFlow1.3で実現するFirewall
Range表記のbitmask変換
TCP/UDPポートのmask適用方法
実装(テーブル設計)
FW運用のテストツール試作
Ryu Certificationの流用
おまじない
デモ
18 Copyright©2014 NTT corp. All Rights Reserved.
Agenda
OpenFlow1.3で実現するFirewall
Range表記のbitmask変換
TCP/UDPポートのmask適用方法
実装(テーブル設計)
FW運用のテストツール試作
Ryu Certificationの流用
おまじない
デモ
19 Copyright©2014 NTT corp. All Rights Reserved.
Rangeの表記どうする?
そもそもTCAMで検索できているはず
TCAMは{0,1,don’t care}で検索
RangeもTCAMで検索しているなら,Lagopusでも検索できるはず.
再起アルゴリズムで
Range -> Bitmask表記のルールに変換
20 Copyright©2014 NTT corp. All Rights Reserved.
例題
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0110 ~ 1111 をbitmaskのルールに分割
21 Copyright©2014 NTT corp. All Rights Reserved.
例題
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
0110 ~ 1111 をbitmaskのルールに分割
22 Copyright©2014 NTT corp. All Rights Reserved.
Algorithm 簡単(?)に
1. ****が範囲に含まれるかチェック
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
****
23 Copyright©2014 NTT corp. All Rights Reserved.
Algorithm 簡単(?)に
2. ****の範囲を2つに分割
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1*** 0***
24 Copyright©2014 NTT corp. All Rights Reserved.
Algorithm 簡単(?)に
3. 1***はRangeに含まれる
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1*** 0***
25 Copyright©2014 NTT corp. All Rights Reserved.
Algorithm 簡単(?)に
2’. 0***を2つに分割
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1*** 00** 01**
26 Copyright©2014 NTT corp. All Rights Reserved.
Algorithm 簡単(?)に
2’’. 01**を2つに分割
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
00** 010* 1*** 011*
27 Copyright©2014 NTT corp. All Rights Reserved.
Algorithm 簡単(?)に
2’’. 01**を2つに分割
0 1 0 1 0 1
0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
00** 010* 1*** 011*
0110 ~ 1111 で表されるレンジは,{011*, 1***}で表されるルールの集合でちょうどカバー出来る.
28 Copyright©2014 NTT corp. All Rights Reserved.
Agenda
OpenFlow1.3で実現するFirewall
Range表記のbitmask変換
TCP/UDPポートのmask適用方法
実装(テーブル設計)
FW運用のテストツール試作
Ryu Certificationの流用
おまじない
デモ
29 Copyright©2014 NTT corp. All Rights Reserved.
TCP/UDPポートのmask適用方法
Metadataにコピーする
しかし,Copy_Fieldは未対応....
Metadata (64bit) L4 src L4 dst
30 Copyright©2014 NTT corp. All Rights Reserved.
TCP/UDPポートのmask適用方法
単純に書きくだす.
※ルール数が65536 * 2 * 2 = 26万
for i in range(0, 65535): # SRC for ip_proto in [6, 17] : flow = {"table_id":0,"priority":1000, "actions":[{"type":"WRITE_METADATA","metadata":i << 16, "metadata_mask":0x00000000FFFF0000}], "match":{"dl_type":2048,"ip_proto":ip_proto,"tp_src":i}} mod_flow_entry(datapath, flow, ofproto.OFPFC_ADD) # DST ...
31 Copyright©2014 NTT corp. All Rights Reserved.
Lagopusなら動く
Lagopusならなんとかしてくれる.
私の戦闘力は 100万です.
32 Copyright©2014 NTT corp. All Rights Reserved.
その他の手
リアクティブに登録しても実現できる
1. TCP/UDPパケットが来たらPacket-In
2. ポート番号のメタデータコピーのルール追加
未登録のPort番号であれば,Packet-In
Port番号コピーのルール+ Packet-Out
コントローラ
スイッチ
データプレーン
コントロールプレーン
33 Copyright©2014 NTT corp. All Rights Reserved.
Agenda
OpenFlow1.3で実現するFirewall
Rangeの表記どうする?
TCP/UDPポートどうする?
実装(テーブル設計)
FW運用のテストツール試作
Ryu Certificationの流用
おまじない
デモ
34 Copyright©2014 NTT corp. All Rights Reserved.
実装
テーブル設計
table 0:
L4 srcポートをmetadataにコピー(32~16bitに)
table 1:
L4 dstポートをmetadataにコピー (16~0bitに)
table 2:
Range -> Bitmask変換したルール群投入
マッチしたら落とす or OUTPUT
or Next table (他のアプリケーション)
35 Copyright©2014 NTT corp. All Rights Reserved.
実装
Table 0のルール例
{'priority': 1000, 'table_id': 0, 'match': {'dl_type': 2048, 'ip_proto': 6, 'tp_src': 5}, 'actions': [ {'metadata_mask': 4294901760, ‘type': 'WRITE_METADATA', 'metadata': 327680} ] }
0xFFFF0000
UDP/TCP両方で ルール登録
0x00050000
36 Copyright©2014 NTT corp. All Rights Reserved.
実装
Table 1のルール例
{'priority': 1000, 'table_id': 1, 'match': {'dl_type': 2048, 'ip_proto': 17, 'tp_dst': 8}, 'actions': [ {'metadata_mask': 65535, 'type': 'WRITE_METADATA', 'metadata': 8} ] }
37 Copyright©2014 NTT corp. All Rights Reserved.
実装
Table 2のルール例
(アドレスに意味はありません)
{"table_id":2,"priority":65535,"cookie":0, "actions":[], "match":{ "dl_type":2048, "ipv4_src":“192.168.1.10/255.255.255.240", "ipv4_dst":“192.168.1.171/255.255.255.240", "ip_proto":17, "metadata":"0x0000000000580050/0x00000000ffffffff"} }
38 Copyright©2014 NTT corp. All Rights Reserved.
その他メリット
ルールの追加/削除が動的に出来ます.
priorityをちゃんと考えれば.
他のアプリと組み合わせられます.
テーブル設計の競合注意
QoSも出来る
ステートは持てない.
速いかも?(試してない)
39 Copyright©2014 NTT corp. All Rights Reserved.
Agenda
OpenFlow1.3で実現するFirewall
Rangeの表記どうする?
TCP/UDPポートどうする?
実装(テーブル設計)
FW運用のテストツール試作
Ryu Certificationの流用
おまじない
デモ
40 Copyright©2014 NTT corp. All Rights Reserved.
再掲
http://www.slideshare.net/stereocat55/tremafirewall
41 Copyright©2014 NTT corp. All Rights Reserved.
再掲
http://www.slideshare.net/stereocat55/tremafirewall
ここまでの内容
ここからの内容
42 Copyright©2014 NTT corp. All Rights Reserved.
Ryu Certification
SDN Framework ‘Ryu’のSwitchテストツール
スイッチのOpenFlow仕様への準拠の度合いを検証する
テストパターンはJSONで記述
http://osrg.github.io/ryu-book/ja/html/switch_test_tool.html
43 Copyright©2014 NTT corp. All Rights Reserved.
Ryu Certification
SDN Framework ‘Ryu’のSwitchテストツール
スイッチのOpenFlow仕様への準拠の度合いを検証する
テストパターンはJSONで記述
http://osrg.github.io/ryu-book/ja/html/switch_test_tool.html
44 Copyright©2014 NTT corp. All Rights Reserved.
Ryu Certification
SDN Framework ‘Ryu’のSwitchテストツール
スイッチのOpenFlow仕様への準拠の度合いを検証する
テストパターンはJSONで記述
http://osrg.github.io/ryu-book/ja/html/switch_test_tool.html
固定
45 Copyright©2014 NTT corp. All Rights Reserved.
Ryu Certification
SDN Framework ‘Ryu’のSwitchテストツール
スイッチのOpenFlow仕様への準拠の度合いを検証する
テストパターンはJSONで記述
http://osrg.github.io/ryu-book/ja/html/switch_test_tool.html
固定
または未達検知
46 Copyright©2014 NTT corp. All Rights Reserved.
こうか!
Lagopus FW
補助SW 試験対象SW
Ryu Certification
テストパターン ファイル
ACL
(1)パケットインのみの フローエントリ登録
(2)パケット印加
(3)パケットイン 又は未達検知
47 Copyright©2014 NTT corp. All Rights Reserved.
未達検知のおまじない
--- /usr/local/lib/python2.7/dist-packages/ryu/tests/switch/tester.py 2015-01-16 11:41:22.000000000 +0900 +++ tester.py 2015-09-29 14:26:26.706239312 +0900 @@ -789,11 +789,7 @@ before = before_stats[target_tbl_id] after = rcv_msgs[target_tbl_id] if before['lookup'] < after['lookup']: - lookup = True - if before['matched'] < after['matched']: - raise TestFailure(self.state) - if not lookup: - raise TestError(self.state) + raise TestFailure(self.state)
48 Copyright©2014 NTT corp. All Rights Reserved.
テストパターンファイルの記述
ACCEPT
[ "test1", { "description":"allow sample test", "prerequisite":[ ### match -> in_port:1, action -> output:4294967293 ### ], “tests”:[ { “ingress”:[ ### テストしたいパケット ### ],
“PACKET_IN”:[ ### ingressと同じ ### ] } ] } ]
Packet_In
49 Copyright©2014 NTT corp. All Rights Reserved.
テストパターンファイルの記述
DROP
[ "test1", { "description":"allow sample test", "prerequisite":[ ### match -> in_port:1, action -> output:4294967293 ### ], “tests”:[ { “ingress”:[ ### テストしたいパケット ### ], “table-miss”:[ 0 ] } ] } ]
Packet_In
50 Copyright©2014 NTT corp. All Rights Reserved.
デモ
51 Copyright©2014 NTT corp. All Rights Reserved.
出力
--- Test start --- waiting for switches connection... dpid=0000000000000001 : Join target SW. dpid=0000000000000002 : Join tester SW. Network Test 1 test1-1 OK Network Test 2 ACCEPT sample test OK DROP sample test ERROR Table-miss error: increment in matched_count. --- Test end --- --- Test report --- Table-miss error(1) Network Test 2 DROP sample test OK(2) / ERROR(1)
Testログ
Summary
52 Copyright©2014 NTT corp. All Rights Reserved.
その他の利点
同じアーキテクチャで他のNW機器もテスト可
descriptionを書きましょう(※重要)
いろいろなプロトコルのテスト可能 VLAN
MPLS
PBB
転送,破棄以外のテストも可能 QoS
Broadcast
53 Copyright©2014 NTT corp. All Rights Reserved.
まとめ
Lagopus (OpenFlow1.3) でL3/L4のパケットフィルタを実現.
Ryu Certificationを利用して,パケットフィルタのテストを実現.
54 Copyright©2014 NTT corp. All Rights Reserved.
Thank you for your attention
This research is a part of the project for “Research and Development of Network Virtualization Technology” supported by the Ministry of Internal Affairs and Communications.