NetFlow_IPFIX Exporting with pmacct – Bits 'n Bytes
NetFlow_IPFIX Exporting with pmacct – Bits 'n Bytes
Bits 'n Bytes
An Ubuntu Linux host is bridges two network segments and traffic passing through the bridge is
recorded as flow records.
Flow records can be useful for various applications. Here is an example flow record:
https://mattjhayes.com/2018/08/22/netflow-ipfix-exporting-with-pmacct/ 1/7
8/29/24, 10:22 AM NetFlow/IPFIX Exporting with pmacct – Bits 'n Bytes
Flow records give a coarse-grained view of what traffic is passing over a network, including flow
source and destination addresses/protocols/ports, as well as volume information such as packets and
bytes per flow.
NetFlow is a specification for exporting and collecting flow records. It is superseded by a newer open-
standard specification called IPFIX.
In this tutorial we use pmacct[1], a free and open source set of passive network monitoring tools
primarily developed by Paolo Lucente. Pmacct originally stood for “Promiscuous mode IP
Accounting”[2], but now has other features too. In this blog post we’re only covering how to use
pmacct as a NetFlow/IPFIX exporter.
We assume that you already have a free unused Ubuntu server with multiple NICs (physical or
virtual) running a recent release and access to the command line. We’re going to make changes to it,
so it does need to be a box that you don’t care about, and you should have physical access to it so
you can reconfigure it if you lose remote connectivity.
Pre-Work
Set up Bridging
https://mattjhayes.com/2018/08/22/netflow-ipfix-exporting-with-pmacct/ 2/7
8/29/24, 10:22 AM NetFlow/IPFIX Exporting with pmacct – Bits 'n Bytes
Configure Bridging
Configure bridging in the /etc/network/interfaces file. The exact configuration will depend on your
interfaces. Here is an example that bridges interfaces eth0 and eth1, and assigns them with an IP
address:
Check iptables
$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
If you happen to have Docker installed, note that Docker sets the FORWARD chain to DROP. If this is
the case you’ll either need to fix it (which Docker overwrites on reboot) or remove Docker. It can be
temporarily fixed when needed by running (beware: may be security implications, could break
Docker too):
Enable forwarding
sudo vi /etc/sysctl.conf
#net.ipv4.ip_forward=1
To be safe, you’re probably going to want to reboot the server at this point.
Install libpcap
https://mattjhayes.com/2018/08/22/netflow-ipfix-exporting-with-pmacct/ 4/7
8/29/24, 10:22 AM NetFlow/IPFIX Exporting with pmacct – Bits 'n Bytes
Install pmacct
Now we install the pmacct project. Create src directory off your home directory:
cd
mkdir src
cd src
wget http://www.pmacct.net/pmacct-1.7.1.tar.gz
cd ~/src/pmacct-1.7.1
./configure
make
Configure pmacct
mkdir ~/pmacct
cd ~/pmacct
vi pmacctd.conf
https://mattjhayes.com/2018/08/22/netflow-ipfix-exporting-with-pmacct/ 5/7
8/29/24, 10:22 AM NetFlow/IPFIX Exporting with pmacct – Bits 'n Bytes
daemonize: true
#daemonize: false
interface: br0
aggregate: src_host, dst_host, src_port, dst_port, proto, tos
plugins: nfprobe
nfprobe_receiver: 192.168.1.30:9995
! Do IPFIX:
nfprobe_version: 10
nfprobe_timeouts: tcp=30:maxlife=60
Run pmacct
If pmacct is configured to run as a daemon, you’ll need to check if processes are running. You should
see a couple of pmacctd processes:
Congratulations, you now have a working NetFlow/IPFIX exporter. Check out the Collecting
NetFlow (https://mattjhayes.com/2018/08/19/collecting-netflow-with-nfcapd-and-nfdump/) post for
how to build a NetFlow/IPFIX collector to receive the flow records.