BGP アトリビュート別に、Juniper(Junos)でどう設定するか をまとめます。
Contents
BGP アトリビュートの Juniper 設定一覧(概要)
| 属性 | 役割 | Juniper の設定方法 |
|---|---|---|
| Local Preference | AS 内の出口選択 | set policy-options policy-statement ... then local-preference xx |
| MED(Multi Exit Disc) | 隣接 AS に対し経路優先度を提示 | set policy-options policy-statement ... then metric xx |
| AS-PATH | 経路の通過 AS の一覧 | set policy-options as-path ... によるマッチと then as-path-prepend で操作 |
| Weight(Cisco特有) | Juniper には無し | Juniperでは local-preference で代替 |
| Origin | IGP/EGP/Incomplete | Junos では明示設定不可(再配布経路の扱いで決まる) |
| Community | 属性タグ付け | set policy-options policy-statement ... then community add ... |
| Extended Community / RT | VPNv4/EVPNなど | VRF で route-target を設定 |
ここから詳細設定例
1. Local Preference(ローカルプリファレンス)
▶ 目的
AS 内で 出口ルータの優先度を決める(値が大きい方が優先)。
✔ 設定例(受信経路に LocalPref を付ける)
set policy-options policy-statement SET-LP term 1 from neighbor 10.1.1.1
set policy-options policy-statement SET-LP term 1 then local-preference 200
set policy-options policy-statement SET-LP then accept
set protocols bgp group EBGP import SET-LP
2. MED(Metric)
▶ 目的
隣接 AS に対して、「この出口から入ってきてほしい」という優先度を提示する
(値が小さい方が優先)
✔ 設定例(広告する経路の MED を変更)
set policy-options policy-statement SET-MED term 1 then metric 50
set policy-options policy-statement SET-MED then accept
set protocols bgp group EBGP export SET-MED
3. AS-PATH(プリペンドなど)
✔ AS-PATH をマッチさせる
set policy-options as-path TRANSIT "65001 .*"
✔ AS-PATH プリペンド(自ASを重ねる)
set policy-options policy-statement PREPEND term 1 from route-filter 0.0.0.0/0 exact
set policy-options policy-statement PREPEND term 1 then as-path-prepend "65010 65010 65010"
set policy-options policy-statement PREPEND then accept
set protocols bgp group EBGP export PREPEND
4. Community
✔ Community の定義
set policy-options community BLACKHOLE members 65535:666
✔ Community を付与(例えば Blackhole)
set policy-options policy-statement ADD-COM term 1 from route-filter 192.168.0.0/24 exact
set policy-options policy-statement ADD-COM term 1 then community add BLACKHOLE
set policy-options policy-statement ADD-COM then accept
set protocols bgp group EBGP export ADD-COM
5. Origin(IGP / EGP / Incomplete)
Juniper では Cisco のように明示的に origin を設定できない。
origin は次のように決まる:
| 経路の種類 | Origin |
|---|---|
| network もしくは IF 直結扱い | IGP |
| aggregate(aggregate route) | IGP |
| 再配布(static, connected, ospf, etc) | incomplete |
ただし policy で rewrite(変更)することは不可。
6. NEXT HOP(次ホップ)
✔ NEXT-HOP 属性の変更
set policy-options policy-statement NEXT-HOP-SET term 1 then next-hop 10.10.10.1
set policy-options policy-statement NEXT-HOP-SET then accept
set protocols bgp group EBGP export NEXT-HOP-SET
eBGP → iBGP 再配布時などによく使う。
7. Extended Community(Route Target)
▶ VRF / L3VPN で利用
set routing-instances VRF-A instance-type vrf
set routing-instances VRF-A interface ge-0/0/0.100
set routing-instances VRF-A route-distinguisher 65010:10
set routing-instances VRF-A vrf-target import 65010:100
set routing-instances VRF-A vrf-target export 65010:100
8. すべての主要アトリビュートを使った実例
set policy-options community PREF-HIGH members 65010:10
set policy-options policy-statement FULL-POLICY term 1 from route-filter 10.10.0.0/16 orlonger
set policy-options policy-statement FULL-POLICY term 1 then {
local-preference 200;
metric 50;
community add PREF-HIGH;
as-path-prepend "65010 65010";
next-hop 192.168.100.1;
}
set policy-options policy-statement FULL-POLICY then accept
set protocols bgp group EBGP export FULL-POLICY