How to reset ifconfig counters

Sometimes it is nice to reset the counters ifconfig displays.  This could be done monthly to show detailed bandwidth transfers each month, or after a specific event.  To do so, execute the following commands:Determine your network driver by using the following command:

ethtool -i eth0

Execute the command to clear the counters.  This command assumes the driver e1000:

modprobe -r e1000; modprobe e1000; ifup eth0

Confirm the command was successful:

ifconfig eth0 | grep bytes
RX bytes:1400246 (1.3 MiB)  TX bytes:58638 (57.2 KiB)

From the output above, the RX and TX bytes were cleared and only display traffic from the last couple of seconds.

*Disclaimer: Use warning performing these commands if unsure of the proper syntax / variables.  Misuse will result in “disconnecting the astronaut” and losing access to the remote host.



One comment


    Barry

    2011/10/13

    If you have an IP address provided by DHCP, you may want to modify this command to include a refresh of the DHCP address, particularly if you are attached via SSH:
    modprobe -r e1000; modprobe e1000; ifup eth0; dhclient

Leave a comment


Name

Email(will not be published)

Website

Your comment