Howto Show/Record Traffic Statistics on subinterfaces under Fedora

Posted on 2008-11-15
Last Modified: 2012-05-05
I have a few linux servers with multiple subinterfaces for IP addresses, but only 1 physical interface.
I'm trying to find a way to view traffic statistics for these subinterfaces, but /proc/net/dev only shows physical interfaces plus the loopback.

Is it possible to include subinterfaces into /proc/net/dev?
If not, how can I do traffic reporting for subinterfaces? (I want to keep each subinterface separate in the reports)
Question by:mtchs
    LVL 43

    Expert Comment

    You will not see the subinterfaces traffic. You can group it by src/dts/IP - but not subinterface. The problem is that subinterface name (like eth0:0) is used only for user. Kernel uses the real device to send/receive traffic. One don't even have to create subinterfaces to bind multiple IPs per single NIC.

    Author Comment

    But why is the traffic statistics lost if it uses the subinterface.

    If I look at the traffic stats for eth0, it is not what the system is truely sending/recieving, as I know I'm pushing more than 33 Mb in 30 days, when I upload a constant rate of 15-30 Mbps (albeit on a different subinterface)
    LVL 43

    Expert Comment

    > But why is the traffic statistics lost if it uses the subinterface.
    As I stated before - it is not - subinterface is just alias for userland.

    Author Comment

    I have a main IP on eth0, that is never used except for system administration, all the rest of the traffic goes to subinterfaces.

    eth0 has a send/recv of ~3 GB, when I know for sure that I average 10-20 Mbit/s upload all day every day.
    And ~3 GB is not ~50 GB.

    So does it just simply not record the traffic?

    As shown in the code snippet, ifconfig doesn't show all the usage, but bwm-ng does.
    Does /proc/net/dev reset after a certain amount of time?

    I have not done any changes to the nic nor has the connection been reset at all for at the very least today.

    >One don't even have to create subinterfaces to bind multiple IPs per single NIC.
    How do I do that? Everywhere I've looked shows creating a subinterface using ifcfg scripts.

    [root@crypt ~]# uptime
     02:16:32 up 30 days,  7:01,  5 users,  load average: 0.48, 0.65, 0.62
    [root@crypt ~]# ifconfig eth0
    eth0      Link encap:Ethernet  HWaddr 00:1C:25:36:AE:F8  
              inet addr:removed  Bcast:removed  Mask:
              inet6 addr: removed Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:3088266641 errors:0 dropped:0 overruns:0 frame:0
              TX packets:210788332 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:1209845624 (1.1 GiB)  TX bytes:3403759979 (3.1 GiB)
              Interrupt:50 Base address:0x4800 
    [root@crypt ~]# 
    bwm-ng v0.6 (probing every 0.500s), press 'h' for help
      input: libstatnet type: avg (30s)
      |         iface                   Rx                   Tx                Total
                   lo:           2.55 Kb/s            2.55 Kb/s            5.10 Kb/s
                 eth1:           3.97 Kb/s            4.34 Kb/s            8.31 Kb/s
                 eth0:         720.84 Kb/s           12.37 Mb/s           13.08 Mb/s
               venet0:         869.59  b/s            1.26 Kb/s            2.11 Kb/s
                total:         728.20 Kb/s           12.38 Mb/s           13.09 Mb/s

    Open in new window


    Accepted Solution

    It looks like the In/Out is a 32bit int... so it wraps at 4 gigs.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Suggested Solutions

    I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
    Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
    This video discusses moving either the default database or any database to a new volume.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now