Tech Blog

Admit it, you've done it.  How often do you visit one of those sites that measures your broadband speed?  Linux has some really nice tools to measure your network speed within your LAN or WAN.

The first tool I will discuss is called iperf.  It runs in a client/server configuration so it is very useful for checking the bandwidth between two hosts in your LAN or even across a WAN.

To install it on CentOS:
# yum –y install iperf

Then on one end of your connection, simply run it in server mode as follows:
# iperf –s 

You should see something like this:

Server listening on TCP port 5001 
TCP window size: 85.3 KByte (default)
[ 4] local port 5001 connected with port 50304 

On the other end, run it in client mode to connect to the server you just started:
# iperf –c {ip or hostname of the server}

Here is what I see:

Client connecting to, TCP port 5001
TCP window size: 21.9 KByte (default)
[ 3] local port 50304 connected with port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 975 MBytes 818 Mbits/sec

That’s all that is needed to measure the speed but like most things Linux, it has many more options that you may want to look at.  As a general rule, I have found that you can usually expect to get somewhere between 60% to 80% of the theoretical top network speed on a relatively quiet LAN but as you might imagine, there are many variables that can affect your actual speed.  So on my gigabit LAN, I think 818 Mbits/sec is pretty good.  

The next utility to try is called iptraf.  You can install it by '# yum -y install iptraf' at a CentOS command line.  Then fire it up by issuing '# iptraf-ng' and you should see something like this:

The IP traffic monitor option will show you the number of bytes coming from each network interface so you can see exactly who (or at least what IP) is burning through your bandwidth.  Here is a quick screen capture of general interface statistics during a slow time on my CentOS gateway:

As you can see, it was only showing 41.3 kbps on my external interface of ens9 when I took this screen capture, mostly because I was the only one home at the time.  Here is a shot of the detailed interface option during a busier period of time:

If for some reason that doesn't suite you, you could have a go at nload.  It is a very similar tool that can be found within EPEL (Extra Packages for Enterprise Linux).  To install EPEL, you can issue the command '# yum -y install epel-release' on CentOS 7.  Then to install nload, '# yum -y install nload'.  Then just fire it up by issuing '# nload' at the command line.  Here is a screen shot of it in action one of my WAN interfaces:

  • Use the left and right arrow keys or Enter/Tab key switch between devices.
  • F2 to show the option window
  • F5 to save current settings to the user’s config file.
  • F6 to reload settings from the config files.
  • q or hit Ctrl+C to quit.

What if you want to track network utilization over time?  Two utilities come to mind that do that quite nicely.  The first is vnstat.  It too is part of EPEL and.  Once it is installed, you can install vnstat with '# yum -y install vnstat'.

The other utility that comes to mind does far more than just collecting network utilization.  It's name is sar and it is part of the sysstat collection of tools.  Actually it can also collect information on CPU usage, memory and paging, process creation, block devices activity, and even interrupt statistics.  To install, issue '# yum -y install sysstat'.

I could (and someday might) write an entire post on sar and still not cover all it can do.  For the purpose of this post, just know that ONE of the things it can do is to collect statistics for network devices. To do that, we can run '# sar -n DEV 1 3' and we should see something like what follows:

Give some of these a try and you just might be surprised with what you come up with!

- Kyle H.