Juniper Netflow configuration examples
Like most of you, I have a long list of "To-do's" in our LogicMonitor deployment. One that I just recently crossed off is capturing Netflow. More accurately, capturing sFlow from Juniper EX/QFX switches. It's worth noting that the actual implementation was surprisingly easy, aided by LM's netflow doc page and Juniper's references (see links below). I've included the needed Juniper commands for those of you who are also in non-Cisco environments. I can't stress enough though that you pay close attention to LM's suggested best-practices, carefully consider Juniper's caveats, and put a lot of effort into planning the details of your deployment (which switches, which physical interfaces, etc) so that you understand what data you are actually getting from sFlow and how it is being delivered. Remember: more data at your disposal does you no good if you can't place it in proper context.
###Global sflow enable, globally define polling interval and sampling rate,
define sflow source address and agent id; define the sflow collector and export port
set protocols sflow agent-id 192.168.254.2
set protocols sflow polling-interval 1
set protocols sflow sample-rate ingress 100
set protocols sflow sample-rate egress 100
set protocols sflow source-ip 192.168.254.2
set protocols sflow collector 192.168.1.2 udp-port 6343
###enable sflow sampling on individual switch ports (note: polling and sampling values set here are not required and will override global values)
set protocols sflow interfaces ge-0/0/9.0 polling-interval 1
set protocols sflow interfaces ge-0/0/9.0 sample-rate ingress 100
set protocols sflow interfaces ge-0/0/9.0 sample-rate egress 100
set protocols sflow interfaces ge-0/0/11.0 polling-interval 1
set protocols sflow interfaces ge-0/0/11.0 sample-rate ingress 100
set protocols sflow interfaces ge-0/0/11.0 sample-rate egress 100
http://www.logicmonitor.com/support/monitoring/networking-firewalls/netflow/
http://www.juniper.net/techpubs/en_US/junos14.1/topics/concept/sflow-ex-series.html
http://www.juniper.net/techpubs/en_US/junos14.1/topics/task/configuration/sflow-ex-series-cli.html
Next up is piping Netflow into our collector from Juniper's MX routers. From a LogicMonitor perspective there will be almost no difference. Unfortunately the degree of difficulty is substantially higher in terms of Juniper configuration. I'll put that into a separate post; check back later if you are interested.
OK, I've finally had a chance to validate this configuration and I can tell you that it works, with a few minor alterations....see below.
I have deployed this on an MX-80 running Junos 13.3R9.13. One other relevant addendum to my original "you need to know your MX HW & SW in detail" caveat: I have 20 x1 GE and 2 x 10GE MIC-3D powering my physical interfaces; if you have anything else consult Juniper documentation for sampling support information. good luck with that
set chassis fpc 1 sampling-instance NETFLOW-INSTANCE
#####The above statement is valid for MX-240, MX-480, and MX-960 HW, though you will need to specify the fpc you want to use. Also, there are very likely some limitations with regards to the number of sampling instances per fpc that you can create, the total number of instances that can be configured per chassis, and whether any single instance can span multiple fpc.
#####The below statement is valid for MX-80 HW. Given that MX-80 has a single tfeb, there are almost certainly much stricter limitations that govern the configuration of the number and deployment of sampling instances.
set chassis tfeb0 slot 0 sampling-instance NETFLOW-INSTANCE
#####From here down is the same regardless of MX model, though of course the physical and logical interfaces will vary.
set chassis network-services ipset services flow-monitoring version9 template LM-V9 option-refresh-rate seconds 25
set services flow-monitoring version9 template LM-V9 template-refresh-rate seconds 15
set services flow-monitoring version9 template LM-V9 ipv4-template
set forwarding-options sampling instance NETFLOW-INSTANCE input rate 1 run-length 0
set forwarding-options sampling instance NETFLOW-INSTANCE family inet output flow-server 192.168.1.2 port 2055
set forwarding-options sampling instance NETFLOW-INSTANCE family inet output flow-server 192.168.1.2 source 192.168.10.1 source-address 192.168.10.1
set forwarding-options sampling instance NETFLOW-INSTANCE family inet output flow-server 192.168.1.2 version9 template LM-V9
set forwarding-options sampling instance NETFLOW-INSTANCE family inet output inline-jflow source-address 192.168.10.1set interfaces ge-1/3/3 unit 2630 family inet sampling input
set interfaces ge-1/3/3 unit 2630 family inet sampling output