# Setup wifi network step-by-step



## vince66 (Sep 14, 2018)

Hello guys,

I'm following the FreeBSD Handbook to setup a wifi network.
The Desktop computer on which I want to do this has a PCI wifi network card (you can see it in the picture below).








*STEP 1: IDENTIFY THE NETWORK CARD*
The command: `sysctl net.wlan.devices`  returns a blank prompt.
So, I've analyzed the installed hardware with commands: `pciconf -lv` and `dmesg | grep pci`





If I've well understood, my PCI network card on pci 0:1:0:0 *has no a driver attached* (I think that this means I need to search the correct driver for the wifi connected card).

This device is shown as using an Broadcom chip BCM43131.

*STEP 2: IDENTIFY THE DRIVER FOR THE NETWORK CARD*
To do this I've run the command: `apropos Broadcom`, obtaining a list of possible drivers.

*QUESTION.*
1 - I think that the next step is to notify the driver to the kernel. *In which a way ?*
2 - It seems that what I've shown here per images is hardware indipendent, that is running the previous commands on a laptop (booted with the same USB stick) I obtain the same results.

Any help is apreciated.
Thanks in advance.


----------



## SirDice (Sep 14, 2018)

vince66 said:


> I think that the next step is to notify the driver to the kernel. In which a way ?


kldload(8) the correct kernel module.


----------



## Minbari (Sep 14, 2018)

Add in /boot/loader.conf the bwi driver

```
if_bwi_load="YES"
```


----------



## vince66 (Sep 14, 2018)

Hello.



Minbari said:


> bwi driver



Are you sure ? Have you just tried ?
Because the bwi(4) says:

" This driver requires firmware to be loaded    before it will work.  The _ports/net/bwi-firmware-kmod_ port needs to be installed before ifconfig(8) will work. "

Googling it also seems that: 

" The firmware port installs a module that must also be loaded:

bwi_v3_ucode "

Have you experienced with the above interface card driver ?


*Another question:*

To join the BSS network of my lab with network name ``my_netlab'', I use the command:

`ifconfig wlan create wlandev bwi0 ssid my_netlab up`


*where I've had to specify the wpa/wpa2 pass_key ?*


----------



## vince66 (Sep 15, 2018)

pyret said:


> /etc/wpa_supplicant.conf





pyret said:


> /etc/rc.conf



Ok ... I've again do my question in a wrong way. I try to be more clear:

Are the info contained in the /etc/wpa_supplicant.conf and /etc/rc.conf related with the driver of the network card ?
( the correct driver seems to be bwi(4), or probably the new one bwn(4) ).

If they are related in which part of the files the driver bwi is mentioned ?

That is: 
/etc/wpa_supplicant.conf and /etc/rc.conf are configuration files executed at the boot time. 
If so, their task is to inform the driver to sniff the network, to start up a connections, etc .... etc ......

Or not ?

Thanks very much.


----------



## kpa (Sep 15, 2018)

The rc.conf(5) settings are used to bring up the interface first to a known state. Then wpa_supplicant(8) is hooked up to process where the interface is told to associate with an access point and wpa_supplicant(8) will then apply its configuration based on the matching SSID to the interface and will set up the encryption. After this the IP address set up is done either by manual set up or DHCP.

Btw the configuration files are not executed, they are not program code where statements are executed in order. They are rather a set of settings that are either simple variable assignments or applied if they match certain conditions like the SSID. With rc.conf(5) the order isn't important but if you repeat the same setting twice only the latter will be in effect, for example:


```
hostname="host1.mydomain"
...
hostname="host2.mydomain"
```

With those hostname would be set just to "host2.mydomain".


----------



## vince66 (Sep 15, 2018)

pyret said:


> /etc/wpa_supplicant.conf





pyret said:


> /etc/rc.conf





kpa said:


> The rc.conf(5) settings are used to bring up the interface first to a known state. Then wpa_supplicant(8) is hooked up to process where the interface is told to associate with an access point and wpa_supplicant(8)



Ok ... if it is so simple I only need to "copy and paste" the code shown in the above files.

Let me try to arrange them for my network ... I'll post the results here.


A question please .....



SirDice said:


> kldload(8)





Minbari said:


> Add in /boot/loader.conf the bwi driver



Once the (correct) network card driver has been installed which command can I use to see if the card is usable ?
- ifconfig(8) is one for example ...
- dmesg(8) (related to the boot phase) ....
- which others ????


----------



## vince66 (Sep 15, 2018)

Minbari said:


> Add in /boot/loader.conf the bwi driver



I hope that is the only necessary line to add to /boot/loader.conf ... for the above mentioned driver obvioulsy.


----------



## vince66 (Sep 20, 2018)

SirDice said:


> the correct kernel module



The problem is:
is there a way to find the name of correct kernel module.

In this case is maybe the driver's name: bwn ?



kpa said:


> The rc.conf(5) settings are used to bring up the interface first to a known state.


Before configure rc.conf, immediately after the driver has been installed, how can I see if the net card is recognized by FreeBSD ?
I thought ifconfig, but ....
neither the driver name nor any reference to the hardware card are shown running ifconfig.

Thanks !!!


----------



## vince66 (Sep 20, 2018)

pyret said:


> ```
> # sysctl net.wlan.devices
> net.wlan.devices: wpi0
> ```



 wpi ???? Do you visualize it ? after net.wlan .devices?

With a Broadcom BCM34131 chip?


----------

