10 Commands To Monitor Network Bandwidth On Linux

Commands To Monitor Network Bandwidth On Linux

Monitor Network Bandwidth

This article is based on Network monitoring. I will share some commands which will provide you the details of Network bandwidth usage. These are the best commands to get a quick look about your network usage. These commands will monitor network bandwidth incoming and outgoing traffic separately.

Some commands provide the details of the process which used the network bandwidth. This will help you to understand which process utilize the higher network.

Check out below list of commands with their explanation.

1. Nload

Nload command line tool which is used to monitor network bandwidth with incoming and outgoing traffic separately. The nload tool is easy to use and does not support any options.
If you want to take a quick look of incoming/outgoing traffic then nload will be the good option.

$ apt-get install nload
$ nload
nload
nload

2. Bmon

Bmon is similar to nload but bmon will provide you some more details. bmon (Bandwidth monitor) is another tool to monitor bandwidth on a linux machine.
The output of bmon tool also provides a graph and packet details. you can choose ethernet option by up/down arrow to check bandwidth on the graph.
Also, you can choose “d” option for extra details of network usage.

$ apt-get install bmon
$ bmon
bmon
bmon

3. Vnstat

vnstat is a different tool from other tools. It will run as a background process or daemon. Keep storing the size of data transfer all the time. You can be checked the history of network bandwidth usage with the help of vnstat.

$ apt-get install vnstat
$ vnstat

Output:

Database updated: Fri Nov 4 17:05:24 2016

eth3 since 11/04/16

rx: 34.68 MiB tx: 3.45 MiB total: 38.13 MiB

monthly
rx | tx | total | avg. rate
————————+————-+————-+—————
Nov ’16 34.68 MiB | 3.45 MiB | 38.13 MiB | 0.97 kbit/s
————————+————-+————-+—————
estimated 274 MiB | 24 MiB | 298 MiB |

daily
rx | tx | total | avg. rate
————————+————-+————-+—————
today 34.68 MiB | 3.45 MiB | 38.13 MiB | 5.08 kbit/s
————————+————-+————-+—————
estimated 47 MiB | 4 MiB | 51 MiB |

When you run this vnstat first time it will give you warning message “eth3: Not enough data available yet”. Try this command after some time so the vnstat will gather some details related to network usage.
If you want the current status of network usage then run below command with some options.

$ vnstat -l -i eth3
vnstat
vnstat

4. ifstat

ifstat provide network usage in batch style mode. Use below command of ifstat which gives you bandwidth with details of Time, data transfer In/Out etc.
We have used “-t” and “-i” option with ifstat command. -t provide the time and -i is used to mentioning ethernet.

$ ifstat -t -i eth0

Output:
Time eth3
HH:MM:SS KB/s in KB/s out
17:54:13 5.69 1.40
17:54:14 3.16 0.18
17:54:15 1.66 0.00
17:54:16 2.21 0.06
17:54:17 3.98 0.12
17:54:18 2.84 0.00

5. dstat

dstat is a versatile resource statistics tool. dstat provide you details in columns and clearly shows in what magnitude and unit are displayed. It will show stats in exactly with the same timeframe. It is written in python. You can use the option to indicate different values with different colors. You can check “man page” for multiple options.

$ apt-get install dstat
$ dstat

If you use only dstat command it will give you complete information like total-CPU-usage, dsk/total, net/total, paging etc.

$ dstat

Output:
—-total-cpu-usage—- -dsk/total- -net/total- —paging– —system–
usr sys idl wai hiq siq| read writ| recv send| in out | int csw
0 0 99 0 0 0| 17k 65k| 0 0 | 12B 164B| 434 1350
0 0 99 0 0 0| 0 0 |5365B 60B| 0 0 | 444 1151
1 0 99 0 0 0| 0 0 |4699B 78B| 0 0 | 486 3311
1 0 99 0 0 0| 0 0 |2220B 0 | 0 0 | 436 2033
1 0 98 0 0 0| 0 0 |5056B 0 | 0 0 | 638 2153
1 0 99 1 0 0| 0 40k |3869B 0 | 0 0 | 572 1701
1 0 99 0 0 0| 0 0 |5242B 0 | 0 0 | 545 3620
1 0 99 0 0 0| 0 8192B|3492B 300B| 0 0 | 530 2620
1 0 98 0 0 0| 0 0 |3437B 1007B| 0 0 | 528 1931
1 0 97 1 0 0| 0 140k |3834B 0 | 0 0 | 585 2274
1 0 98 0 0 0| 0 80k |2280B 125B| 0 0 | 535 4014

To check only send/receive data with time then use below command.

$ dstat -nt

Output:
-net/total- —-system—-
recv send | time
0 0 |04-11 18:04:32
4747B 594B |04-11 18:04:33
2984B 294B |04-11 18:04:34
3817B 0 |04-11 18:04:35
4372B 60B |04-11 18:04:36
4762B 0 |04-11 18:04:37
10k 8557B |04-11 18:04:38
6344B 356B |04-11 18:04:39

6. iftop

iftop listens or provide info on network traffic. It will display the traffic by pairs of hosts. iftop reports a bandwidth on individual connections.
Run below command to install iftop on a linux machine.

$ apt-get install iftop
$ iftop -n

Use below options with iftop :

-h   display this message
-n   don’t do hostname lookups
-N  don’t convert port numbers to services
-p   run in promiscuous mode (show traffic between other
hosts on the same network segment)
-b   don’t display a bar graph of traffic
-B  Display bandwidth in bytes
-I   interface listen on named interface
-f   filter code uses filter code to select packets to count
(default: none, but only IP packets are counted)
-F   net/mask show traffic flows in/out of IPv4 network
-G  net6/mask6 show traffic flows in/out of IPv6 network
-l   display and count link-local IPv6 traffic (default: off)
-P  show ports as well as hosts
-m limit sets the upper limit for the bandwidth scale
-c  config file specifies an alternative configuration file

iftop
iftop

7. iptraf

Iptraf is basically a console-based network monitor tool for Linux. It will provide a variety of information like TCP connection, interface statistics, TCP/UDP traffic breakdowns etc. it is an interactive and colorful IP monitor. It provides unique connections and the data usage between hosts.

$ apt-get install iptraf
$ iptraf
iptraf
iptraf

8. tcptrack

tcptrack is used to monitor tcp connection on the network. It will show information such as bandwidth usage, state, source/destination addresses etc. Command output is much like the top command. you can check multiple options with “man pages”. tcptrack uses pcap library to capture and calculates packet.

$ apt-get install tcptrack
$ tcptrack -i eth0 -t

Output:
Client Server State Idle A Speed
192.168.6.110:34370 192.168.4.78:4949 SYN_SENT 1s 0 B/s
192.168.3.39:41533 216.58.199.174:443 ESTABLISHED 6s 0 B/s
192.168.3.39:38335 172.217.24.78:443 ESTABLISHED 17s 0 B/s
192.168.6.110:36804 192.168.4.208:4949 SYN_SENT 1s 0 B/s
192.168.3.39:48362 209.151.236.18:443 CLOSING 5s 0 B/s
192.168.6.110:54936 192.168.4.207:4949 SYN_SENT 1s 0 B/s

9. speedometer

the speedometer is simple network bandwidth tool which draws nice graphs of incoming and outgoing traffic. the speedometer is written in python language. it is working on python-urwid library. It will provide you a graph of receive/transfer bytes in the interface.

$ apt-get install speedometer
$ speedometer -r eth0 -t eth0
speedometer
speedometer

10. Netload

Netload is simple network bandwidth tool. it will provide you only small report on traffic load and how much bytes are transferred since the command is running.
it is part of netdiag.

$ apt-get install netdiag
$ netload eth0
netload
netload

I hope you like the article if you find any difficulties using monitor network bandwidth command then please do comment your queries or problem via the comment section, till then stay tuned to techthings.org for more such valuable articles.

READ MORE:

Read : Useful rsync command examples for SysAdmins

Read : Useful MySql Commands Every SysAdmin Should Know






Leave a Reply

Your email address will not be published. Required fields are marked *