M.A.C.T.S. v1.01
MACTS is a traffic shaper that uses MAC addresses which are associated with users to classify traffic. This allows fair usage of bandwidth among many machines.
Additionally, there is a statistics monitor that displays current statistics on the terminal, or stores them in round robin databases. The stored data may then be used to generate graphs with the included Perl/CGI scripts.
Finally, the config file is straight-forward and requires little knowledge of networking or the underlying traffic control mechanism. Setup should be easy.
COMPONENTS
macts - This clears the current traffic classifiers and sets up new ones, as directed by /etc/macts/macts.conf. It also stores some temporary state data in /etc/macts/handles.cache.
macts-stats - With no args, this displays statistics on a terminal, including data rate (kb/s), packet rate (packets/s), and backlog (packets) for each machine. Given the -r flag, it stores the statistics in round robin databases (one for each machine), located in /etc/macts/stats/.
macts-chart - This is a CLI chart generator which reads data from RRDs stored in /etc/macts/stats/.
macts-chart.cgi - This is a CGI wrapper for macts-chart.
INSTALL
- mkdir /etc/macts
- mkdir /etc/macts/stats
- create /etc/macts/macts.conf
- add the following lines to /etc/sysctl.conf:
net.ipv4.conf.default.accept_source_route = 1 # not sure if this is necessary net.bridge.bridge-nf-filter-vlan-tagged = 0 net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0
- move macts, macts-stats, and macts-chart to /usr/local/bin/
- create /etc/sysconfig/network-scripts/ifcfg-br0 with the following lines (replace the IP addresses with your configuration): DEVICE=br0 TYPE=Bridge BOOTPROTO=static IPADDR=192.168.0.1 NETMASK=255.255.255.0 BROADCAST=192.168.0.255 NETWORK=192.168.0.0 ONBOOT=yes DELAY=0
- change both /etc/sysconfig/network-scripts/ifcfg-eth* to (replace the with the interface number): DEVICE=eth TYPE=Ethernet ONBOOT=yes BRIDGE=br0
- (recommended) to run at startup, add the following line to /etc/rc.local: /usr/local/bin/macts
- (optional) install rrdtools and the perl rrdtool interface
- (optional) add the following line to root's cron:
*/5 * * * * /usr/local/bin/macts-stats -r 2&> /dev/null
- (optional) move macts-chart.cgi to your web server's cgi directory.
CONFIGURATION
Here's a sample file:
OutsideInterface eth0 UpstreamBandwidth 80 DefaultBinBandwidth 1
<MACS>
00:11:22:33:44:55 will darkstar
00:12:34:56:78:9A ben foo
00:AA:BB:CC:DD:EE ben bar
00:00:DE:AD:BE:EF david
</MACS>
NOTES
This was designed to run on Fedora Core 4, however it should work on any linux system running kernel v2.4+ with small changes. The output of tc has changed recently, so you may have to modify macts-stats's get_stats() function.
TODO
- detect tc's version, and process data accordingly
- add per-user, in addition to per-machine, shaping
- add firewall rules to this README to correct TOS fields for some traffic (ssh, p2p clients, etc.)
- write install script
AUTHOR
MACTS was written by William Knop. If you have questions or comments, feel free to email me at wknop@andrew.cmu.edu.
LICENSE
This program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
