My wifibox setup

Help with setting up network cards, including WiFi cards.
Post Reply
matuzalem
Posts: 1
Joined: Wed Aug 30, 2023 1:48 pm

My wifibox setup

Post by matuzalem »

I installed Wifibox using the GhostBSD Software Station:
I simply searched for “wifibox” selected it and the dependencies followed:

Code: Select all

    grub2-bhyve
    socat
    wifibox
    wifibox-alpine
    wifibox-core
Configuration:

After the installation to the system, check the sample configuration files provided in the /usr/local/etc/wifibox directory and follow the instructions to create a working configuration, otherwise wifibox will refuse to start. For systems that might be put in sleep mode, e.g. laptops, there is a sample devd.conf(5) configuration file in the /usr/local/etc/devd directory that can be used to restart wifibox on resume.

get wifi card specs:

I used pciconf -lBbcevV iwm0 to get the pci address of my Wi-Fi card

Code: Select all

iwm0: <Intel(R) Dual Band Wireless AC 9560>
iwm0@pci0:0:20:3
Then I added it to the bhyve.conf file
Wifibox configuration

Code: Select all

# cat /usr/local/etc/wifibox/bhyve.conf

Code: Select all

cpus=1
memory=128
console=yes
passthru=0/20/3
I edited the provided devd/wifibox.conf file so that Wifibox continues to work after putting the laptop to sleep. I copied these settings from the discussions on the wifibox github page. These settings have been working for me so far.

Code: Select all

# This is a `devd(8)` configuration file to run the resume action of

# wifibox on the ACPI resume event. Review the contents and create a

# copy of it without the `.sample` extension to use it. Restart the
# `devd` service once the file has been created.

notify 11 {
match "system" "ACPI";
match "subsystem" "Suspend";
action "logger 'Stopping wifibox before suspend' && /usr/local/sbin/wifibox stop && /etc/rc.suspend acpi $notify";
};

notify 11 {    
match "system" "ACPI";    
match "subsystem" "Resume";    
action "/etc/rc.resume acpi $notify && logger 'Starting wifibox after resume and getting IP via DHCP' && /sbin/kldunload vmm && /sbin/kldload vmm && /usr/local/sbin/wifibox start guest && /sbin/dhclient wifibox0";
};
The next file I edited was the /usr/local/etc/wifibox/wpa_supplicant/wpa_supplicant.conf file. All I had to do was copy over the WiFi settings for my connection from the FreeBSD /etc/wpa_supplicant.conf file

Next configure the Host:

Disable local WiFi and enable Wifibox

By default, PCI pass-through is disabled for AMD-based hardware, hence it must be explicitly enabled via the corresponding syctl(8) variable. This can be done by adding the following line to either /etc/sysctl.conf or /boot/loader.conf depending on whether vmm(4) is going to be loaded by wifibox or it is already loaded at boot.

added this line to /boot/loader.conf

Code: Select all

# Wifibox
hw.vmm.amdvi.enable=1
In order to make wifibox work as a system service, the following line has to be added to rc.conf(5).

Code: Select all

wifibox_enable="YES"
At the same time, make sure that no FreeBSD driver is configured for the same device and remove all the related settings from there. The devmatch(8) utility might be used to stop any conflicting drivers from loading automatically. For example, the iwm(4) and iwlwifi(4) native drivers could be disabled in rc.conf(5) as shown below.

Code: Select all

devmatch_enable="YES"
devmatch_blocklist="if_iwm if_iwlwifi"
I made the following changes to my /etc/rc.conf file:
Disabled local wifi:

Code: Select all

#WiFi
#wlans_iwm0="wlan0"
#ifconfig_wlan0="WPA DHCP"
#create_args_wlan0="wlanmode sta regdomain FCC country US"
#wlandebug_wlan0="+state +node +auth +assoc +dot1xsm +wpa +scan"
Enabled Wifibox service:

Code: Select all

## ## WIFIBOX ## ##
wifibox_enable="YES"
devmatch_enable="YES"
devmatch_blocklist="if_iwm if_iwlwifi"
#DHCP
ifconfig_wifibox0="SYNCDHCP"
background_dhclient_wifibox0="YES"
defaultroute_delay="0"
defaultrouter="10.0.0.1"
## ## end wifibox ## ##
Using Wifibox

The wifibox0 networking interface can be brought up with the use of the netif service.

Code: Select all

# service netif start wifibox0
For static IP address configurations, the routing service has to be restarted as well.

Code: Select all

# service routing restart
After configuring Wifibox and GhostBSD to use Wifibox I restarted my computer. Then I ran:

Code: Select all

#service netif start wifibox0
and Wifibox instantly connected to my WiFi! To verify that Wifibox was working as intended. I ran a speed test and was able to get the fastest speed available on my WiFi network connection and hardware:

Code: Select all

Idle Latency: 6.47 ms (jitter: 0.84ms, low: 5.83ms, high: 7.14ms)

Download: 556.38 Mbps (data used: 982.2 MB)
20.03 ms (jitter: 16.97ms, low: 8.80ms, high: 286.34ms)

Upload: 235.55 Mbps (data used: 229.0 MB)
11.10 ms (jitter: 5.34ms, low: 5.31ms, high: 32.83ms)

Packet Loss: 0.0%
Solution to bring up wifibox automatically on reboot: From:https://forums.sheridancomputers.co.uk/ ... reesbd/102

To bring the wifibox0 interface up on reboot create a /etc/rc.local script. This file probably doesn’t exist on your machine because its the old way of doing rc scripting but this seems to be the easiest way to have wifibox work upon restart of the machine.

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:

#cat /etc/rc.local

Code: Select all

    /sbin/dhclient wifibox0
Reboot, all should be good
Post Reply