How to Connect to Multiple WiFi APs Simultaneously with a Single Adapter in Linux/FreeBSD


2 views

Connecting to multiple access points simultaneously with a single WiFi adapter presents unique technical challenges due to hardware limitations and protocol constraints. Unlike wired interfaces where VLANs or interface aliases (eth0:1) can create logical separation, wireless connections require more sophisticated handling.

While most WiFi hardware can't maintain multiple concurrent client connections natively, we can implement creative solutions:


# Example for Ubuntu using wpa_supplicant multiple instances
# First interface (wlan0)
sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/conf_ap1.conf -D nl80211,wext -B

# Second virtual interface (wlan0_1)
sudo iw dev wlan0 interface add wlan0_1 type managed
sudo wpa_supplicant -i wlan0_1 -c /etc/wpa_supplicant/conf_ap2.conf -D nl80211,wext -B

For pfSense users wanting to connect to multiple APs:

  1. Create VLAN interfaces under Interfaces > Assignments
  2. Configure separate wireless interfaces for each AP
  3. Use bridge interfaces to combine connections if needed

Linux's mac80211 framework enables virtual interfaces with different MAC addresses:


# Check driver capabilities
iw list | grep "valid interface combinations"

# Create virtual interfaces
sudo iw phy phy0 interface add wlan1 type managed 4addr on
sudo iw dev wlan1 set mac $(macchanger -r wlan1 | grep New | awk '{print $3}')
  • Performance impact: Each virtual interface shares the same physical radio
  • Security implications: Different networks may have conflicting firewall rules
  • Roaming behavior: The system won't automatically failover between APs

For Ubuntu systems, consider using network namespaces to isolate connections:


# Create network namespace
sudo ip netns add network2

# Move virtual interface to namespace
sudo iw phy phy0 interface add wlan1 type managed
sudo ip link set wlan1 netns network2

# Configure connection inside namespace
sudo ip netns exec network2 dhclient wlan1

Not all wireless chipsets support multiple virtual interfaces. Check compatibility with:


lspci -k | grep -A 3 -i wireless
iw list

Unlike wired networks where interface aliasing (eth0:1) allows multiple IP assignments, wireless interfaces traditionally associate with only one AP at a time due to 802.11 protocol constraints. However, advanced configurations using virtual interfaces can achieve concurrent connections.

Modern Linux kernels (since 2.6.24) support creating multiple virtual wireless interfaces from a single physical device:

# Create virtual interface (replace wlan0 with your device)
iw dev wlan0 interface add wlan0_sta1 type station
iw dev wlan0 interface add wlan0_sta2 type station

# Verify creation
iwconfig

For pfSense/FreeBSD, use ifconfig cloning with unique MAC addresses:

# Create cloned interface
ifconfig wlan0 create wlandev ath0 wlanmode sta clone lladdr 00:12:34:56:78:9A

# Connect to first AP
ifconfig wlan0 inet 192.168.1.100 ssid AP1 wpakey password1 up

# Connect cloned interface to second AP
ifconfig wlan0_sta1 inet 192.168.2.100 ssid AP2 wpakey password2 up

For desktop environments using NetworkManager, configure connection profiles:

# Create connection profile for AP1
nmcli con add type wifi ifname wlan0 con-name AP1 \
    ssid AP1 wifi-sec.key-mgmt wpa-psk wifi-sec.psk password1

# Create second profile for AP2 using same interface
nmcli con add type wifi ifname wlan0 con-name AP2 \
    ssid AP2 wifi-sec.key-mgmt wpa-psk wifi-sec.psk password2

# Activate both connections
nmcli con up AP1
nmcli con up AP2
  • Ath9k and iwlwifi drivers generally support virtual interfaces
  • Realtek rtl8187/rtl8192cu may require patched drivers
  • Check supported modes with: iw list | grep "valid interface combinations"

When using multiple gateways, configure policy routing:

# Create separate routing tables
echo "100 AP1" >> /etc/iproute2/rt_tables
echo "200 AP2" >> /etc/iproute2/rt_tables

# Add default routes
ip route add default via 192.168.1.1 dev wlan0 table AP1
ip route add default via 192.168.2.1 dev wlan0_sta1 table AP2

# Add routing rules
ip rule add from 192.168.1.100 lookup AP1
ip rule add from 192.168.2.100 lookup AP2

The physical radio must time-share between virtual interfaces, causing:

  • Potential throughput reduction (~30-50% per additional connection)
  • Increased latency from channel switching
  • Possible packet loss during roaming events