Need a mark bit for a VPN or rate limit? Check before shrinking the mwan3 mask. Counting from bit zero on the right, 0x3F00 uses bits 8 through 13. It overlaps 0x100. Other rules might still use 0x1.
Read the active mask
Run these commands over SSH on the router. If the first prints nothing, find the local script default. Compare it with the fwmark masks in both rule lists.
uci show mwan3 | grep mmx_mask
grep -nE 'mmx_mask|MWAN3_INTERFACE_MAX' /lib/mwan3/common.sh
ip -4 rule show
ip -6 rule show
The capacity calculation below comes from the OpenWrt packages 24.10 branch. If the path, formula or active value differs, check your installed version. Saved edits may still be pending.
Check overlap and capacity separately
These commands only do arithmetic. The screenshot shows a shell in an OpenWrt 25.12.6 VM. It does not test failover. Substitute your mask and candidate bits.
echo $((0x3f00 & 0x100))
echo $((0x3f00 & 0x1))
echo $(((1 << 6) - 4))
echo $(((1 << 3) - 4))
printf '0x%x\n' $((0x200 | 0x1))
printf '0x%x\n' $((0x201 & 0x3f00))

The first two bitwise AND results are 256 for overlap and 0 for no overlap with this mask alone. The next two calculate the interface limit as 2ⁿ − 4 for n set bits. Six bits allow 60 managed interfaces. Three allow four, too few for two existing links plus three more.
Why can a free bit still break routing?
The last pair combines 0x1 with an existing 0x200 to get 0x201. Reading through the original mask still gives 0x200. Assigning the entire mark to 0x1 loses that value. Check VPN, shaping and connection mark save and restore masks too.
Keep the mask if a bit is free across all rules. Back up mwan3 and custom rules first. Change only your bit and mask the match. Open fresh matching and bypass connections, checking counters and exits. Test the backup link during maintenance. If routing changes unexpectedly, restore both configurations, reload and retest with new connections.
Verify mwan3 failover and per-connection balancing across two WANs
Comments