Usually we connect the Raspberry Pi to the existing network.
But there are situations when we need to setup wireless access point.
This is for example, when the Raspberry Pi works as server for accepting data from different devices in a location without a network.
Here is an description how to setup a Wireless Access Point on the Raspberry Pi running FreeBSD 10.
Setup an adapter
First, we need an WiFi adapter which support hostap mode.
We should see HOSTAP in the list of the adaptor’s capabilities:
ifconfig wlan0 create wlandev ath0
ifconfig wlan0 list capsdrivercaps=6f85edc1<STA,FF,TURBOP,IBSS,HOSTAP,AHDEMO,TXPMGT,SHSLOT,SHPREAMBLE,MONITOR,MBSS,WPA1,WPA2,BURST,WME,WDS,BGSCAN,TXFRAG> cryptocaps=1f<WEP,TKIP,AES,AES_CCM,TKIPMIC>
In the FreeBSD Manual Pages I found three chipsets for USB WiFi adapters which support HostAP mode.
This are rum(4), run(4) and ural(4) adapters.
Each manual page has a list of adapters from different manufacturers.
I found in one local store D-Link DWA-140 rev B1.
I inserted it into my Raspberry Pi, booted it with the last FreeBSD 10 stable snapshot and checked
We don’t see any WiFi adapters, only Loopback and wired Ethernet.
Let’s load kernel modules for our adapter by hand:
We got our adapter.
Now we need to create a
wlan pseudo-device from our adapter:
ifconfig wlan0 create wlandev run0
And we got an message that we need to load
wlan_amrr module. Let’s load it:
Let’s check its capabilities:
ifconfig wlan0 list caps
My adapter supports HostAP mode!
Now we need to recreate a
wlan pseudo-device to put it in HostAP mode.
ifconfig wlan0 destroy
ifconfig wlan0 create wlandev run0 wlanmode hostap
ifconfig wlan0 inet 192.168.1.1 netmask 255.255.255.0 ssid pibsd mode 11g channel 1
I setup ip address 192.168.1.1 with netmask 255.255.255.0 for
This means that devices connected to this adapter should has ip address in the network 192.168.1.0/24
I use "
pibsd" as SSID, mode 11g and channel 1.
We have configured our Wireless Access Point.
It doesn't use any authentication and doesn't provide ip addresses to clients but it can accept connections now.
I have checked our new wireless network on my smartphone.
It sees the "pibsd" network. And this network is "open".
To work with this network we need to setup ip address for our client.
Here is an example for Windows machine:
Our Windows client is connected to our Access Point.
To make our settings permanent we need to load kernel modules and to setup
wlan at startup.
We need to add next strings to
/boot/loader.conf for D-Link DWA-140:
We need to add next strings to
/etc/rc.conf to setup
ifconfig_wlan0="inet 192.168.1.1 netmask 255.255.255.0 ssid pibsd mode 11g channel 3"
I have changed channel from 1 to 3 for permanent usage.
After reboot we can see that our adapter works in HostAP mode:
It is a good idea to have an authentication for our new Access Point.
I use WPA-PSK as "good enough" authentication method.
We need to setup and use hostapd(8) daemon for client authentication and key management on the AP with WPA.
The configuration is done in
Here we use interface
wlan0, SSID "
mysecretpassphrase" as WPA passphrase and
WPA-PSK as key management protocol.
After that we can start
And connect to AP with WPA authentication method:
We can check which clients are connected to our AP:
ifconfig wlan0 list sta
To make our settings permanent we need to add next string to
First, we need to compile and install isc-dhcp-server:
Second, we need to create a configuration file for our DHCP server.
This is file
It's enough to have a simple configuration.
I have network 192.168.1.0/24.
DHCP server will provide ip addresses from 192.168.1.10 to 192.168.1.250.
And our AP with ip address 192.168.1.1 will be a default router for our clients.
To start the DHCP server at boot time we to add next strings to
After reboot we can connect clients to our new and complete Wireless Access Point.
Windows machine connected to AP:
To connect FreeBSD machine we need to prepare correct
Here is the result:
This is second Raspberry Pi with FreeBSD as client connected to first Raspberry Pi with FreeBSD as server.
Yes, I have two Raspberry Pi 🙂