Yalo
    e-mail
    internet accelerators
    internet access
    internet and phone call
    web hosting
    storage space
    url redirection
    internet call waiting
    free sms
    nota bene
 

Traffic accounting with iptables on Linux

  Main script is used to start and stop accounting rules, to save traffic counters in a file and to calculate total traffic values based on saved accounting data. To start traffic accounting run rc.account_main start. This will start accounting rules. To stop traffic accounting run rc.account_main stop. This will save accounting data in the file and will stop accounting rules. To save traffic accounting data in a file run rc.account_main save from crontab periodically. To calculate total traffic data based on saved accounting data run rc.account_main total, this will save totals in another file.

Main script makes use of another script which does the job (creates chains, populates them with rules, writes data to files, etc.). There are two kinds of that ultimate script: Variant 1 to measure direct traffic through Linux gateway which is either performing NAT or do not; and Variant 2 to measure traffic flowing through a proxy process on the gateway. Variant 1 will not measure traffic flowing through a proxy process on the gateway, similarly Variant 2 will not measure direct traffic through the gateway. IP addresses for which traffic measurement is performed are assumed to be on the intranet side of the gateway. Variant 3 is a combined variant of Variant 1 and Variant 2 scripts.