Viewing Live Bandwidth with iftop
iftop is a tool used to view current bandwidth activity on a network interface. It is considered to be for network usage, what ‘top’ is for CPU usage. iftop will monitor a given or default interface, and display a table current bandwidth usage between two hosts.
To install iftop with yum, the EPEL repository must be installed.
Redhat / CentOS 5 (most likely version in use)
32bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm 64bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
Redhat / CentOS 6
32bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm 64bit: rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Now that the repository is installed to the server, we can install iftop
yum install iftop
iftop is a very simple tool to use. You simply need to supply the interface which should be monitored (eth0, eth1, etc). For the majority of users, this will just be the default ‘eth0’ interface. You can execute the command ‘ifconfig’ to view all interfaces.
iftop -i eth0
By default, iftop displays all traffic in [mega/kilo/giga]bits (little ‘b’) per second, as opposed to bytes (big ‘B’). To display in bytes rather than bits, specify the ‘-B’ switch.
iftop -i eth0 -B
iftop will also display all address with a hostname, if connecting host’s IP resolves to one. To have iftop always reports IPs regardless, use ‘-n’.
iftop -i eth0 -n
Additionally, the port in which traffic is occurring on is not displayed. To display this, use the -P and -N switches (-N will show a port number, rather than common name).
iftop -i eth0 -P -N