JUNOSのFilter Base Forwarding
JUNOSでFBFの設定をしてみます。
CiscoでゆうとPBRです。
構成は以下の通り
やりたいことは以下の通り
- R1の1.1.1.1/32からR3の3.3.3.3/32宛はR2のge-0/0/1のリンクを通る
- R1の11.11.11.11/32からR3の3.3.3.3/32宛はR2のge-0/0/2のリンクを通る
- R3からの戻りのトラフィックに関しては気にしない(どちらのリンクを使っても良いい)
設定
1.全てのルータでOSPFを有効にする
#show protocols ospf area 0.0.0.0 { interface all; interface fxp0.0 { disable; } }
2.R2でOSPFネイバーと経路の確認
vmx2_re# run show ospf neighbor Address Interface State ID Pri Dead 192.168.12.1 ge-0/0/0.0 Full 1.1.1.1 128 31 192.168.23.3 ge-0/0/1.0 Full 3.3.3.3 128 33 192.168.32.3 ge-0/0/2.0 Full 3.3.3.3 128 33 vmx2_re# run show route 1.1.1.1 inet.0: 19 destinations, 19 routes (19 active, 0 holddown, 0 hidden) 1.1.1.1/32 *[OSPF/10] 00:11:13, metric 1 > to 192.168.12.1 via ge-0/0/0.0 vmx2_re# run show route 3.3.3.3 inet.0: 19 destinations, 19 routes (19 active, 0 holddown, 0 hidden) 3.3.3.3/32 *[OSPF/10] 00:11:14, metric 1 > to 192.168.23.3 via ge-0/0/1.0 to 192.168.32.3 via ge-0/0/2.0
3.R2でFirewall Filterの設定
- term 1 で source-address 11.11.11.11/32の場合はrouting-instance RI_11.inet.0のルーティングテーブルへ転送する(この時点ではまだRI_11.inet.0は作成していない)
- term 2ではそれ以外のものは許可(term 2が無いと暗黙のdenyされる)
vmx2_re# show firewall family inet { filter FBF { term 1 { from { source-address { 11.11.11.11/32; } } then { routing-instance RI_11; } } term 2 { then { accept; } } } }
4.R2でrouting instanceの設定
- 3.3.3.3/32宛はnext-hop 192.168.32.3へ向ける(ge-0/0/2のリンク)
- instance-typeはforwardingにする。
forwardingとはフィルタベースのフォワーディングをサポートして、
instance-type vrfのようにインターフェースのマップはできない。
vmx2_re# show routing-instances RI_11 { routing-options { static { route 3.3.3.3/32 next-hop 192.168.32.3; } } instance-type forwarding; }
5.R2でrouting-optionの設定
- interface-routeを rib-group FBF-32へ
- rib-group FBF-32はinet.0をRI_11.inet.0へimportする
vmx2_re# show routing-instances interface-routes { rib-group inet FBF-32; } rib-groups { FBF-32 { import-rib [ inet.0 RI_11.inet.0 ]; } }
6.R2で経路の確認
- RI_11で3.3.3.3/32のネクストホップが192.168.32.2(ge-0/0/2)になっていること
を確認
vmx2_re> show route 3.3.3.3 inet.0: 19 destinations, 19 routes (19 active, 0 holddown, 0 hidden) 3.3.3.3/32 *[OSPF/10] 00:33:08, metric 1 > to 192.168.23.3 via ge-0/0/1.0 to 192.168.32.3 via ge-0/0/2.0 RI_11.inet.0: 8 destinations, 8 routes (8 active, 0 holddown, 0 hidden) 3.3.3.3/32 *[Static/5] 00:17:13 > to 192.168.32.3 via ge-0/0/2.0
7.トラフィックを流して確認してみる
- 送信元1.1.1.1からトラフィックを流してge-0/0/1を通っていることを確認する
R1で # ping 3.3.3.3 source 1.1.1.1 rapid count 10000
R2で # monitor interface traffic を実行
- ge-0/0/1を通っていることを確認する(ge-0/0/2は通っていないこと)
vmx2_re> monitor interface traffic Interface Link Input packets (pps) Output packets (pps) ge-0/0/0 Up 40301 (324) 40315 (324) ge-0/0/1 Up 40298 (324) 27308 (324) ge-0/0/2 Up 3759 (0) 16800 (0)
- 送信元11.11.11.11からトラフィックを流してge-0/0/2を通っていることを確認する
R1で # ping 3.3.3.3 source 11.11.11.11 rapid count 10000
R2で # monitor interface traffic を実行
- ge-0/0/2を通っていることを確認する(output側のみ)
vmx2_re> monitor interface traffic Interface Link Input packets (pps) Output packets (pps) ge-0/0/0 Up 51466 (306) 51479 (306) ge-0/0/1 Up 51461 (306) 36084 (0) ge-0/0/2 Up 3800 (0) 19229 (306)