例: サンプリング インスタンスの設定
サンプリングインスタンスを使用してアクティブサンプリングを設定し、そのサンプリングインスタンスを特定のフレキシブルポートコンセントレータ(FPC)、モジュラーポートコンセントレータ(MPC)、または高密度ポートコンセントレータ(DPC)に関連付けることができます。さらに、サンプリング インスタンスの宛先ごとに、複数の宛先およびプロトコル ファミリーに関連付けられた複数のサンプリング インスタンスを定義できます。
ネットワークの詳細例
次の例は、Junos OS リリース 9.6 を実行している MX480 ルーター上の 2 つのサンプリング インスタンスの設定を示しています。
図1では、ルーター1からのパケットが監視ルーターのギガビットイーサネットge-0/1/0インターフェイスに到着し、パケットはサービスインターフェイスsp-2/0/0によってサンプリングされ、エクスポートインターフェイスge-1/0/4によってcflowdサーバーに送信されます。ルーター3からのパケットは、監視ルーターのギガビットイーサネットge-3/1/0インターフェイスに到着し、パケットはサービスインターフェイスsp-2/1/0によってサンプリングされ、エクスポートインターフェイスge-1/0/4によってcflowdサーバーに送信されます。サンプリング プロセス中も、ge-0/1/0 および ge-3/1/0 からルーター 2 へのge-1/0/0 2 への通常のトラフィック フローは中断されずに継続されます。アクティブ フロー監視では、入力インターフェイスと出口インターフェイスの両方を任意のインターフェイス タイプ(SONET/SDH、ギガビット イーサネットなど)にすることができます。
FPC、MPC、または DPC にアタッチできるサンプリング インスタンスは 1 つだけです。サンプリングインスタンスの下に複数のファミリーを設定できます。各ファミリーは、独自のコレクターアドレスを持つことができます。サンプリング インスタンスを定義し、各インスタンスを異なる FPC にアタッチすることも、1 つのサンプリング インスタンスをすべての FPC にアタッチすることもできます。
この例のサンプリング構成には、次のものが含まれます。
-
[edit forwarding-options]階層レベルでサンプリング データを収集するように構成された 2 つのサンプリング インスタンスs0とs1。flow-serverステートメントには、フロー サーバーの IP アドレス、ポート、およびテンプレートが含まれます。interfaceステートメントには、フロー レコード処理用のサービス インターフェイス(sp-2/0/0またはsp-2/1/0)と、サンプリングされたインターフェイス上の受信ルーターの送信元アドレスが含まれています。 -
FPC 0 および 3 への 2 つのサンプリング インスタンスのバインディング。これらは、
[edit chassis fpc slot]階層レベルのsampling-instanceステートメントで設定されます。 -
[edit interfaces interface-name unit unit-number family family]階層レベルでsamplingステートメントを使用して、入力インターフェイスge-0/1/0およびge-3/1/0でサンプリングを有効にします。
この例では、 ping コマンドがMX480ルーターを介してルーター1からルーター2に発行され、トラフィックが生成されます。パケットが生成された後、 show コマンドを発行して、サンプリング設定が期待どおりに機能していることを確認します。
ルーター設定例
次の出力は、2つのサンプリングインスタンスを持つMX480ルーターの設定を示しています。
user@MX480–router> show configuration
[...Output Truncated...]
}
chassis {
fpc 0 { # The fpc number is associated with the interface on which sampling is enabled, ge-0/1/0 in this statement.
sampling-instance s0;
}
fpc 3 { # The fpc number is associated with the interface on which sampling is enabled, ge-3/1/0 in this statement.
sampling-instance s1;
}
}
interfaces {
ge-0/1/0 { # This interface has sampling activated.
unit 0 {
family inet {
sampling { # Here sampling is activated.
input;
}
address 10.0.0.1/30;
}
}
}
ge-1/0/0 { # The interface on which packets are exiting the router.
unit 0 {
family inet {
address 192.0.2.1/30;
}
}
}
ge-1/0/4 { # The interface connected to the cflowd server.
unit 0 {
family inet {
address 198.51.100.1/32;
}
}
}
sp-2/0/0 { # The service interface that samples the packets from Router 1.
unit 0 {
family inet;
}
}
sp-2/1/0 { # The service interface that samples the packets from Router 3.
unit 0 {
family inet;
}
}
ge-3/1/0 { # This interface has sampling activated.
unit 0 {
family inet {
sampling { # Here sampling is activated.
input;
}
address 192.168.2.1/30;
}
}
}
}
forwarding-options {
sampling {
instance {
s0 {
input {
rate 1;
run-length 0;
}
family inet {
output {
flow-server 198.51.100.2 { # The address of the external server.
port 2055;
version9 {
template {
v4
}
}
}
interface sp-2/0/0 {
source-address 192.168.1.1; # Source address of the sampled packets
}
}
}
}
s1 {
input {
rate 1;
run-length 0;
}
family inet {
output {
flow-server 198.51.100.2 { # The address of the external server.
port 2055;
version9 {
template {
v4
}
}
}
interface sp-2/1/0 {
source-address 192.168.1.2; # Source address of the sampled packets
}
}
}
}
}
}
}
routing-options {
static {
route 203.0.113.0/8 next-hop 192.0.2.2;
}
}
services {
flow-monitoring {
version9 {
template v4 {
flow-active-timeout 30;
flow-inactive-timeout 30;
ipv4-template;
}
}
}
}
設定例に使用される設定コマンド
この例では、以下の set コマンドをサンプリング・インスタンスの構成に使用しています。これらのコマンドの値を、ご自身のネットワークに関連する値に置き換えてください。
-
set chassis fpc 0 sampling-instance s0 -
set chassis fpc 3 sampling-instance s1 -
set interfaces ge-0/1/0 unit 0 family inet sampling input -
set interfaces ge-0/1/0 unit 0 family inet address -
set interfaces ge-1/0/0 unit 0 family inet address -
set interfaces sp-2/0/0 unit 0 family inet -
set interfaces sp-2/1/0 unit 0 family inet -
set interfaces ge-3/1/0 unit 0 family inet sampling input -
set interfaces ge-3/1/0 unit 0 family inet address -
set forwarding-options sampling instance s0 input rate 1 -
set forwarding-options sampling instance s0 input run-length 0 -
set forwarding-options sampling instance s0 family inet output flow-server 198.51.100.2 port 2055 -
set forwarding-options sampling instance s0 family inet output flow-server 198.51.100.2 version9 template v4; -
set forwarding-options sampling instance s0 family inet output interface sp-2/0/0 source-address 192.168.1.1 -
set forwarding-options sampling instance s1 input rate 1 -
set forwarding-options sampling instance s1 input run-length 0 -
set forwarding-options sampling instance s1 family inet output flow-server 198.51.100.2 port 2055 -
set forwarding-options sampling instance s1 family inet output flow-server 198.51.100.2 version9 template v4; -
set forwarding-options sampling instance s1 family inet output interface sp-2/1/0 source-address 192.168.1.2 -
set routing-options static route 203.0.113.0/8 next-hop 192.0.2.2 -
set services flow-monitoring version9 template v4 flow-active-timeout 30 -
set services flow-monitoring version9 template v4 flow-inactive-timeout 30 -
set services flow-monitoring version9 template v4 ipv4-template
機能の検証
設定が想定どおりに動作していることを確認するには、サンプリング インスタンスで構成されたルーターで以下のコマンドを使用します。
-
show services accounting aggregation template template-name template-name -
show services accounting flow
以下は、この設定例で使用したMX480ルーターで発行された show コマンドの出力を示しています。
user@MX480–router> show services accounting aggregation template template-name v4
Src Dst
Port/ Port/
Source Destination ICMP ICMP Packet
Address Address Type Code Proto TOS Count
10.0.0.6 203.0.113.3 100 1000 17 8 14
10.0.0.5 203.0.113.2 100 1000 17 8 15
10.0.0.3 203.0.113.3 100 1000 17 8 15
10.0.0.2 203.0.113.3 100 1000 17 8 15
10.0.0.4 203.0.113.2 100 1000 17 8 15
10.0.0.6 203.0.113.2 100 1000 17 8 15
10.0.0.4 203.0.113.3 100 1000 17 8 15
10.0.0.2 203.0.113.2 100 1000 17 8 16
10.0.0.3 203.0.113.2 100 1000 17 8 15
10.0.0.5 203.0.113.3 100 1000 17 8 15
user@MX480–router> show services accounting aggregation template template-name v4
Src Dst
Port/ Port/
Source Destination ICMP ICMP Packet
Address Address Type Code Proto TOS Count
10.0.0.6 203.0.113.3 100 1000 17 8 16
10.0.0.5 203.0.113.2 100 1000 17 8 17
10.0.0.3 203.0.113.3 100 1000 17 8 16
10.0.0.2 203.0.113.3 100 1000 17 8 16
10.0.0.4 203.0.113.2 100 1000 17 8 17
10.0.0.6 203.0.113.2 100 1000 17 8 17
10.0.0.4 203.0.113.3 100 1000 17 8 16
10.0.0.2 203.0.113.2 100 1000 17 8 17
10.0.0.3 203.0.113.2 100 1000 17 8 17
10.0.0.5 203.0.113.3 100 1000 17 8 16
user@MX480–router> show services accounting flow
Flow information
Interface name: sp-2/0/0, Local interface index: 152
Flow packets: 884, Flow bytes: 56576
Flow packets 10-second rate: 0, Flow bytes 10-second rate: 628
Active flows: 10, Total flows: 35
Flows exported: 75, Flows packets exported: 14
Flows inactive timed out: 25, Flows active timed out: 75
user@MX480–router> show services accounting flow
Flow information
Interface name: sp-2/0/0, Local interface index: 152
Flow packets: 898, Flow bytes: 57472
Flow packets 10-second rate: 0, Flow bytes 10-second rate: 628
Active flows: 10, Total flows: 35
Flows exported: 75, Flows packets exported: 14
Flows inactive timed out: 25, Flows active timed out: 75