Jump to content

Grant amount of network traffic


and_woox
 Share

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?

Thanks

Link to comment
Share on other sites

something like this:

 

#!/usr/bin/perl 

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...