How to Setup Wifibox on FreeBSD to Help Fix Slow Wifi
(work in progress).
The built-in intel wifi drivers whilst they do work, are pretty slow. I was getting a maximum throughput of 12Mbps, after implementing wifibox I was getting much more usable speeds.
What is Wifibox?
Wifibox deploys a Linux guest (based in alpine Linux) to drive a wireless networking card on the FreeBSD host system with the help of PCI pass-through.
This guide has been tested on FreeBSD 13.1
Installing Wifibox
Ensure operating system is and packages are up-to-date
Update operating system:
$ doas freebsd-update fetch install
Update packages:
$ doas pkg update
$ doas pkg upgrade
Install Wifibox from packages
$ doas pkg install wifibox
Configure Wifibox
Configure bhyve passthrough for wireless adapter
In order to configure bhyve wifibox we need to configure PCI pass through for the wifi adapter, it can also be helpful to enable the console.
We need to get he address of the wirelss adapter to pass through:
$ pciconf -lv | grep -B2 -i wireless
Which will give output similar to:
iwm0@pci0:2:0:0: class=0x028000 rev=0x59 hdr=0x00 vendor=0x8086 device=0x095a subvendor=0x8086 subdevice=0x5410
vendor = 'Intel Corporation'
device = 'Wireless 7265'
We can see from the above output in our example, the address of our card is pci0:2:0:0:, so the address we need for the pci card is 2/0/0
Edit the file /usr/local/etc/wifbox/bhyve.conf
and update the passthru parametre:
console=yes
passthru=2/0/0
Where the 2/0/0
in our case is the output from the previous command.
Configure WPA Supplicant
In order for wifibox it needs access to a wpa_supplicant.conf
file know which networks to connect to, for this we’re going to link our existing /etc/wpa_supplicant.conf
:
$ cd /usr/local/etc/wifibox/wpa_supplicant
$ doas mv wpa_supplicant.conf wpa_supplicant.bak
$ doas ln /etc/wpa_supplicant.conf ./
Edit /etc/rc.conf
and add:
### prevent intel wireless drivers loading
devmatch_enable="YES"
devmatch_blocklist="if_iwm if_iwlwifi"
### start wifibox and configure interfaces
wifibox_enable="YES"
ifconfig_wifibox0="SYNCDHCP"
background_dhclient_wifibox0="YES"
defaultroute_delay="0"
For some reason on reboot the the wifibox0
interface fails to get an IP from DHCP, seems to be because the interface doesn’t exist before the bhyve VM is started, work around until I find a solution:
Edit `/etc/rc.local’:
/sbin/dhclient wifibox0
Reboot, all should be good