我們今天要來設定 PBR,我們以 Juniper MX 為例
首先,我們要先決定一個 routing-instance,可以把他當作一個獨立的路由表
set routing-instance PBR-WARP instance-type forwarding
set routing-instance PBR-WARP routing-options static route 0.0.0.0/0 next-hop x.x.x.
接著,設定 RIB Group 及路由策略
set routing-options rib-group INT-ROUTES import-rib [ inet.0 PBR-WARP.inet.0 ]
set routing-options interface-routes rib-group inet INT-ROUTES
最後設定路由規則
set firewall family inet filter PBR-WARP term 1 from source-address y.y.y.y/z
set firewall family inet filter PBR-WARP term 1 then routing-instance PBR-WARP-RI
再到網卡介面設定 filter
unit 7 {
vlan-id 700;
family inet {
rpf-check fail-filter rpf-exception;
filter {
input PBR-WARP;
}
address 172.16.0.254/24;
}
}
完成!