Traffic Accounting by IP Address

Forums Network Management ZeroShell Traffic Accounting by IP Address

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #41892

    I would like to track monthly traffic per IP address with my Zeroshell router. Is there support for pmacct or some other traffic accounting tool? I have installed the MRTG add-on. Could that be configured for individual IP traffic accounting?

    FYI I’m currently using a Zeroshell device to manage traffic in a combination office/retail/residential building, and have successfully implemented QOS and Captive Portal (for the downstairs Coffee Shop). Very stable. Works great.

    Many thanks.


    I’d like that feature too…


    It doesn’t look like there is any progress on ip accounting, so I knocked up something to help in the meantime.
    I hope someone finds this useful.

    In my case, I want to IP account for the subnet.

    I created a new chain called ‘accounting’ and left it blank.
    I then added the following line to the “Post Boot script”
    # Startup Script

    You’ll need to create this file.
    Here is my example: (change the subnet to whatever you want)

    let a=1
    while [ $a -lt 255 ]; do
    iptables -A accounting -d 192.168.6.$a
    let a=a+1
    iptables -A accounting -j RETURN

    On boot, zeroshell will create the ‘accounting’ chain, then this post boot script will populate it with some rules.

    The last step is to create a new rule at the top of your FORWARD chain.
    In my case, I have said anything coming in ppp0 (internet) going out ETH00 (LAN) should be sent to the ‘accounting’ chain.
    The chain simply counts the packets then returns to the FORWARD chain for normal processing.

    To view the stats, you can either use:
    iptables -L accounting -v -n
    iptables -L accounting -v -n -x
    (-x prints exact values, handy for parsing the bytes value into other scripts)
    Or you can choose the chain from the web interface (it will appear to be empty) and click the VIEW button.
    You’ll see the same output as the commands above.

    One last thing – if you want to reset the stats daily or whatever, add something like this to your cron jobs:

    iptables -Z accounting

    I hope you find this useful.



    Looks like a great step in the progress of accounting!

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.