On a linux server with dhcpd that acts as the internet gateway for all clients of the LAN: how can I monitor the internet usage based on IP/MAC address, and deny internet access if a certain bandwidth consumption has been exceeded?
On Linux, you could get this done with some scripting:
- Create firewall rules with
iptablesso that all bandwidth for each client passes through a separate rule. The firewall subsystem in the kernel will count network packets and bytes that a particular rule matched. You can see the counters if you run
iptables -vL. You might want to use the
-noption too, for performance:
- Write a script that runs from cron and which checks how much data has been used by every client. Then if it's over a particular amount, have the script modify the firewall so that the client can not access the Internet anymore
iptables' counters get reset when the firewall is cleared (i.e., after reboot, or when you do
iptables -F. As such, you might want to have the script state its conclusions to some database or something.
Your answer is given here on Serverfault for limiting traffic
and for monitoring that traffic install iftop