Thursday, May 21, 2020

Associate Wireless Adapter with a Wifi Access Point without assigning an IP address (for use by a Virtual Machine)

I recently signed up for mobile service with a MVNO that uses Sprint's network. A free phone and unlimited data is included with the plan, along with unlimited tethering.

For my home internet setup, I already have a dual-WAN setup using Sophos UTM 9 running in a VirtualBox as the IDS/IPS load-balancing gateway. But still, given the unlimited data and tethering ability with the new cell phone plan, I wanted to add cellular broadband as a fall-back internet connection, mostly as an experiment but also as a useful backup internet uplink.

So I attached a USB wifi adapter to the Dell blade that hosts the Sophos UTM 9 gateway, looking to tether it to the cell phone hotspot only as far as wifi association takes place with no IP address, and connect the wifi-associated wireless lan adapter to the Sophos UTM 9 virtual machine which would then configure it with a DHCP address as another WAN uplink.

The alternative would have been to configure VirtualBox settings to connect the USB wifi adapter directly to the UTM 9 virtual machine. On researching this option, however, it appeared to be a daunting task to get Sophos UTM 9 to configure a wireless network adapter as an internet uplink.

Therefore I created the following bash shell script for the wifi USB dongle to associate with the mobile network. This script runs on the host blade. The UTM VM now has a new additional virtual adapter bridged to the wifi dongle. Everything works great.

### REF:


dhclient -r ${DEVICE}
ifconfig ${DEVICE} down
killall wpa_supplicant
rm -f /run/wpa_supplicant/${DEVICE}

ifconfig ${DEVICE} up
sleep 5

# wpa_supplicant.conf should have the output generated by "wpa_passphrase WIFI-SSID WIFI-PASSWORD"
wpa_supplicant -B -i ${DEVICE} -Dwext -s -c /etc/wpa_supplicant/wpa_supplicant.conf

iwlist ${DEVICE} scan

echo "Connecting, please wait"

sleep 10

iwconfig ${DEVICE} rate 32M
iwconfig ${DEVICE}

echo "Check association with \"iwconfig ${DEVICE}\""
echo "Get IP address if needed with \"dhclient ${DEVICE}\""

exit 0

"SIOCSIFFLAGS: Operation not possible due to RF-kill"

If you get the above error when you try to bring the wifi adapter up, the kernel has "soft blocked" your wireless adapter. To unblock it, do the following as root:

# rfkill list
1: phy1: Wireless LAN
Soft blocked: yes
Hard blocked: no

# rfkill unblock all

# rfkill list
1: phy1: Wireless LAN
Soft blocked: no
Hard blocked: no

No comments:

Post a Comment

"SEO" link builders: move on, your spam link will not get posted.

Recommended Products from Amazon