Solved

Reset eth0 on Linux!

Posted on 2014-02-14
10
953 Views
Last Modified: 2014-03-03
Hi All,

When I run ifconfig on the CentOS, information of eth0:

eth0   Link encap:Ethernet  HWaddr 00:0C:29:87:91:F9
          inet addr:192.168.102.111  Bcast: 192.168.102.255  Mask:255.255.255.0
          .....
          RX bytes:10623376070 (9.8 GiB)  TX bytes:97989127014 (91.2 GiB)

How can I reset these counters especially RX/TX packets? (I don't want to use "/etc/init.d/network restart")

Thks in advance,

LDVHAI.
0
Comment
Question by:ldvhai
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
10 Comments
 
LVL 25

Expert Comment

by:Zephyr ICT
ID: 39858606
I don't think this is possible, the counters are kept in the kernel if I'm not mistaking, resetting the counters would entail resetting the nic(s) hence loosing connection.

You can check if the driver is a kernel module by doing

#ethtool -i eth0
0
 
LVL 2

Author Comment

by:ldvhai
ID: 39858613
Thanks for your answer:

The information got from CentOS

[root@ldvhai ~]# ethtool -i eth0
driver: e1000
version: 7.3.21-k4-3-NAPI
firmware-version: N/A
bus-info: 0000:02:00.0
[root@ldvhai ~]#

Thks,
0
 
LVL 25

Assisted Solution

by:Zephyr ICT
Zephyr ICT earned 125 total points
ID: 39858675
The only way I see to reset the counters is by unloading the module from kernel and reloading it:

# modprobe -r e1000; modprobe e1000; ifup eth0

Should do it ... But like I said, it wil disrupt traffic/network.
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 
LVL 31

Expert Comment

by:farzanj
ID: 39858704
service network restart

Open in new window


OR

ifdown eth0
ifup    eth0

Open in new window

0
 
LVL 38

Assisted Solution

by:Gerwin Jansen, EE MVE
Gerwin Jansen, EE MVE earned 250 total points
ID: 39858732
Or create a script (ifconfig alias) that uses a .ini file in which you specify which amount of RX/TX traffic to deduct from the ifconfig output. An emtpy .ini file (or not present) will show original ifconfig output so you can remove the .ini file when system is rebooted. You can use ifconfig to create the .ini file.
0
 
LVL 13

Assisted Solution

by:Sandy
Sandy earned 125 total points
ID: 39864483
vnstat is also one of the tool which can be used to clear the stats without network interruption.

To get more information you can refer to below link

http://www.linuxnix.com/2009/09/how-to-use-vnstat-to-monitor-bandwidth-usage.html

TY/SA
0
 
LVL 38

Accepted Solution

by:
Gerwin Jansen, EE MVE earned 250 total points
ID: 39864544
@Sandy - Nice tool - how does resetting the statistics shown by ifconfig work in vnstat?
0
 
LVL 2

Author Comment

by:ldvhai
ID: 39900517
Thanks for your anwser.
0
 
LVL 2

Author Closing Comment

by:ldvhai
ID: 39900521
Thanks for your anwser.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question