|
1 | | -# MAC-Shaper |
2 | | -Per-MAC bandwidth control for OpenWrt |
| 1 | +# MAC-Shaper — Per-MAC bandwidth control for OpenWrt |
| 2 | + |
| 3 | +<img src="https://github.com/DimaDoesCode/MAC-Shaper/blob/main/mac-shaper.jpeg" width="200" height="200" align="left"/> |
| 4 | +<b>mac-shaper</b> is a lightweight traffic shaping solution for OpenWrt that allows you to limit or control bandwidth <b>per MAC address</b> using Linux <code>tc</code> and <code>ifb</code>.<br><br> |
| 5 | + |
| 6 | +It consists of:<br> |
| 7 | + - a backend daemon and init script<br> |
| 8 | + - LuCI web interface<br> |
| 9 | + - optional meta-package for easy installation |
| 10 | + |
| 11 | +✅ Tested on **OpenWrt 24.10.4**. ❌ Not compatible with **OpenWrt 24.10.5**. |
| 12 | + |
| 13 | +📦 **[Browse Packages & Documentation](https://dimadoescode.github.io/MAC-Shaper/)** |
| 14 | +🚀 **[Latest Release](https://github.com/DimaDoesCode/MAC-Shaper/releases/latest)** |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## ✨ Features |
| 19 | + |
| 20 | +- Per-MAC upload & download rate limiting |
| 21 | +- Enable / disable individual rules without deleting them |
| 22 | +- Fast reload without reboot |
| 23 | +- LuCI UI with inline enable/disable checkboxes |
| 24 | +- Clean UCI-based configuration |
| 25 | +- Designed for embedded devices |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +## 📦 Packages |
| 30 | + |
| 31 | +| Package | Description | |
| 32 | +|------|------------| |
| 33 | +| `mac-shaper` | Backend scripts, init.d service | |
| 34 | +| `luci-app-mac-shaper` | LuCI web interface | |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## 🧰 Requirements |
| 39 | + |
| 40 | +- OpenWrt **24.10.4** |
| 41 | +- Kernel support for: |
| 42 | + - `tc` |
| 43 | + - `ifb` |
| 44 | + - `sch_htb` |
| 45 | + |
| 46 | +--- |
| 47 | + |
| 48 | +## 🚀 Installation |
| 49 | + |
| 50 | +### Method 1: Using Custom Feed (Recommended) |
| 51 | + |
| 52 | +📦 **Browse all available packages:** [https://dimadoescode.github.io/MAC-Shaper/](https://dimadoescode.github.io/MAC-Shaper/) |
| 53 | + |
| 54 | +**Step 1:** Add the custom feed to your router |
| 55 | + |
| 56 | +Choose your architecture from the list below (or visit the [package repository](https://dimadoescode.github.io/MAC-Shaper/) to browse all available targets): |
| 57 | + |
| 58 | +| Architecture | Feed URL | |
| 59 | +|-------------|----------| |
| 60 | +| ipq806x-generic | `https://dimadoescode.github.io/MAC-Shaper/ipq806x-generic` | |
| 61 | +| mvebu-cortexa9 | `https://dimadoescode.github.io/MAC-Shaper/mvebu-cortexa9` | |
| 62 | + |
| 63 | +```sh |
| 64 | +# SSH into your OpenWrt router |
| 65 | +ssh root@192.168.1.1 |
| 66 | + |
| 67 | +# Add the feed (replace URL with your architecture) |
| 68 | +echo "src/gz mac_shaper_feed https://dimadoescode.github.io/MAC-Shaper/ipq806x-generic" >> /etc/opkg/customfeeds.conf |
| 69 | +``` |
| 70 | + |
| 71 | +**Step 2:** Disable signature checking |
| 72 | + |
| 73 | +Since these packages are not officially signed, you need to temporarily disable signature verification: |
| 74 | + |
| 75 | +```sh |
| 76 | +# Edit the opkg configuration |
| 77 | +vi /etc/opkg.conf |
| 78 | + |
| 79 | +# Find the line: |
| 80 | +# option check_signature |
| 81 | +# And comment it out by adding # at the beginning: |
| 82 | +# #option check_signature |
| 83 | + |
| 84 | +# Or use sed to do it automatically: |
| 85 | +sed -i 's/^option check_signature/#option check_signature/' /etc/opkg.conf |
| 86 | +``` |
| 87 | + |
| 88 | +**Step 3:** Install packages |
| 89 | + |
| 90 | +```sh |
| 91 | +opkg update |
| 92 | +opkg install mac-shaper luci-app-mac-shaper |
| 93 | +``` |
| 94 | + |
| 95 | +**Step 4:** (Optional) Re-enable signature checking |
| 96 | + |
| 97 | +After installation, you can re-enable signature verification for official packages: |
| 98 | + |
| 99 | +```sh |
| 100 | +sed -i 's/^#option check_signature/option check_signature/' /etc/opkg.conf |
| 101 | +``` |
| 102 | + |
| 103 | +⚠️ **Security Note:** Disabling signature checks should be done carefully. Only install packages from trusted sources. You can re-enable signature verification immediately after installing these packages. |
| 104 | + |
| 105 | +### Method 2: Manual Installation from Releases |
| 106 | + |
| 107 | +Download the `.ipk` files for your architecture from the [Releases page](https://github.com/DimaDoesCode/MAC-Shaper/releases/latest) and install them manually: |
| 108 | + |
| 109 | +```sh |
| 110 | +# Transfer files to your router |
| 111 | +scp *.ipk root@192.168.1.1:/tmp/ |
| 112 | + |
| 113 | +# SSH into router and install |
| 114 | +ssh root@192.168.1.1 |
| 115 | +cd /tmp |
| 116 | +opkg install mac-shaper_*.ipk |
| 117 | +opkg install luci-app-mac-shaper_*.ipk |
| 118 | +``` |
| 119 | + |
| 120 | +--- |
| 121 | + |
| 122 | +## ⚙️ Configuration |
| 123 | + |
| 124 | +Configuration file: `/etc/config/mac-shaper` |
| 125 | + |
| 126 | +Example: |
| 127 | +```sh |
| 128 | +config mac-shaper 'general' |
| 129 | + option device 'br-lan' |
| 130 | + option default_bw '200mbit' |
| 131 | + option burst 'auto' |
| 132 | + option cburst 'auto' |
| 133 | + |
| 134 | +config rule |
| 135 | + option mac 'AA:BB:CC:DD:EE:FF' |
| 136 | + option rate '50mbit' |
| 137 | + option enabled '1' |
| 138 | + option comment 'Laptop' |
| 139 | +``` |
| 140 | +Apply changes: |
| 141 | +```sh |
| 142 | +/etc/init.d/mac-shaper reload |
| 143 | +``` |
| 144 | + |
| 145 | +--- |
| 146 | + |
| 147 | +## 🖥 LuCI Web Interface |
| 148 | + |
| 149 | +LuCI interface is available under: |
| 150 | +`Services → MAC Shaper` |
| 151 | + |
| 152 | +<img src="https://github.com/DimaDoesCode/MAC-Shaper/blob/main/LuCI.png" width="614" height="500" align=""/> |
| 153 | + |
| 154 | +Features: |
| 155 | +- quick enable / disable of rules |
| 156 | +- live status display |
| 157 | +- safe testing of limits |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## 🛠 Supported Targets |
| 162 | + |
| 163 | +| Target | Architecture | Common Devices | |
| 164 | +|--------|-------------|----------------| |
| 165 | +| ipq806x-generic | ARM Cortex-A15 | Linksys E8350, Netgear R7800, TP-Link C2600 | |
| 166 | +| mvebu-cortexa9 | ARM Cortex-A9 | Linksys WRT1900AC/S, WRT3200ACM | |
| 167 | + |
| 168 | +More targets can be added easily via CI. Open an issue to request support for your device! |
| 169 | + |
| 170 | +--- |
| 171 | + |
| 172 | +## 🔧 Troubleshooting |
| 173 | + |
| 174 | +### Package installation fails |
| 175 | +- Ensure you've disabled signature checking (see Installation Step 2) |
| 176 | +- Verify your router's architecture matches the feed URL |
| 177 | +- Check that you have enough storage space: `df -h` |
| 178 | + |
| 179 | +### Service doesn't start |
| 180 | +```sh |
| 181 | +# Check service status |
| 182 | +/etc/init.d/mac-shaper status |
| 183 | + |
| 184 | +# View logs |
| 185 | +logread | grep mac-shaper |
| 186 | + |
| 187 | +# Check if required kernel modules are loaded |
| 188 | +lsmod | grep ifb |
| 189 | +lsmod | grep sch_htb |
| 190 | +``` |
| 191 | + |
| 192 | +### Rules not applying |
| 193 | +```sh |
| 194 | +# Verify configuration syntax |
| 195 | +uci show mac-shaper |
| 196 | + |
| 197 | +# Reload service |
| 198 | +/etc/init.d/mac-shaper reload |
| 199 | + |
| 200 | +# Check traffic control rules |
| 201 | +tc qdisc show |
| 202 | +tc class show dev ifb0 |
| 203 | +``` |
| 204 | + |
| 205 | +--- |
| 206 | + |
| 207 | +## 📜 LICENSE |
| 208 | + |
| 209 | +```text |
| 210 | +GNU GENERAL PUBLIC LICENSE |
| 211 | +Version 3, 29 June 2007 |
| 212 | +
|
| 213 | +Copyright (C) 2025 |
| 214 | +
|
| 215 | +This program is free software: you can redistribute it and/or modify |
| 216 | +it under the terms of the GNU General Public License as published by |
| 217 | +the Free Software Foundation, either version 3 of the License, or |
| 218 | +(at your option) any later version. |
| 219 | +
|
| 220 | +This program is distributed in the hope that it will be useful, |
| 221 | +but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 222 | +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 223 | +GNU General Public License for more details. |
| 224 | +
|
| 225 | +You should have received a copy of the GNU General Public License |
| 226 | +along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 227 | +``` |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +## 🤝 Contributing |
| 232 | + |
| 233 | +Pull requests and issues are welcome! Please feel free to: |
| 234 | +- Report bugs |
| 235 | +- Request new features |
| 236 | +- Submit pull requests |
| 237 | +- Request support for additional architectures |
| 238 | + |
| 239 | +--- |
| 240 | + |
| 241 | +## 📊 Build Status |
| 242 | + |
| 243 | +Packages are automatically built using GitHub Actions for multiple OpenWrt targets. Check the [Actions tab](https://github.com/DimaDoesCode/MAC-Shaper/actions) for build status. |
| 244 | + |
| 245 | +**Latest Release:** [](https://github.com/DimaDoesCode/MAC-Shaper/releases/latest) |
0 commit comments