JUNOS Workshop
モジュールの offline/online
Section titled “モジュールの offline/online”Juniper 製品の一部モジュールは交換前にオフラインし、交換後にオンラインにする
CLI@juniper > request chassis fpc ?Possible completions:offline Take FPC offlineonline Bring FPC onlinerestart Restart FPCslot FPC slot number (0..1)ルータの reboot ・ shutdown コマンド
Section titled “ルータの reboot ・ shutdown コマンド”system を停止する場合、必ず shutdown コマンドを実行して下さい FreeBSD を採用しているため、shutdown 後の電源 OFF を推奨しております。 最悪の場合、ファイルシステムが壊れ正常な Boot ができなくなる可能性があります。 ※ Juniper スイッチ製品は内部的に boot device を冗長し、耐久性を向上させています
CLI@juniper > request system rebootReboot the system ? [yes,no] (no)
CLI@juniper > request system haltHalt the system ? [yes,no] (no)
CLI@juniper > request system halt both-routing-engine /// RE冗長時に、同時にshutdownするOption ///Online Document の参照
Section titled “Online Document の参照”Help syslog ログの参考情報を確認
{master}nelco@MX240> show log messages<snip>Jan 23 01:31:35 MX240 login: LOGIN_INFORMATION: User nelco logged in from host 10.9.100.112 on device ttyp0
nelco@MX240> help syslog LOGIN_INFORMATIONName: LOGIN_INFORMATIONMessage: User <username> logged in from host <hostname> on device <tty-name>Help: User was authenticated and logged in Description: The indicated username was authenticated and logged into the shell specified for it in the password file.Type: Event: This message reports an event, not an errorSeverity: info今いる階層から他の階層の show/edit
Section titled “今いる階層から他の階層の show/edit”[edit chassis alarm]CLI@Juniper# top show interfaces lo0 unit 0family inet {address 1.1.1.54/32;}
[edit chassis alarm]CLI@Juniper# top edit protocols ospftop で単発 delete するとすべての config が削除される
CLI#Juniper# deleteConfiguration Mode から Operational Mode コマンドの実行
Section titled “Configuration Mode から Operational Mode コマンドの実行”[edit]CLI@juniper# run ping 10.0.0.1 count 10[edit]CLI@juniper# run show configurations[edit]CLI@juniper# run show interfaces terse今いる階層から他の階層への移動
Section titled “今いる階層から他の階層への移動”TOP 階層に移動する
[edit interfaces ge-0/0/0]CLI@juniper # top[edit]CLI@juniper #1 階層上に移動する
[edit interfaces ge-0/0/0]CLI@juniper # up 1{master:0}[edit interfaces]CLI@juniper #50 世代分のコンフィグレーションファイルを保存
Section titled “50 世代分のコンフィグレーションファイルを保存”スタートアップコンフィグ及びランニングコンフィグの区別はなく /config/juniper.conf.gz が Active になる唯一の有効なコンフィグレーション・ファイル 保存先は下記
- /config juniper.conf.gz、juniper.conf.[1-3]
- /var/db/config juniper.conf.[4-49].gz
write memory は不要で commit だけで良い
{master:0}[edit]nelco@EX4550# commitconfiguration check succeedscommit complete[edit]nelco@MX240# commit synchronizere0:configuration check succeedsre1:commit completere0:commit complete設定の反映チェック
Section titled “設定の反映チェック”構文チェック、設定矛盾の確認のみを行います。{master:0}[edit]
nelco@EX4550# commit checkconfiguration check succeeds設定差分の確認(Candidate と Activate コンフィグの差分確認)
Section titled “設定差分の確認(Candidate と Activate コンフィグの差分確認)”Top で行わないと入っている階層の差分しか出ないので注意が必要 +:追加設定内容 -:削除設定内容
CLI@Juniper# show | compare+address 1.1.1.55/32;-address 1.1.1.54/32;設定差分の確認(過去コンフィグとの差分確認)
Section titled “設定差分の確認(過去コンフィグとの差分確認)”CLI@Juniper# show | compare rollback 1+ aggregated-devices {+ ethernet {+ device-count 3;+ }+ }RollBack 機能について
Section titled “RollBack 機能について”過去の設定環境に戻す際に、50 世代分まで遡っての再設定がコマンドにより可能 Rollback “ X”で指定した世代の config を candidate configuration として呼び戻す ※0 もしくは数字なしは現在の Activate Configuration を Candidate Configuration として反映させる (configure に入る前に戻る)
nelco@EX4550# rollback ?Possible completions:<[Enter]> Execute this command0 2015-05-18 09:53:21 UTC by nelco via cli1 2015-05-18 09:53:17 UTC by nelco via cli commit confirmed, rollback in 2minsPipe を使用することで出力形式の変更やフィルタ等が可能 (Operation/ Configuration Mode)
Section titled “Pipe を使用することで出力形式の変更やフィルタ等が可能 (Operation/ Configuration Mode)”“ | no-more” コマンドの最後まで出力させる “ | find” 最初にマッチしたパターンから表示 “ | match” パターンにマッチした行を表示 ” | refresh 3” int ごとに watch みたいな感じで repeat できる ” | last” tail みたいな感じができる
例show log messages | last 10 | refresh 3set コマンドベースの表示
Section titled “set コマンドベースの表示”[edit protocols rip]CLI# show | display setset protocols rip group 1 export default-to-ripset protocols rip group 1 neighbor ge-0/0/0.251Root アカウントは必ず初期設定が必要
Section titled “Root アカウントは必ず初期設定が必要”工場出荷時に設定されているユーザで Default パスワードは未設定 Password は、6~128 文字の間で指定(英数字の組み合わせ)
- 初回 commit 時に設定する必要あり
nelco@MX480-112# set system root-authentication plain-text-passwordNew password:Retype new password:{master}[edit]nelco@MX480-112#nelco@MX480-112# commitcommit completenelco@M7i-43# show systemroot-authentication {encrypted-password "$1$H2jtPh9I$uy.JH5zVapzJ8zmOAKCJo."; ## SECRET-DATA}ルータ名の設定
Section titled “ルータ名の設定”lab@EX4200-2# set system host-name EX4200-2
ドメイン名の設定
Section titled “ドメイン名の設定”lab@EX4200-2# set system domain-name nissho-ele.co.jp
DNS サーバの設定
Section titled “DNS サーバの設定”ルータがクエリーするための Server 複数の Server を指定可能 lab@EX4200-2# set system name-server 192.168.0.1 lab@EX4200-2# set system name-server 192.168.0.2
NTP Server の設定
Section titled “NTP Server の設定”Server 同期の条件は下記で、条件外では” > set date “コマンドを使用
ab@EX4200-2# set system ntp server 10.9.100.202lab@EX4200-2# run show ntp associationsremoterefidst t when poll reach delay offset jitter========================================================================*10.9.100.202 133.243.238.163 2 - 146 1024 377 51.613 25.951 25.204Time-zone 設定
Section titled “Time-zone 設定”set system time-zone Asia/Tokyolab@EX4200-2# run show system uptimefpc0:--------------------------------------------------------------------------Current time: 2017-05-01 19:07:31 JSTLC2101 (100G/40G モジュール) の speed を port ごとに設定。 この設定を変更する場合は PIC 単位で offline/online が必要で、該当 PIC でポートがリンクアップしている場合は down/up が発生するため注意。
fpc 0 { pic 0 { port 0 { speed 100g; } port 1 { speed 100g; } port 2 { speed 100g; } port 3 { speed 100g; } } : :}GRES (Graceful Routing Switchover) / NSR
Section titled “GRES (Graceful Routing Switchover) / NSR”RE 冗長されている場合に、どちらかの RE で障害が発生してもスイッチオーバー中にパケット転送を継続する機能。 IF とカーネルの情報を保持し、トラフィックを中断させないが、コントロールプレーンは保持しない。 標準では backup RE で rpd (ルーティングプロトコルを制御するプロセス) が起動していないため、スッチオーバー中に新しい primary RE で rpd が再起動する (= neighbor down/up などが発生する)。 backup RE でも rpd を起動し、primary RE の rpd と常に同期することで、対応しているルーティングプロトコルの down/up を防止する NSR (Nonstop active routing) という機能がある。 OSPF(v3), BGP は NSR サポート対象なので、agmx では NSR を有効化している (routing-options の階層の設定)。 詳細: https://www.juniper.net/documentation/us/en/software/junos/high-availability/topics/topic-map/gres-understanding.html https://www.juniper.net/documentation/us/en/software/junos/high-availability/topics/topic-map/nonstop-active-routing-understanding.html GRES と NSR の補足: Nexus 7000/7700 だと特に何も設定しなくても SUP を 2 枚さしていれば switchover 時にプロトコルが継続する動きをしますが (たまにうまくいってないですが)、 Junos だと GRES/NSR という機能を明示的に設定することによってはじめてその動作が有効になります。
routing-options { nonstop-routing; # NSR}apply-path
Section titled “apply-path”prefix-list で既存の設定から値を持ってくる show configuration policy-options prefix-list ntp-servers | display inheritance のように叩くと、apply-path でなんの prefix が展開されたかを確認できます
prefix-list ntp-servers { 127.0.0.1/32; apply-path "system ntp server <*>";}port-id-subtype interface-name は設定しておかないと、対向側から見た時に IF 名が index になりわからなくなるため必要。
lldp { port-id-subtype interface-name; interface all;}syslog の facility, severity
Section titled “syslog の facility, severity”| facility | 内容 |
|---|---|
| any | 全カテゴリ |
| authorization | 認証と権限関連 |
| change-log | 設定変更 |
| conflict-log | ハードウェアと一致しない設定 |
| daemon | プロセスの処理、エラー等 |
| firewall | firewall filter のログ |
| ftp | ftp プロセスのログ |
| interactive-commands | CLI に入力されたコマンド |
| kernel | kernel の処理、エラー等 |
| pfe | pfe の処理、エラー等 |
| user | ユーザープロセスの処理やエラー等 |
| severity | 内容 |
|---|---|
| any | 全てのメッセージ |
| none | 設定された facility のログ出力を停止 |
| emergency | 機能停止に陥るような重大な問題 |
| alert | データベースが破損するなど、対処が必要なレベル |
| critical | ハードディスクエラー等、クリティカルな状態 |
| erro | 上3つほど深刻ではないが、エラーが発生している状態 |
| warning | 監視が必要な状態 |
| notice | エラーではないが、留意する必要がある |
| info | 通常のイベントログやエラー以外の状態 |
管理/アクセス用の Port を有効にする
Section titled “管理/アクセス用の Port を有効にする”デフォルトでは、セキュリティのため Telnet や Ftp 等の管理 Port は無効になっている set system services ftp set system services ssh set system services telnet connection-limit 5
Interface Name
Section titled “Interface Name”MX シリーズは基本的に以下のルールです ge- [FPC num] / [PIC num] / [port num] [FPC num]:ラインカードのスロット番号 [PIC num]:ラインカード内の PIC(PFE)番号 [port num]:PIC 内の port 番号 ex) ge-3/2/9 ge = Media Type を表す 3 = MPC の Slot 番号を表す 2 = MPC 内の PIC 番号を表す 9 = PIC 内の Port 番号を表す
ge-0/0/0 の interface に 10.0.0.1/24 を設定する場合
Section titled “ge-0/0/0 の interface に 10.0.0.1/24 を設定する場合”set interfaces ge-0/0/0 unit 0 family inet address 10.0.0.1/24nelco@MX2010-K1-RE0-191# show interfaces ge-0/0/0unit 0 { family inet { address 10.0.0.1/24; }}xe-0/0/1 の interface に VLAN10 で IP 10.0.0.1/24 を設定する場合
Section titled “xe-0/0/1 の interface に VLAN10 で IP 10.0.0.1/24 を設定する場合”set interfaces xe-0/0/1 unit 10 vlan-id 10set interfaces xe-0/0/1 unit 10 family inet address 10.0.0.1/24nelco@MX2010-K1-RE0-191# show interfaces ge-0/0/0vlan-id 10;unit 10 { /// vlan-id を設定する場合は必ずunit 番号が0以外。Unit番号=vlan-idである必要はない /// family inet { address 10.0.0.1/24; }}デフォルトで各ルーティングテーブル内で、同一経路を様々なプロトコルで学習した際にルートリファレンスを使用して決定する
Section titled “デフォルトで各ルーティングテーブル内で、同一経路を様々なプロトコルで学習した際にルートリファレンスを使用して決定する”※たとえば BGP より OSPF が優先されるので複雑なネットワークではプリファレンスの管理が重要 0 = Directly connected 5 = Static routes 7 = RSVP 9 = LDP 10 = OSPF internal 15 = IS-IS L1 internal 18 = IS-IS L2 internal 100 = RIP 130 = Aggregate or generated 150 = OSPF external 160 = IS-IS L1 external 165 = IS-IS L2 external 170 = BGP
ルーティングテーブルの見方
Section titled “ルーティングテーブルの見方”10.1.0.0/24 は Direct、OSPF の両方から学習しているが、Direct の優先度が 0 で High Priority のため、選択されている
nelco@M120-52> show routeinet.0: 10 destinations, 10 routes (10 active, 0 holddown, 0 hidden)+ = Active Route, - = Last Active, * = Both
10.1.0.0/24 *[Direct/0] 05:02:19 > via ge-3/0/1.0 [OSPF/10] 05:01:44, metric 1 > via ge-3/0/1.010.1.0.52/32 *[Local/0] 05:02:19 Local via ge-3/0/1.010.2.0.0/24 *[OSPF/10] 05:01:32, metric 2 > to 10.1.0.28 via ge-3/0/1.0Static Route について
Section titled “Static Route について”手動で設定する基本的なルートで設定の仕方は 2 種類 1.ネクストホップに IP を指定する場合
- ネクストホップがアクティブになればルーティングテーブルに登録される
2.ネクストホップに IP を指定しない場合
- この場合パケットは転送されるためでなく、パケットをルータ内部でドロップ(廃棄)するためのもの
- Reject :ICMP Unreachable メッセージをパケット送出元の返す
- Discard :ICMP Unreachable メッセージをパケット送出元の返さない
# set routing-options static route [destination-address] next-hop [next-hop address]# set routing-options rib inet6.0 static route [destination-address] next-hop [next-hop address]IPv4 の基本的なコンフィグレーションについて
Section titled “IPv4 の基本的なコンフィグレーションについて”*10.9.0.0/16 に対して next-hop 10.9.144.253 で設定する場合 set routing-options static route 10.9.0.0/16 next-hop 10.9.144.253 *1.0.0.0/24 に対して next-hop discard で設定する場合 set routing-options static route 1.0.0.0/24 discard *2.0.0.0/24 に対して next-hop reject で設定する場合 set routing-options static route 2.0.0.0/24 reject
OSPF Overview
Section titled “OSPF Overview”AS 内部での経路交換を目的とし、広く一般的に使われております 本プロトコルは下記の手順を踏んで経路交換を行います
- LSA と呼ばれるリンクステート(各ルータのインタフェース情報)を交換
- 交換結果から LSDB(経路情報の一覧)を作成
- LSDB より SPF アルゴリズムで目的値までの最短パスを計算
OSPF 内での役割によってルータのタイプがある
Section titled “OSPF 内での役割によってルータのタイプがある”- バックボーンルータ
- エリア0の内部にあるルータ
- エリア0以外はインターナルルータ
- エリアボーダルータ(ABR)
- 他のエリアと隣接しているルータ
- AS ボーダルータ(ASBR)
- OSPF ドメイン以外からルート情報を注入するルータ
LSDB は OSPF ルータで共通
Section titled “LSDB は OSPF ルータで共通”情報の正確性を保てる一方で、大きなネットワークではリンクステート情報が増えてしまい、LSDB が巨大になってしまう そのため、コンバージェンスや性能の低い装置があった場合は学習できないといったパフォーマンスの問題が発生する可能性がある
OSPF ネットワーク内をエリアという概念で区分
Section titled “OSPF ネットワーク内をエリアという概念で区分”これによりエリア毎での LSA の送受信範囲を制限することで、学習容量を抑制し先述の問題を解消できる
OSPF Packet Type
Section titled “OSPF Packet Type”5 種類の Packet Type を使用して LSDB を構築
- Hello
OSPF Neighbor の探索(224.0.0.5)を行い、死活監視にも利用されます 中には、Interval 情報なども含まれます
- Database Description
自身の保持する LSDB を広報し、OSPF neighbor と LSDB の差分確認を行います
- Link-State Request
差分があった際に、その差分情報のアップデートをリクエストします
- Link-State Update
リクストがあった際に、差分情報のアップデートを行います
- Link-State Acknowledgment
差分情報を受け取ったら返事を行います
シンルグエリアでの設定
Section titled “シンルグエリアでの設定”基本的に area 番号と所属 IF を指定するだけで動作します また interface 指定時は論理ユニットまで指定できます ※未指定時は必ず.0(unit 0)で、VLAN IF での OSPF 利用時などは.1(unit1) , .2(unit 2)と指定が重要となります
set protocols ospf area [area-id] interface [interface]Sample)set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface ge-0/0/12.0マルチエリアでの設定
Section titled “マルチエリアでの設定”シングルエリアと同様に area 番号と所属 IF を指定するだけで動作します ※ passive 設定を追加することで、経路情報は交換されますが Hello は送信されません
set protocols ospf area [area-id] interface [interface]Sample)set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface ge-0/0/12.0set protocols ospf area 0.0.0.1 interface ge-0/0/13.0シングル、マルチエリアでの設定
Section titled “シングル、マルチエリアでの設定”OSPF と同じ設定方法にて実現ができます 後述するオプション設定に関しても OSPF と同様の設定手法となります ※ LSA 管理のために 32bit の source ID が必要となるため、追加で後述の router-ID が必要 です。ただ、lo0 に IPv4 設定があればそれを利用するため未設定でも動作します
set protocols ospf3 area [area-id] interface [interface]Sample)set protocols ospf3 area 0.0.0.0 interface lo0.0 passiveset protocols ospf3 area 0.0.0.0 interface ge-0/0/12.0set protocols ospf3 area 0.0.0.1 interface ge-0/0/13.0ルータ ID の設定
Section titled “ルータ ID の設定”DR の選択や LSA の source として使用し、未設定の場合は lo0 のアドレスを使用 ※ ルータ(DR/BDR)の選定基準
- プライオリティ:大きい方 ※同じ場合は次の基準であるルータ ID で確認
- ルータ ID:大きい方
set routing-options router-id [router-id]Sample) set routing-options router-id 10.10.10.1Priority の設定
Section titled “Priority の設定”DR の選定に使用され、デフォルトでは 128 を使用する ※0 として設定した場合は DR の選定候補から外れる
set protocols ospf area [area-id] interface [interface] priority [priority]Sample) set protocols ospf area 0 interface ge-0/0/0 priority 200メトリック(リンクコスト)の設定
Section titled “メトリック(リンクコスト)の設定”その Link に対するコスト値を設定し経路をコントロールする set protocols ospf area [area-id] interface [interface] metric [metric] Sample) set protocols ospf area 0 interface ge-0/0/0 metric 100
Authentication-OSPF
Section titled “Authentication-OSPF”隣接関係の認証で、simple か md5 を選択する
lab@R1-110# set protocols ospf area 0 interface ge-0/0/0 authentication ?Possible completions:+ apply-groups Groups from which to inherit configuration data+ apply-groups-except Don't inherit configuration data from these groups> md5 MD5 authentication keysimple-password Authentication keyスタブエリア、NSSA の設定について
Section titled “スタブエリア、NSSA の設定について”Stub エリアや NSSA の ABR として動作するには、ABR の設定に stub または nssa のコマンドを追加します
nelco@M120-52# show protocol ospfarea 0.0.0.0 { interface ge-1/0/0.0;}area 0.0.0.1 { stub; /// NSSAならばNSSAと変更 /// interface so-0/0/0.0;}stub エリア、nssa に default ルートをアドバタイズするためには以下のコマンド入力します(default ルートの metric を 10 に設定)
nelco@M120-52# set protocols ospf area 1 stub default-metric 10基本的な設定と接続の確認(OSPF)
Section titled “基本的な設定と接続の確認(OSPF)”ab@R1-110# show protocols ospfexport static-to-ospf;area 0.0.0.0 { interface lo0.0 { passive; } interface ge-0/0/12.0;}
lab@R1-110# run show ospf neighborAddress Interface State ID Pri Dead10.10.0.2 ge-0/0/12.0 Full 10.10.10.2 128 38
lab@R1-110# run show ospf interfaceInterface State Area DR ID BDR ID Nbrsge-0/0/12.0 DR 0.0.0.0 10.10.10.1 10.10.10.2 1lo0.0 DRother 0.0.0.0 0.0.0.0 0.0.0.0 0LSDB の確認(OSPF)
Section titled “LSDB の確認(OSPF)”user@host> show ospf databaseOSPF link state database, Area 0.0.0.1 Type ID Adv Rtr Seq Age Opt Cksum LenRouter 10.255.70.103 10.255.70.103 0x80000002 215 0x20 0x4112 48Router *10.255.71.242 10.255.71.242 0x80000002 214 0x20 0x11b1 48Summary *23.1.1.0 10.255.71.242 0x80000002 172 0x20 0x6d72 28Summary *24.1.1.0 10.255.71.242 0x80000002 177 0x20 0x607e 28NSSA *33.1.1.1 10.255.71.242 0x80000002 217 0x20 0x73bd 36BGP overview
Section titled “BGP overview”AS 間で経路交換を行うためのプロトコル AS(NW 上の同ポリシーにて運用される NW)間を接続していくため、インターネットの中で重要なルーテイングプロトコル PATH ベクター型ルーティングプロトコルのため、交換される経路がどのような AS パスを通過したかを記録されループせずにネットワークがつくられる BGP は AS 間と AS 内で 2 種類の接続形態が用意されている EBGP :AS 間を接続し、BGP 経路を交換する IBGP :AS 内を接続し、BGP 経路を交換する デフォルトの BGP アドバタイズルール ルーティングテーブル内のアクティブな BGP 経路のみをアドバタイズする ✓ eBGP ピアから受信したルート情報を iBGP ピアへ送信 ✓ eBGP ピアから受信したルート情報を eBGP ピアへ送信 ✓ iBGP ピアから受信したルート情報を eBGP ピアへ送信 アドバタイズ不可な BGP 経路について ✓ iBGP ピアから受信したルート情報を iBGP ピアへ送信 これを回避するため iBGP ピアは基本的にフルメッシュでピアリングする その他の経路について ✓ スタティックルートや IGP で学習したルートは policy-options 機能を利用して再配信が可能
BGP Attribute
Section titled “BGP Attribute”代表的な Attribute は下記
- Next Hop
- Local Preference
- AS path
- Origin
- MED
- Community
Next Hop について
Section titled “Next Hop について”トラフィックを送信する next hop IP address を示し、これを解決した経路情報が ルーティングテーブル上の Next-Hop となる ・ eBGP :Peer 接続された隣接ルータの IP アドレスが Next hop として広報される ・ iBGP :対向ルータが学習している IP アドレスのまま広報される →一般的には、対向ルータが外部 AS から学習した経路の Next hop
Local Preference について
Section titled “Local Preference について”iBGP の間で使用され、他の AS に伝達されることはないため、自 AS からのトラ フィックの出口を決定する ✓ LP 値が高いほど優先され、BGP の経路選択基準のなかで一番最初に比較さ れるため AS path 長等に関係なく強制的に経路選択させることができる
AS Path について
Section titled “AS Path について”該当経路がどのような AS を通過するかを管理することで、ループを抑制する また通過する AS パスが多いほど(実際の装置の hop 数ではない)非優先の経路として扱われる
Origin について
Section titled “Origin について”IGP(0) :経路情報を AS 内から学習したことを示す EGP(1) :経路情報を AS 外から学習したことを示す Incomplete(2) :経路情報を上記以外から学習したことを示す
MED について
Section titled “MED について”複数の eBGP ピアから同じルートアドバタイズされたときに、AS へのトラフィック優先度を決定するために使用し、低い値が優先される ・経路広報時:相手 AS から自 AS へのトラフィックを制御 ・経路受信時:自 AS から相手 AS へのトラフィックを制御
Community について
Section titled “Community について”BGP の送信情報に tag(識別情報)をつけ、それを元に経路の統一的なコントロールを行うことができる ✓ 値は 4octet で、前の 2octet に自分の AS 番号を、後ろ 2octet は適当な数字を入れる使われ方が多い。(例 100:1) Well-known community として以下のように定義されているものもある ✓ No-export :直接接続の AS へは広報するが、その先の AS へは広報しない(0xFFFFFF01) ✓ No-Advertise :直接接続の Peer へは広報するが、その先の AS 内部 Peer へも広報しないようにする(0xFFFFFF02)
BGP 経路選択ルール
Section titled “BGP 経路選択ルール”BGP ネクストホップへの IP 到達性がある(前提)
- Local-preference の値が最も大きいものを優先します。
- AS パス長が最短のものを優先する。
- origin の値が最も小さいものを優先する。
- MED の値が最も小さいものを優先する。
- IBGP ピアより EBGP ピアから学習した経路を優先する。
- AS からの最良の出口を優先する。
- EBGP で受信した経路は、現在アクティブになっている経路を優先する。
- Router ID が最も小さいピアからの経路を優先する。
- クラスタ長が最も短い経路を優先する。
- ピア IP アドレスが最も小さいピアからの経路を優先する。
eBGP の設定について
Section titled “eBGP の設定について”一般的に eBGP は接続 IF のリンクアドレスを使用して接続 AS 番号の指定 set routing-options autonomous-system [as-number] BGP の設定 set protocols bgp group [group-name] type external set protocols bgp group [group-name] peer-as [peer-as] set protocols bgp group [group-name] neighbor [peer-ip]
iBGP の設定について
Section titled “iBGP の設定について”一般的に iBGP は耐障害性を考慮し loopback address を使用して接続されます AS 番号の指定 set routing-options autonomous-system [as-number] BGP の設定 set protocols bgp group [group-name] type internal set protocols bgp group [group-name] local-address [local-ip] set protocols bgp group [group-name] neighbor [peer-ip]
NLRI(Network Layer Reachability Information)の設定について
Section titled “NLRI(Network Layer Reachability Information)の設定について”BGP では、該当 neighbor とどのようなプロトコル(IPv4,IPV6,VPN など)経路を交換するかの確認に NLRI を使用する 本 NLRI を変更することで Multi Protocol-BGP が実現される 基本的には L3VPN/L2VPN に使用する場合に必要
nelco@MX80-97# set protocols bgp family ?Possible completions:> evpn EVPN NLRI parameters> inet IPv4 NLRI parameters> inet-mdt IPv4 Multicast Distribution Tree (MDT) NLRI parameters> inet-mvpn IPv4 MVPN NLRI parameters> inet-vpn IPv4 Layer 3 VPN NLRI parameters> inet6 IPv6 NLRI parameters---snip---BGP update で意図しない NLRI を受信した際に BGP peer が flap するのを防止するためには以下の設定を入れる https://supportportal.juniper.net/s/article/2023-08-29-Out-of-Cycle-Security-Bulletin-Junos-OS-and-Junos-OS-Evolved-A-crafted-BGP-UPDATE-message-allows-a-remote-attacker-to-de-peer-reset-BGP-sessions-CVE-2023-4481?language=en_US
bgp { bgp-error-tolerance;}4byte AS の設定について
Section titled “4byte AS の設定について”JUNOS9.1 以降で 4byte AS をサポートしている ただし、2byte AS のみサポートしているルータと接続する際に 4byte AS の capability を無効化しないと Peer が張れない場合がある この場合は、該当する BGP group に disable-4byte-as を設定することで解消される
nelco@M7i-122# show protocolsbgp { group ebgp { disable-4byte-as; }}BGP のオプション設定
Section titled “BGP のオプション設定”log-updown について
Section titled “log-updown について”Peer が Down/up した場合に Syslog に記述されるようにする
lab@R1-110# set protocols bgp log-updownAuthentication の設定
Section titled “Authentication の設定”ネイバーとの MD5 認証を可能とする
nelco@MX80-97# set protocols bgp group ibgp authentication-key junipernelco@MX80-97# show protocols bgp group ibgpauthentication-key “$9$rOjKWxbs4Di.Ndi.P56/lKM”; ## SECRET-DATA /// 自動で暗号化される///Hold-time について
Section titled “Hold-time について”ネイバーとの Hold-Time を変更する場合に設定する デフォルトは 90sec で 3 ~ 65535sec まで設定可能
nelco@M7i-122# show protocolsbgp { group ibgp { hold-time 20; }}Advertise-inactive について
Section titled “Advertise-inactive について”BGP 経路が active ルートでない場合でも peer にルートを送信することができる 例えば、OSPF と BGP で同経路を学習していると、通常 OSPF がプロトコルプリファレンスの関係から優先経路になるため BGP 経路は inactive になってしまい配信されない場合などの対策
nelco@M7i-122# show protocolsbgp { advertise-inactive;}送受信経路の確認
Section titled “送受信経路の確認”対象ピアからの受信経路確認
lab@R1-110# run show route receive-protocol bgp 192.168.40.2inet.0: 18 destinations, 18 routes (18 active, 0 holddown, 0 hidden)Prefix Nexthop MED Lclpref AS path\* 130.0.0.0/24 192.168.40.2 400 300 I\* 130.0.1.0/24 192.168.40.2 400 300 I\* 140.0.0.0/24 192.168.40.2 0 400 I\* 140.0.1.0/24 192.168.40.2 400 I対象ピアへの送信経路を確認
lab@R1-110# run show route advertising-protocol bgp 192.168.40.2inet.0: 18 destinations, 20 routes (18 active, 0 holddown, 0 hidden)Prefix Nexthop MED Lclpref AS path\* 110.0.0.0/24 Self I\* 110.0.1.0/24 Self 0 I\* 120.0.0.0/24 Self 200 I\* 120.0.1.0/24 Self 200 Iルーティングポリシーについて
Section titled “ルーティングポリシーについて”JUNOS では経路の管理を全てルーティングポリシーにて実行します ルーティングポリシーは 2 種類のフィールドによってルールを作成し、作成したルールを各プロトコルに適用させ、通常とは異なる動作を実現します そのため、下記のような通常のプロトコル動作に対して変更を加えたいときに本機能を使用します
- プロトコルから学習した経路を選択してルーティングテーブルに反映したいとき
- 学習した経路全てをネイバーにアドバタイズしたくないとき
- 他のプロトコルからあるプロトコルへ経路を再配送するとき
- 経路に付属する情報を変更したいとき
デフォルトポリシーについて
Section titled “デフォルトポリシーについて”各プロトコルでの一般的な動作がデフォルトポリシーとなる そのため、これらの変更を行うことがルーティングポリシーの目的となる
- OSPF/IS-IS
- そのプロトコルから受信する全ての経路を Import する
- そのプロトコル自身から学習した経路を Export する
- そのプロトコルが動作しているインタフェースの IP サブネット(Direct の経路)を Export する
- BGP
- BGP ネイバーから学習した全ての経路を Import する
- BGP ネイバーから学習した Active な(Routing Table 上で) BGP 経路を BGP ネイバーに Export する
暗黙に頼ると分かりづらいので、match condition (from) なしで reject か permit か書くのがおすすめ
policy-statement ospf3-export { term reject { then reject; }}ルーティングポリシーの作成について
Section titled “ルーティングポリシーの作成について”下記のように from と then をセットで設定していくことで設定ができる set policy-options policy-statement [policy-name] term [term name] from [match condition] set policy-options policy-statement [policy-name] term [term name] then [action] Sample) set policy-options policy-statement static-to-ospf term 1 from protocol static set policy-options policy-statement static-to-ospf term 1 from route-filter 110.0.0.0/24 orlonger set policy-options policy-statement static-to-ospf term 1 then accept set policy-options policy-statement static-to-ospf term 2 then reject 各プロトコルの in/out で適用する set protocols ospf export [policy-name] set protocols ospf import [policy-name] set protocols bgp import [policy-name] set protocols bgp export [policy-name] set protocols bgp group [group-name] import [policy-name] set protocols bgp group [group-name] export [policy-name] set protocols bgp group [group-name] neighbor [peer-ip] import [policy-name] set protocols bgp group [group-name] neighbor [peer-ip] export [policy-name] Sample) set protocols ospf export static-to-ospf set protocols bgp group ibgp export self set protocols bgp group ebgp export export-to-ebgp
複数のポリシー適用時は左から順番に参照される
Section titled “複数のポリシー適用時は左から順番に参照される”下記のサンプルでは policy 1→2→3 の順番に評価される 各ポリシー内に複数の term があった場合は上から順番に評価される つまり、policy2 で評価したい経路が policy1 で評価されると想定した通信設計ができない恐れがあるため適用される順番が非常に重要 ✓ 追加で設定した内容は全て一番右側(最後に評価)に登録される
ospf { export [ policy-name1 policy-name2 policy-name3 ]; import policy-name;}コマンドによる順番の入れ替え
Section titled “コマンドによる順番の入れ替え”本コマンドにより順番を入れ替え、意図した設計に変更することができる #insert policy-options policy-statement [policy-name] term [変更対象] ‘ before|after’ term [変更先] ※ before で変更先のひとつ前の term、after で変更先の一つ後に移動できる
Route-filter 機能を使用し特定経路に、policy を適用する場合に有効
Section titled “Route-filter 機能を使用し特定経路に、policy を適用する場合に有効”条件(from)文中にて他の条件と併用することが多く、下記の状況で使用する ➢ 特定の経路に関しては、import しない ➢ 特定の経路に関して、付加属性(情報)を与えて広報したい etc Prefix を指定する条件文は 2 種類用意されている ➢ route-filter ✓ Policy-statement 中に prefix 群を記述 ✓ サブネットマスクの値が可変 ➢ prefix-list ✓ Policy-option 配下の prefix-list 中に prefix を記述 ✓ サブネットマスクの値は不変(exact match)
static route を OSPF に再配信する場合
Section titled “static route を OSPF に再配信する場合”Static 110.0.0.0/24 に完全一致する経路を OPSF に再配信する
policy-options { policy-statement static-to-ospf { term 1 { from { protocol static; route-filter 110.0.0.0/24 exact; } then accept; } }}protocols ospf { export static-to-ospf;}ab@R1-110# run show route 110.0.0.0/24inet.0: 18 destinations, 20 routes (18 active, 0 holddown, 0 hidden)+ = Active Route, - = Last Active, * = Both110.0.0.0/24 *[Static/5] 21:11:16 DiscardOSPF でデフォルトルートを originate 設定
Section titled “OSPF でデフォルトルートを originate 設定”デフォルトルートを OSPF に再配信する
routing-options { static { route 0.0.0.0/0 discard; }}protocols { ospf { **export default-originate;** area 0.0.0.0 { interface ge-0/1/0.0; interface lo0.0 { passive; } } }}
policy-options { **policy-statement default-originate {** term 1 { from { protocol static; route-filter 0.0.0.0/0 exact; } then { external { type 1; } accept; } } }}BGP Next-hop Self
Section titled “BGP Next-hop Self”Next-hop 属性の変更
Section titled “Next-hop 属性の変更”iBGP peer(R2)では Next-hop 属性は変更せず(R1)に学習した状態のまま転送してしまう そのため、iBGP neighbor(R3)は該当 next-hop 情報を RIB に学習していないと hidden 扱いになってしまう 本機能は Next-hop 情報を BGP neighbor の local-address(R2)に変更して送信する これにより他 iBGP neighbor(R3)は送信元の local-address(R2)を覚えておけばよくなる
Action部に追加の設定を行うprotocols {bgp {group ibgp {type internal;local-address 1.1.1.51;export Next-hop-self;neighbor 1.1.1.70;}}}
policy-options {policy-statement Next-hop-self {term 1 {from protocol bgp;then {next-hop self;accept;}}}}Local Preference 属性の変更
Section titled “Local Preference 属性の変更”eBGP から 200.0.0.0/24 を受信するときに Local preference を 200 に設定
protocols {bgp {group ebgp {import Local-Preference;type external;peer-as 65001;neighbor 192.168.100.1;}}
policy-options {policy-statement Local-Preference {term 1 {from {protocol bgp;route-filter 200.0.0.0/24 orlonger;}}then {local-preference 200;accept;}}}}AS-Path 属性の変更について
Section titled “AS-Path 属性の変更について”AS-path prepend ✓ AS-Path をプリペンドして AS-path 長を長くみせかける方法 AS-path filter ✓ 指定した AS パスフィルタによってルーティングポリシーを決定 ✓ 全部あるいは一部の AS パスを指定してマッチさせることが可能 ✓ AS パスのパターンマッチにはレギュラーエクスプレッションを使用
AS-Path Prepend の設定方法について
Section titled “AS-Path Prepend の設定方法について”protocols {bgp {group ebgp {export AS-path-prepend;type external;peer-as 200;neighbor 192.168.0.1;}}}
policy-options {policy-statement AS-path-prepend {term 1 {from {route-filter 200.0.0.0/24 exact;}}then {as-path-prepend “100 100 100”;accept;}}}}Community 属性の変更
Section titled “Community 属性の変更”R2 では eBGP から受信時に以下の内容を実施 ✓ 161.161.0.0/16 の経路に community no-export を追加 ✓ 152.152.0.0/16 の経路には Community 65000:1 を追加 R3 から AS2 には community 65000:1 が付与された経路は配信しない
R2 の設定方法について
Section titled “R2 の設定方法について”経路にしたがって community tag を付与する
protocols {bgp {group ebgp {import community ;type external;peer-as 1;neighbor 192.168.100.1;}}
policy-options {community com_1 members no-export;community com_2 members 65000:1;}
policy-options {policy-statement community {term 1 {from {protocol bgp;route-filter 161.161.0.0/16 exact;}then {community add com_1;accept;}}term 2 {from {protocol bgp;route-filter 152.152.0.0/16 exact;}then {community set com_2;accept;}}}}R3 の設定方法について
Section titled “R3 の設定方法について”指定の経路が付与されていると経路を配信しない
protocols {bgp {group ebgp {export community_filter ;type external;peer-as 2;neighbor 192.168.200.1;}}
policy-options {policy-statement community_filter {term 1 {from {protocol bgp;community com_1;}then reject;}}community com_1 members 65000:1;}MED 属性の変更
Section titled “MED 属性の変更”R1,R2 において eBGP から 220.0.0.0/24 と 221.221.0.0/24 の経路を受信するときに MED を追加し、トラフィックをコントロール
設定方法について
Section titled “設定方法について”Action 部に追加の設定を行う
protocols {bgp {group ebgp {export med ;type external;peer-as 1;neighbor 192.168.100.1;}}
policy-options {policy-statement med {term med_10 {from {protocol bgp;route-filter 220.0.0/24 exact;}then {metric 110;accept;}}term med_20 {from {protocol bgp;route-filter 221.221.0/24 exact;}then {metric 250;accept;}}}Firewall overview
Section titled “Firewall overview”指定の条件をもとにトラフィックの転送許可、拒否を行うことでセキュリティを保つ 該当製品に搭載される PFE にてハードウェア処理を行う 転送されるパケットのヘッダ部の情報を参照し、アクションを実行する ✓ Accept :通信の許可 ✓ Discard :ICMP メッセージを送ることなく、パケットを破棄 ✓ Reject :ICMP メッセージを送信して、パケットを破棄 合致した通信の帯域制御(policer) その他にもトラフィック解析要素として下記の情報も取得可能 ✓ Sampling:ポートミラー機能や Netflow 機能と組み合わせたサンプリング ✓ Count :Firewall に合致したパケット数のカウント(※多量の count 設定は転送量に影響する場合がございます) ✓ Logging :Firewall に合致したパケットの一部情報をログに記録
Firewall 階層での設定
Section titled “Firewall 階層での設定”Policy-options と同等の設定の仕方で条件を作成する set firewall family [family protocol] filter [filter-name] term [term-name] from [match-condition] set firewall family [family protocol] filter [filter-name] term [term-name] then [action] 作成した条件を interface の input / output 方向に unit 単位で設定する ✓ トランジット通信の場合は IF に設定すること指定 IF からの通信を制御可能 ✓ 装置宛ての通信は loopback IF に適用することで全 IF からの通信を制御可能 set interfaces [interface name] unit [unit name] family inet filter input [filter-name] set interfaces [interface name] unit [unit name] family inet filter output [filter-name]
ルータへのアクセス制御
Section titled “ルータへのアクセス制御”特定アドレスのみ telnet を許可する
irewall {family inet {filter ACL-SAMPLE {term 1 {from {source-address {100.0.1.0/24;}protocol tcp;destination-port telnet;}then accept;}term 2 {from {protocol tcp;destination-port telnet;}then {log;count reject-telnet;discard;}}term End-ACL {then accept;}}}
interfaces {lo0 {description Loopback;unit 0 {family inet {filter {input ACL-SAMPLE;}address1.1.1.1/30;}}}}カウンターの確認
Section titled “カウンターの確認”Action 中に counter の設定を入れることで合致したパケット数が確認できる
nelco@MX80-97# set firewall family inet filter test term 1 then count testnelco@M7i-122> show firewallFilter: __default_bpdu_filter__Filter: ACL-SAMPLECounters:Name Bytes Packetsreject-telnet 3029 55Firewall counter をクリアする場合
lab@juniper> clear firewall [all | counter-name | filter-name]