Unable to connect to multiple WiFi networks via multiple virtual interfaces
My laptop have an atheros WiFi card, I created 2 virtual interfaces on top of it, with following commands:
- iw dev wlan0 interface add vlan0 type station
- iw dev wlan0 interface add vlan1 type station
I changed their mac addresses, as:
- macchanger -e vlan0
- machhanger -e vlan1
and then I turned them on,:
- ifconfig vlan0 up
- ifconfig vlan1 up
I want to connect both these interfaces to 2 different networks. Lets say I have SSID1 and SSID2 broadcast by 2 different APs.
I execute below command to do that:
- iw dev vlan1 connect SSID1
- iw dev vlan2 connect SSID2
The problem is, vlan1 is able to connect but vlan2 could not. In order to find an answer I traced the frames in the air, I see when vlan2 is asked to connect it sends probe requests and get probe responses from SSID2 but it never sends association request.
However, if I try to connect both vlan1 and vlan2 to one SSID - SSID1/2 both of them are able to connect and associate.
The question is, why 2 different virtual interfaces are not able to connect to 2 different networks?
Generally speaking, a single Wi-Fi card only has a single radio, so it can only be tuned to a single channel at a time. Cards that support MIMO (2 or more spatial streams) technically have multiple radios in one sense, but they're ganged together; they're only designed to work as a team, on the same channel.
If the nearest APs publishing the two SSIDs you're interested in are on different channels, then you won't be able to connect to both because your radio can't be tuned to both channels at the same time. Trying to rapidly switch back and forth between channels (known as "Time Division Duplexing" or TDD) is just not a recipe for success; you'd end up missing lots of packets on both networks. Even if your card used 802.11 Power Save mode wisely to ask the APs to queue up packets while the client is on the other channel, the client will probably still miss important multicasts/broadcasts including ARP Requests.
You can't connect to two networks from the same PC if you have only one WIFI card.
Even if you have two virtual machines, and you are trying to connect from those to two networks - what you are trying to do is to have to programs, on the same PC, to use the same WIFI card to connect to different networks.
That is just not possible.