This is working for me on Linux (Kali). You may need to change addresses, gateways, or netmasks based on your personal situation. Sorry if you don't need this, for the next person to stumble here though, as I did moments ago.
Where <your-nicN> is what you see from an ifconfig such as eth0 or wlan0
sudo ip link add link <your-nicN> mac0 type macvlan && sudo ifconfig mac0 up
That creates a new "virtual" interface called mac0 and brings it up. I added the the up command because a first I thought this didn't work, but sudo ip link show [tab][tab] plus a double tab completed with a list that included mac0 I then proceeded to bring it up with ifconfig and assign it an address.
Just Remember to assign it an ip address or tell it to use dhcp
ifconfig mac0 inet 192.168.1.107 netmask 255.255.255.0 #static/manual config
or
dhclient mac0 # For a dhcp-client, to get ip from router.
if you need to assign a default gateway:
sudo ip route add default via 192.168.1.1
The place I got some of this from is here:
http://www.pocketnix.org/posts/Linux%20Networking:%20MAC%20VLANs%20and%20Virtual%20Ethernets
Edit3: I tried messing with "bond" and ifenslave but I need to do a bit more studying on that, I couldn't really figure it out. What I did do though what set up an "EtherSwitch Router" in GNS3 and then assigned a "cloud" ten of the macN devices on one "end" and then another "cloud" to a vmware host only adapter, virtualbox would probably work the same, on the other "end", I am going to mess around with that a bit and see if I can limit the speed on the macN devices to simulate an "aggregation" or if I can distribute the load across the ten connections for "increased" bandwidth. Maybe if I set them all to txqueuelen:10 on Linux. I have DragonflyBSD on the other "end" of this, I will attempt to connect it to my real router via GNS3.
Edit2: Here is a quick script to get as many up as you need with dhclient.
It needs to be ran as root. So create the file, then chmod 750 <script> and run it with sudo if you can/have to. I use it like this : ./crazy-mac.sh 20 it takes the first argument and creates that many new interfaces each with its own mac and ip address. There are no sanity checks so use it wisely, or add some yourself ;)
Note : Make sure to connect with your normal wlan0 first or else this wont work.
how-to-connect-manually-to-a-wireless-ap
Also if their is mac access control list on the router you might need to do some some sniffing to gain a list of mac address accepted by the router. You will then need to edit the script to parse a file with that list and use a line for each $i in the sequence instead of allowing this to create random mac addresses.
Note2: You might want to put some a sleep <N> in the loop somewhere, this will bring up many "devices" sequentially and will probably raise some red flags if anyone is paying attention to the network. I don't think 20 some devices will pop up in this fashion under normal circumstances.
#!/bin/sh
## crazy-mac.sh
for i in $(seq ${1}); do
ip link add link wlan0 mac${i} type macvlan && \
ifconfig mac${i} up && \
dhclient mac${i};
done
And to bring them down: Again just a quick script...
#!/bin/sh
## crazy-down.sh
for i in $(seq ${1}); do
ifconfig mac${i} down && \
ip link delete mac${i};
done
And if you need a list of mac addresses this is working with bash when a file is a list of one mac address per line in the file.
#!/bin/bash
## crazy-mac2.sh
## Usage : crazy-mac2.sh <N> </path/to/mac-list.txt>
MACLIST=($(cat ${2}))
# This is for testing, comment this and uncomment out the other for loop
# if this one works the other should also.
for i in $(seq ${1}); do
echo "mac${i} : ${MACLIST[${i}-1]}"; done
#for i in $(seq ${1}); do
# ip link add link wlan0 mac${i} address ${MACLIST[${i}-1]} type macvlan && \
# ifconfig mac${i} up && \
# dhclient mac${i};
#done
unset MACLIST
Edit: I was just reading about "lagg" devices (at least for unix) that can be used to aggregate multiple interfaces into a single "lagg" interface to increase performance or to provide fall backs should one go down for whatever reason.
I was just thinking about how this would be useful in a situation where the bandwidth was limited per mac address, it might be able to be used in such a situation so that you can take all the many virtual macN interfaces and aggregate the bandwidth into a single interface and then perhaps tun/tap that to a virtual host or something. This is interesting to me, I'll try to set up bandwidth limit on my personal wifi per mac address to recreate the scenario and attempt this I'll be back.