Jump to content

Grant amount of network traffic


Recommended Posts

Please i'm working on an iptables script where i can grant a certain amount of monthly traffic, for example grant 8g to one client per month and if he passes that amount his connection becomes unavailable.

I'm trying to find a command that serves as a network traffic counter.

What should i be looking for?


Link to comment
Share on other sites

something like this:



my @eths = qw ( eth0 eth1 eth2 eth3 eth4);

for my $eth(@eths) {
$count = 0; my $rxbytes = 0; my $txbytes = 0; 
for (`/sbin/ip -s link show $eth`) {  
	chomp; $count++;
	if ($count == 4) {
		($rxbytes, $rest) = split;
	} elsif ($count == 6) {  
		($txbytes, $rest) = split;
print "$eth $rxbytes $txbytes\n";

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...