How to Monitor Network Bandwidth Using the Command Line on Linux

Analyzing and monitoring the network traffic of an entire network infrastructure is a very important task for every Linux system administrator. Network admin needs to see what’s going on with the network, who’s using the bandwidth, and how their entire network infrastructure is handling the load. The good thing is there are many open-source network monitoring and traffic analysis tools available in Linux.

In this post, we will discuss some Linux command line tools that can be used to monitor the network usage.

Nload

Nload is a console application that allows users to monitor the incoming and outgoing traffic separately.

It visualizes the incoming and outgoing traffic using two graphs and provides additional info like total amount of transferred data and min/max network usage.

You can install nload by running the following command:

sudoapt-get install nload

Now run the nload command:

sudo nload

Once the nload command is executed, you should see the following output.

Iptraf

Iptraf is an ncurses-based IP LAN monitoring tool that shows individual connections and the amount of data flowing between the hosts.

To install iptraf, run the following:

sudoapt-get install iptraf

Once iptraf has been installed, issue the following command:

sudo iptraf

You should see the following output.

Vnstat

Vnstat is different from most of the other tools. It is a console-based network traffic monitor for Linux that runs as a daemon and keeps a log of network traffic for the selected interface. It can be used to generate a report of the network usage.

You can install vnstat by running the following command:

sudoapt-get install vnstat

Now, run vnstat without any argument:

sudo vnstat

You can see the total amount of data transfer on your network.

If you want to monitor the bandwidth usage in realtime, use the -l option. It will display the total bandwidth used by incoming and outgoing data.

Now, run vnstat to monitor the bandwidth usage on the wlan0 interface:

sudo vnstat -l-i wlan0

You will see the following output.

Speedometer

Speedometer is a command line utility that can be used to monitor the current download/upload speeds of the network connections and the speeds of the file systems. Speedometer shows a graph of your current and past network speed in your console. You can also use speedometer directly on a file to monitor the download performance and history of a specific download instead of all the network traffic.

Run the following command to install speedometer in your system:

sudoapt-get install speedometer

Now, run speedometer on wlan0 interface:

sudo speedometer -r wlan0 -t wlan0

You will see an output similar to the following.

Iftop

Iftop is a command line tool that listens to network traffic on a given interface (such as eth0, eth1, wlan0) and shows a table of current bandwidth usage by hosts. Iftop uses the pcap library to capture the incoming and outgoing packets of the network interface.

You can easily install iftop by running the following command:

sudoapt-get install iftop

Now, run iftop with the n option that prevents iftop from resolving ip addresses to hostname:

sudo iftop -n

You will see the following output.

Conclusion

I hope this post will be helpful to quickly check the network bandwidth on your Linux server. Feel free to leave a comment if you have any questions.