ifinfo - a tool to get network interface information
ifinfo [options for ifinfo]
ifinfo is a simple commandline network inquiry/formatting tool specifically designed to output some useful information about your network connection. It works by querying the relevant tables in /proc as well as the output of various Unix commands. Its entire purpose in life is to tell you what you want to know, hopefully in a format that is useful and compact.
Ifname IP/netmask MTU Tx (MB) Rx (MB)
lo: 127.0.0.1/255.0.0.0 16436 210.524 MB 210.524 MB eth0: 192.168.1.16/255.255.255.0 1500 1787.516 MB 186.974 MB
The parameters you may use for this are as follows:
Note: current versions of the Linux kernel have a network byte counter overflow at 4 GB, so that if you are transfering more than 4 GB of data, you will find that the counters overflow and wrap around.
ifinfo --sep="," --ifname=eth0,lo --info=dev,HWaddr,irq,inet_addr,name
lo,00:00:00:00:00:00,-,127.0.0.1,localhost.localdomain eth0,00:40:05:0B:9F:01,5,192.168.1.16,squash.scalableinformatics.com
ifinfo --format="[%s],%s+%s" --ifname=eth0,lo --info=dev,HWaddr,inet_addr
[lo],00:00:00:00:00:00+127.0.0.1 [eth0],00:40:05:0B:9F:01+192.168.1.16
ifinfo --format=``<tr><td>%s</td><td>%s</td><td>%s</td>'' --ifname=eth0,lo --info=dev,HWaddr,inet_addr
<tr><td>lo</td><td>00:00:00:00:00:00</td><td>127.0.0.1</td> <tr><td>eth0</td><td>00:40:05:0B:9F:01</td><td>192.168.1.16</td>
We recommend simply using %s as the format specifier for a particular field. Wrap the field with the text you need. The above example shows how this could be used as part of a status display for a web based machine.
ifinfo --mask=hex --ifname=eth0,lo
lo: 127.0.0.1/0xff000000 16436 219.678 MB 219.678 MB eth0: 192.168.1.16/0xffffff00 1500 1793.610 MB 189.103 MB
ifinfo --mask=range --ifname=eth0,lo
lo: 127.0.0.1/8 16436 219.685 MB 219.685 MB eth0: 192.168.1.16/24 1500 1793.614 MB 189.108 MB
ifinfo --mask=bits --ifname=eth0,lo
lo: 127.0.0.1/11111111000000000000000000000000 16436 219.691 MB 219.691 MB eth0: 192.168.1.16/11111111111111111111111100000000 1500 1793.620 MB 189.114 MB
ifinfo --ifname=eth0,lo --ns
lo: localhost.localdomain 16436 220.802 MB 220.802 MB eth0: squash.scalableinformatics.com 1500 1794.392 MB 189.379 MB
ifinfo --ifname=eth0,lo --info=dev,name
lo,localhost.localdomain eth0,squash.scalableinformatics.com
ifinfo --ifname=eth0,lo --info=dev,name,irq
lo,localhost.localdomain,- eth0,squash.scalableinformatics.com,5
ifinfo --ifname=eth0,lo --route
lo: 127.0.0.0/255.0.0.0 -> 0.0.0.0
eth0: 0.0.0.0/0.0.0.0 -> 192.168.1.254
192.168.1.0/255.255.255.0 -> 0.0.0.0
169.254.0.0/255.255.0.0 -> 0.0.0.0
The route 0.0.0.0/0.0.0.0 address pointing to a particular IP address represents the default route. The masking bits above do not currently work with this option.
/usr/local/bin/ifinfo
ifinfo will emit warning messages for incorrect parameters.
Perl 5.6.0 or higher, Getopt::Long, POSIX.
ifconfig(8), route(8), netstat(8)
This code is licensed under GPL version 2.0. See http://www.gnu.org/copyleft/gpl.html#SEC1 for specific details.
Joe Landman landman@scalableinformatics.com L<http://scalableinformatics.com>