# How to install + configure a Pi Router with hostapd?



## openbsd98324 (Apr 17, 2022)

Hello, 

For my PI I use on raspios PiRouter with hostapd.









						openbsd98324 openbsd98324 / pirouter · GitLab
					

Transform your Raspberry PI in a wifi router, using eth0 ==> wlan0 (bridge).




					gitlab.com
				




How do you install the same on FreeBSD ? (i.e.  wget -c --no-check-certificate   "https://download.freebsd.org/ftp/re...reeBSD-12.1-RELEASE-arm64-aarch64-RPI3.img.xz" )

Hostapd config has: 


```
country_code=GB
interface=wlan0
bridge=br0
ssid=DEBIANROUTER
wmm_enabled=0
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=****
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
```


Kind regards


----------



## obsigna (Apr 17, 2022)

I do this with a BeagleBone Black using an USB wireless adapter (RTL8188eu).

AFAIK, FreeBSD does not provide a driver for the Pi’s internal wlan interface - I happily would like to learn otherwise, though. That said, your journey starts with finding a working wlan interface for your Pi running FreeBSD.

In case you use a USB one, you need to add some directives to /boot/loader.conf, something like I did for the RTL8188eu one:

Excerpt of the file /boot/loader.conf

```
...
if_bridge_load=YES
rtwn_load=YES
rtwn-rtl8188eufw_load=YES
legal.realtek.license_ack=1
wlan_load=YES
wlan_amrr_load=YES
wlan_xauth_load=YES
wlan_wep_load=YES
wlan_tkip_load=YES
wlan_ccmp_load=YES
if_rtwn_usb_load=YES
dev.rtwn.0.ht40=1
```
The network settings are done in the file `/etc/rc.conf`:

```
...
wlans_rtwn0="wlan0"
create_args_wlan0="wlanmode hostap country GB regdomain ETSI ssid DEBIANROUTER channel 7 roam:rate 7"
ifconfig_wlan0="up"

cloned_interfaces="bridge0"
ifconfig_bridge0="inet 192.168.0.1/24 addm cpsw0 addm wlan0 stp cpsw0 stp wlan0 description LAN"
ifconfig_cpsw0="up"
hostapd_enable="YES"
gateway_enable="YES"
...
```
Note, cpsw0 is the ethernet interface of the BeagleBone Black. You need to replace this by the respective ethernet device identifier of your Pi.

The access point settings go into the file /etc/hostapd.conf:

```
interface=wlan0
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
wpa=2
wpa_passphrase=<A_SECRET_WLAN_PASSWORD>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
```


----------



## Phishfry (Apr 17, 2022)

My setup is exactly the same.
One small addition I have used this to define the routing path in /etc/rc.conf

```
defaultrouter="192.168.1.1"
```

I don't have these defined either:


obsigna said:


> wlan_amrr_load=YES wlan_xauth_load=YES wlan_wep_load=YES wlan_tkip_load=YES wlan_ccmp_load=YES


You wouldn't need WEP at all or TKIP as shown in your hostapd.


obsigna said:


> ```
> wpa_pairwise=CCMP
> ```



If you did need TKIP for older gear you would have to enable it here:

```
wpa_pairwise=CCMP TKIP
```

My APU2 with none of those settings in /boot/loader.conf

```
# kldstat
Id Refs Address                Size Name
 1   20 0xffffffff80200000  1f2f8c0 kernel
 2    1 0xffffffff82131000     6958 amdtemp.ko
 3    2 0xffffffff82138000     37a0 amdsmn.ko
 4    1 0xffffffff8213c000    20c80 geom_mirror.ko
 5    1 0xffffffff82520000     2224 speaker.ko
 6    1 0xffffffff82523000     3218 intpm.ko
 7    1 0xffffffff82527000     2180 smbus.ko
 8    1 0xffffffff8252a000     7638 if_bridge.ko
 9    1 0xffffffff82532000     50d8 bridgestp.ko
10    1 0xffffffff82538000     20e8 wlan_xauth.ko
```

Here is a client ifconfig snippet showing we have CCMP in use.

```
AES-CCM 2:128-bit
```


----------

