Install IPTraf on a Centos / RHEL / Fedora Linux To Get Network Statistics

Posted on in Categories , , , , last updated July 21, 2014

How can I install IPTraf utility on a CentOS, Red Hat Enterprise Linux, or Fedora Linux to get a variety information on my network?

IPTraf is a console-based network monitoring utility. IPTraf gathers data like TCP connection packet and byte counts, interface statistics and activity indicators, TCP/UDP traffic breakdowns, and LAN station packet and byte counts. IPTraf features include:

  • An IP traffic monitor that shows information on the IP traffic passing over your network. Includes TCP flag information, packet and byte counts, ICMP details, OSPF packet types.
  • General and detailed interface statistics showing IP, TCP, UDP, ICMP, non-IP and other IP packet counts, IP checksum errors, interface activity, packet size counts.
  • A TCP and UDP service monitor showing counts of incoming and outgoing packets for common TCP and UDP application ports
  • A LAN statistics module that discovers active hosts and shows statistics showing the data activity on them
  • TCP, UDP, and other protocol display filters, allowing you to view only traffic you’re interested in.
  • Logging
  • Supports Ethernet, FDDI, ISDN, SLIP, PPP, and loopback interface types.
  • Utilizes the built-in raw socket interface of the Linux kernel, allowing it to be used over a wide range of supported network cards.
  • Full-screen, menu-driven operation.

CentOS / RHEL / Fedora Linux install IPTraf

Type the following yum command to install IPTraf:
# yum install iptraf
Sample outputs:

Loaded plugins: auto-update-debuginfo, protectbase, rhnplugin, security
This system is receiving updates from RHN Classic or RHN Satellite.
0 packages excluded due to repository protections
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package iptraf.x86_64 0:3.0.1-14.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package      Arch         Version             Repository                  Size
 iptraf       x86_64       3.0.1-14.el6        rhel-x86_64-server-6       316 k
Transaction Summary
Install       1 Package(s)
Total download size: 316 k
Installed size: 0  
Is this ok [y/N]: y
Downloading Packages:
iptraf-3.0.1-14.el6.x86_64.rpm                           | 316 kB     00:00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : iptraf-3.0.1-14.el6.x86_64                                   1/1 
  Verifying  : iptraf-3.0.1-14.el6.x86_64                                   1/1 
  iptraf.x86_64 0:3.0.1-14.el6                                                  

How do I use iptraf command?

The syntax is:

iptraf [options]
iptraf -i interface_name_here

To start the IP traffic monitor for eth0 interface type the following command. Pass the -i all option for all interfaces:
# iptraf -i eth0
# iptraf -i all

Sample outputs:

Fig.01: iptraf in action
Fig.01: iptraf in action

Access all main menus

If the iptraf is started without any command-line options, the program comes up in interactive mode, with the various facilities accessed through the main menu as follows:
# iptraf
Sample outputs:

Fig.02: iptraf with menus
Fig.02: iptraf with menus

To start the general interface statistics, enter:

# iptraf -g

To see the detailed statistics facility on an interface called eth0

# iptraf -d interface_name_here
# iptraf -d eth0

To see the TCP and UDP monitor on an interface called eth0

# iptraf -z interface_name_here
# iptraf -z eth0

To displays the packet size counts on an interface called eth0

# iptraf -z interface_name_here
# iptraf -z eth0

Other options

Here are other options for the program:

-l iface    - start the LAN station monitor ("-l all" for all LAN interfaces)
-B          - run in background (use only with one of the above parameters)
-t timeout  - when used with one of the above parameters, tells
              the facility to run only for the specified number of
              minutes (timeout)
-L logfile  - specifies an alternate log file for any direct invocation
              of a facility from the command line.  The log is placed in
              /var/log/iptraf if path is not specified.
-I interval - specifies the log interval for all facilities except the IP
              traffic monitor.  Value is in minutes.
-f          - clear all locks and counters.  Use with great caution.
              Normally used to recover from an abnormal termination.

Related media

This tutorial is also available in a quick video format:

See also

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 0 comments/add one below):