Description

This article describes how to configure active sampling using a sampling instance and associate that sampling instance to a particular PFE. It includes an example showing the configuration of a sampling instance on an MX480 router with IPv4 and IPv6 interfaces.

Symptoms

 

Solution

 

Topology

                                      R3
                                      |
                                 <ge-2/3/9>
                          20.1.1.2/30 | 2002::2/64
                                      |
                                      |
                          20.1.1.1/30 | 2002::1/64
                                 <ge-1/3/7>
                                      |
R1 <ge-1/0/0> ---------- <ge-1/3/9>  R2  <ge-1/3/8> ---------------------<ge-0/1/0>  R4 
10.1.1.1/30            10.1.1.2/30        3001::2/64                      3001::1/64

Hardware used: MX-480

FPC 0 REV 08 750-024064 YC3847 MS-DPC
FPC 1 REV 17 750-021157 YB4434 DPCE 40x 1GE R TX

R2> show version 
Model: mx480
JUNOS Base OS boot [12.2R1.8]

Configuration

On R2: Sampling*
[edit chassis]
lab# show 
fpc 1 {
    sampling-instance a1;
}

[edit interfaces]
lab# show 
sp-0/0/0 {
    unit 0 {
        family inet;
    }
}
sp-0/1/0 {
    unit 0 {
        family inet6;
    }
}
lab# show interfaces ge-1/3/7 
unit 0 {
    family inet {
        address 20.1.1.1/30;
    }
    family inet6 {
        address 2002::1/64;
    }
}
lab# show interfaces ge-1/3/8  
unit 0 {
    family inet6 {
        filter {
            input v6-sample; 
        }
        address 3001::2/64;
    }
}
lab# show interfaces ge-1/3/9  
unit 0 {
    family inet {
        filter {
            input v4-sample;
        }
        address 10.1.1.2/30;
    }
}

[edit forwarding-options]
lab# show 
sampling {
    instance {
        a1 {
            input {
                rate 1;
                run-length 0;
            }
            family inet {
                output {
                    flow-server 10.1.1.2 {
                        port 2055;
                        version9 {
                            template {
                                v4;
                            }
                        }
                    }
                    interface sp-0/0/0 {
                        source-address 1.1.1.1;
                    }
                }
            }
            family inet6 {
                output {
                    flow-server 10.1.1.2 {
                        port 2055;
                        version9 {
                            template {
                                v6;
                            }
                        }
                    }
                    interface sp-0/1/0 {
                        source-address 1.1.1.1;
                    }
                }
            }                           
        }
    }
}

[edit services]
lab# show 
flow-monitoring {
    version9 {
        template v4 {
            flow-active-timeout 30;
            flow-inactive-timeout 30;
            ipv4-template;
        }
        template v6 {
            flow-active-timeout 30;
            flow-inactive-timeout 30;
            ipv6-template;
        }
    }
}

[edit firewall]
lab# show 
family inet {
    filter v4-sample {
        term 1 {
            then {
                sample;
                accept;
            }
        }
    }
}
family inet6 {
    filter v6-sample {
        term 1 {
            then {
                sample;
                accept;
            }
        }
    }
}

Verification

To verify that your configuration is working as expected, use the commands below on the respective routers.

For v4 Traffic

Ping from R1 to R3 and check the flows on R2:

R1>ping 20.1.1.2 rapid count 100000

R2# run show services accounting flow

Flow information
Service Accounting interface: sp-0/0/0, Local interface index: 271
Flow packets: 681491110, Flow bytes: 31351856438
Flow packets 10-second rate: 0, Flow bytes 10-second rate: 16
Active flows: 3, Total flows: 16
Flows exported: 179 , Flows packets exported: 526
Flows inactive timed out: 13, Flows active timed out: 179

For v6 Traffic

Ping from R4 to R3 and check the flows on R2:

R4# run ping 2002::2 rapid count 1000000

R2# run show services accounting flow

Flow information Service Accounting interface: sp-0/0/0, Local interface index: 271
Flow packets: 681593915, Flow bytes: 31360071542
Flow packets 10-second rate: 280, Flow bytes 10-second rate: 16356
Active flows: 4, Total flows: 20
Flows exported: 209 , Flows packets exported: 568
Flows inactive timed out: 16, Flows active timed out: 209

Troubleshooting

1. Create a firewall counter with any name and check if the count increases. (Note: Do not forget to add term 2 then accept.)
2. Check reachability from source to flow-server.
3. Check if port is open on Flow-server and accepting connections from MX box.
4. Deactivate and activate sampling.

Related Information