Network Monitoring with FreeBSD's NetFlow

Jul 19, 2023 • FreeBSDSoftware

We often find it crucial to keep an eye on network activities and manage them for optimizing the resources. From governing bandwidth usage to predicting data hoarding, network monitoring plays a vital role. We have discussed about different network monitoring and management techniques so far in our articles in FreeBSD’s networking guide. Today, we will figure out how we can benefit from FreeBSD’s NetFlow to keep our network operations smooth.

Starting with NetFlow

NetFlow, developed by Cisco, is a protocol that collects and monitors network traffic flow data. It is a widespread and accepted protocol that most of the networking devices support. For FreeBSD users, NetFlow can be a powerful tool to keep track of every minute details of what’s happening over their network.

Installing NetFlow

In FreeBSD, we use software like pfflowd or softflowd to enable NetFlow services. They are part of the FreeBSD ports collection.
You can install pfflowd using the command:

pkg add pfflowd

Or softflowd by running:

pkg add softflowd

You can find more details about package management in our previous article.
Please note that pkg is a newer, faster replacement for the traditional FreeBSD ports system.

NetFlow Configuration

After the installation, the next step would be configuring the software. They differ in configuration, but the overall process could be summarized as below:

  • For pfflowd, the configuration is as simple as adding an entry in /etc/rc.conf:
echo 'pfflowd_enable="YES"' >> /etc/rc.conf

And to start it, run:

/etc/rc.d/pfflowd start

More about configuring FreeBSD system can be found here.

  • softflowd is quite more customizable. The -i flag dictates which interfaces to capture; -n specifies where to send the flows:
softflowd -i em0 -n 192.0.2.2:9996

Make sure to replace em0 and 192.0.2.2:9996 with the correct interface name and IP address respectively.

Using NetFlow

Once you activated NetFlow, it starts to monitor the traffic on your network interface. Getting the data exported into a useful format and visualizing it often requires additional software.

Using external NetFlow collectors, like nfdump, flow-tools, is generally the best way. They collect, store, and help analyze flow data exported by NetFlow exporters. FreeBSD ports of these tools are available and can be installed via the command line:

pkg add nfdump flow-tools

You can then use these tools to dump the NetFlow data into a file and analyze it as needed.

Note: It’s always advisable to secure your network interfaces and use robust firewalls. Consider taking a look at our guide on Configuring Firewalls and Security.

Conclusion

With NetFlow on FreeBSD, monitoring your network traffic is no daunting task. It helps you get a deeper insight into your network, ensuring you are making the best use of your resources, boosting system performance optimization guide here, and spotting problematic trends before they become issues. The knowledge of a tool like NetFlow and how to employ it can be a Great Armor in your System Administration collection.

Happy networking!


Checkout these related ports: