# Raspberry Pi as Wireless Access Point



## balanga (Mar 23, 2019)

I'm thinking of setting up a Raspberry Pi as a Wireless Access Point and have read the excellent guide by Vadim Zaigrin but have noticed that it is almost five years old, and wondered if any of the instructions should be amended if using FreeBSD 12.0...


----------



## ralphbsz (Mar 23, 2019)

Setting up a generic *BSD machine as a wireless AP is not very difficult; there are lots of guides for that on the web.  I used both an OpenBSD and then a FreeBSD machine as an AP for about 5 years.  The idea was to (a) save power and (b) simplify my overall system.  Since I didn't use encryption or authentication, it was very easy, but I've also seen guides that do the whole thing, using hostapd().

In theory, this should be just as easy on a Raspberry Pi as on a generic FreeBSD setup.

Problem 1: The built-in wireless on the newer RPi3 and RPi0w doesn't work under FreeBSD, so you'll have to use a USB wireless dongle.

Problem 2: Wireless devices that are designed as clients make bad access points, they are lacking good antennas.  Even though I had a wireless device with external antennas, after switching to "real" access points, the signal quality around the house became much better for me.  Depending on the size of your area, this might not matter to you.

Problem 3: I found that *BSD is a very buggy when used as an AP.  Under OpenBSD, about 10 years ago, the drivers were so buggy, it didn't even work reliably.  Under FreeBSD, it actually worked for days at a time, then some resource leaked, and it hung, and required reboots.  And it never worked with Apple-made clients, because FreeBSD AP mode doesn't support some 802.11 feature correctly, which Apple devices happen to need.  I kept struggling with fixing this, and rebooting frequently, and then I gave up and spent money on a good AP.

In summary, this was an interesting project to waste a weekend on, but it is not production-worthy.  I should have given up much earlier, after days instead of years.


----------



## balanga (Mar 23, 2019)

ralphbsz said:


> Setting up a generic *BSD machine as a wireless AP is not very difficult; there are lots of guides for that on the web.  I used both an OpenBSD and then a FreeBSD machine as an AP for about 5 years.  The idea was to (a) save power and (b) simplify my overall system.  Since I didn't use encryption or authentication, it was very easy, but I've also seen guides that do the whole thing, using hostapd().


One thing I noticed about Zaigrin's guide, ie that he showed how to set up isc-dhcp-server, whereas dnsmasq() seems much more suitable, and if anyone wants to set it up there is useful guide here.


> In theory, this should be just as easy on a Raspberry Pi as on a generic FreeBSD setup.
> 
> Problem 1: The built-in wireless on the newer RPi3 and RPi0w doesn't work under FreeBSD, so you'll have to use a USB wireless dongle.


I'm using the RPi2 and already have a dongle, but I was wondering whether I should expect FreeBSD drivers to be available for the NanoPi K1 Plus which looks like an interesting competitor to the RPi3.



> Problem 2: Wireless devices that are designed as clients make bad access points, they are lacking good antennas.  Even though I had a wireless device with external antennas, after switching to "real" access points, the signal quality around the house became much better for me.  Depending on the size of your area, this might not matter to you.
> 
> Problem 3: I found that *BSD is a very buggy when used as an AP.  Under OpenBSD, about 10 years ago, the drivers were so buggy, it didn't even work reliably.  Under FreeBSD, it actually worked for days at a time, then some resource leaked, and it hung, and required reboots.  And it never worked with Apple-made clients, because FreeBSD AP mode doesn't support some 802.11 feature correctly, which Apple devices happen to need.  I kept struggling with fixing this, and rebooting frequently, and then I gave up and spent money on a good AP.
> 
> In summary, this was an interesting project to waste a weekend on, but it is not production-worthy.  I should have given up much earlier, after days instead of years.



For me it is bit of an interesting exercise trying to set up the RPi as a FreeBSD AP, never having looked behind the scenes before, but I'm sure OpenWrt would provide a better service since it is designed for the job. Have you thought about installing it on your 'good AP'? I've installed it on a TP-LINK TL-WDR3600 but haven't spent any time monitoring it.

Once I've got my RPi working properly under FreeBSD I might try and compare results with it running under OpenWrt.

If you've still got your RPi you may be interested in https://openwrt.org/toh/raspberry_pi_foundation/raspberry_pi ...


----------



## balanga (Mar 23, 2019)

Anyone know what this is telling me?

It's what gets displayed when I insert the wifi dongle into the RPi.


```
ugen0.5: <Ralink 802.11 n WLAN> at usbus0
run0 on uhub1
run0: <1.0> on usbus0
run0: MAC/BBP RT5390 (rev 0x0502), RF RT5370 (MIMO 1T1R), address 00:87:24:83:34:55
wlan0: Ethernet address: 00:87:24:83:34:55
run0: firmware RT3071 ver. 0.33 loaded
wlan0: ieee80211_new_state_locked: pending INIT -> SCAN transition lost
```

I see the SSID on my phone and it tries to connect but doesn't manage it. is there a log on the RPi which shows connection attempts?


----------



## Phishfry (Mar 23, 2019)

balanga said:


> s there a log on the RPi which shows connection attempts?


It depends on what you are using. I use no logging in hostapd but do log dnsmasq clients.
/etc/hostapd.conf allows you to set a log as does /usr/local/etc/dnsmasq.conf

I have great luck with FreeBSD as an AP built with NanoBSD scripts. Using APU2 and Atheros hardware.


```
# uname -a
FreeBSD APU2 11.2-RELEASE FreeBSD 11.2-RELEASE #0 r336118: Wed Jul 18 05:35:43 EDT 2018     root@gigabyte:/usr/obj/nanobsd.apu2ap/usr/src/sys/GENERIC  amd64


# df -h
Filesystem             Size    Used   Avail Capacity  Mounted on
/dev/ufs/nanobsds1a    457M    437M    -17M   104%    /
devfs                  1.0K    1.0K      0B   100%    /dev
/dev/md0               4.4M    2.8M    1.3M    68%    /etc
/dev/md1               4.4M    2.9M    1.1M    72%    /var


# cat /etc/hostapd.conf
interface=wlan0
ssid=APU
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
wpa=2
wpa_passphrase=**********
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP TKIP


# cat /etc/rc.conf
hostname="APU2"
ifconfig_igb0="DHCP"
ifconfig_igb1="inet 192.168.101.1 netmask 255.255.255.0"
ifconfig_igb2="inet 192.168.102.1 netmask 255.255.255.0"
sshd_enable="YES"
sendmail_enable="NONE"
clear_tmp_enable="YES"
dumpdev="NO"
wlans_ath0="wlan0"
create_args_wlan0="wlanmode hostap ssid APU channel 157"
hostapd_enable="YES"
ifconfig_wlan0="inet 192.168.100.1 netmask 255.255.255.0"
dnsmasq_enable="YES"
gateway_enable="YES"
pf_enable="YES"
pf_rules="/etc/pf.conf"
defaultrouter="192.168.1.1"
#growfs_enable="YES"
#growfs_type="nanobsd-pingpong"


# cat /etc/local/dnsmasq.conf
server=1.1.1.1
server=8.8.4.4
dhcp-range=set:wlan0,192.168.100.10,192.168.100.25,255.255.255.0,24h
dhcp-range=set:igb1,192.168.101.10,192.168.101.25,255.255.255.0,24h
dhcp-range=set:igb2,192.168.102.10,192.168.102.25,255.255.255.0,24h
dhcp-option=wlan0,option:router,192.168.100.1
dhcp-option=igb1,option:router,192.168.101.1
dhcp-option=igb2,option:router,192.168.102.1


# cat /etc/pf.conf
ext_if="igb0"
set skip on lo
nat on $ext_if inet from ! ($ext_if) to any -> ($ext_if)
```


----------

