Tools for Monitoring Network Bandwidth on Linux

In this tutorial, we are going to show some tools for monitoring Network bandwidth on Linux.

Network bandwidth is a measurement indicating the capacity of data transmitted over a network in a given amount of time. It is normally represented by a number of bits, kilobits, megabits, or gigabits transmitted in 1 second.

The higher the bandwidth of a network, the larger the amount of data that can be transmitted through the network. Network monitoring helps us keep track of the network bandwidth and is useful information for the system administrators.

In this blog post, we will use Ubuntu 22.04 as our OS on our LC-VPS2 plan. You can choose any Linux distro you like. Let’s get started!

Prerequisites

  • A server with Ubuntu 22.04 (other distros should work fine too)
  • User privileges: root or non-root user with sudo privileges

Update the System

Before we start to use any of the network monitoring tools, we need to update the system packages to the latest versions available.

sudo apt-get update -y && sudo apt-get upgrade -y

1. iftop

Interface top of iftop is a tool for viewing the current bandwidth on a network interface. To install iftop execute the following command:

apt install iftop -y

Executing the iftop command will give you output like this:

xxxxxxxx.roseh  => 122.121.68.224.133   5.12Kb  4.05Kb  4.11Kb
                <=                   512b    486b    346b
xxxxxxxx.roseh  => one.one.one.on      0b    114b    100b
                <=                     0b    196b    164b
xxxxxxxx.roseh  => undefined.host      0b     32b      8b


TX:             cum:   11.8rates:ea 4.75Kb6 4.58Kb  3.92Kb
RX:                    2.01KB       1.09Kb5  672b    648b
TOTAL:                 13.8KB       5.84Kb7 5.24Kb  4.55Kb

With this, you can see how much bandwidth is going in and out of the server, including to each IP address (or even the reverse DNS record if it is present). At the bottom you’ll see a summary of transmission (TX), receiving (RX), and both combined.

2. Netstat

Netstat is one of the most used network monitoring commands. It is used for monitoring incoming and outgoing network connections, open (or listening) ports, which programs are listening on which ports, and so on. To check all of this in one command, you can run the netstat -tunlp command:

root@host:~# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      3472/mariadbd
tcp        0      0 0.0.0.0:25              0.0.0.0:*               LISTEN      1356/master
tcp        0      0 0.0.0.0:7022            0.0.0.0:*               LISTEN      791/sshd: /usr/sbin
tcp6       0      0 :::25                   :::*                    LISTEN      1356/master
tcp6       0      0 :::7022                 :::*                    LISTEN      791/sshd: /usr/sbin

You’ll get a list of all open ports, which IP addresses the ports are listening on, and which process has opened that port. A local address of 0.0.0.0 means the port is listening on any IP address that the server has, which can be a security risk if you have services that shouldn’t be publicly accessible. We recommend following this guide on setting up firewall rules using iptables if you need to restrict access to some of your software.

Netstat has a lot of options, so we recommend going through the man page (by running the command man netstat) and seeing what each option flag does. You can view total TCP connections, diagnosing network performance issues, and more.

3. Nload

Nload is a real-time tool for monitoring network traffic and bandwidth usage. Executing the nload command will give you output like this:

Device eth0 [162.246.254.3] (1/2):
===================================
Incoming:
Curr: 104.78 kBit/s
Avg: 117.27 kBit/s
Min: 87.00 kBit/s
Max: 150.11 kBit/s
Ttl: 6.10 GByte

Outgoing:
Curr: 19.02 kBit/s
Avg: 15.50 kBit/s
Min: 6.00 kBit/s
Max: 21.86 kBit/s
Ttl: 7.90 MByte

This is a pretty simple program, showing you the overall network load (as the command’s name would suggest). This is good for checking if you’re hitting a known bandwidth cap, such as 100Mbit/s or 1000Mbit/s.

4. Nethogs

Nethogs is used for finding the PID of the application that is eating most of your bandwidth. Executing nethogs will give you output similar to this:

NetHogs version 0.8.6-3
PID USER     PROGRAM                       DEV         SENT      RECEIVED
27706 root     sshd: root@pts/0            eth0        0.188       0.053 KB/sec
? root     162.246.254.3:45881-35.203.210.237:54563    0.011       0.011 KB/sec
? root     162.246.254.3:25757-35.203.210.169:54911    0.000       0.000 KB/sec

This is useful if you’re having slow network performance, and you can’t figure out which program or service is causing it.

5. Bmon

Bmon is a straightforward command-line tool for monitoring network bandwidth utilization. Execute bmon and check the output:

Interfaces                     x RX bps       pps     %x TX bps       pps     %
 >lo                           x      0         0      x      0         0
    qdisc none (noqueue)       x      0         0      x      0         0
  eth0                         x  13.22KiB      0      x    360B        1
    qdisc none (fq_codel)      x      0         0      x    360B        1
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqqqqqqqvqqqqqqqqqqqqqqqqqq

                              (RX Bytes/second)                                                                   
    0.00 ............................................................                   
    0.00 ............................................................                    
    0.00 ............................................................                   
    0.00 ............................................................                    
    0.00 ............................................................                   
    0.00 ............................................................                   
         1   5   10   15   20   25   30   35   40   45   50   55   60                   

This is more of a TUI program, or terminal user interface. Its layout is reminiscent of task manager or resource monitor, giving you a graph of your network usage. You can use the arrow keys to go up and down and monitor each of your system’s interfaces.

Other Tools

There are many other network monitoring tools for bandwidth on Linux, such as Nagios, IPTraf, Speedometer, Darkstat, SARG, and many more. All of this can be easily found on the Internet. Odds are, with each of these tools, you’ll be able to diagnose, debug, and troubleshoot your networking and make it run exactly as you intend.

That’s it – you have now learned about some of the most used tools for monitoring network bandwidth with real examples and usage.

P.S. If you liked this post about tools for monitoring Network bandwidth on Linux, please share it with your friends on social networks or simply leave a reply below. Thanks.

Leave a Comment