Published : 2013-09-17

Home hostap

After recently replacing my frequently crashing ISP gateway, I decided to build my own ADSL router.

For a reliable router OS I chose OpenBSD. For hardware I used an Alix 2d13 board with an Atheros mini-PCI Wi‑Fi card (DNMA92) and matching antennas.

This tutorial explains how to configure OpenBSD as a Wi‑Fi access point while acting as your router.

IMG_20131105_203131

Booting on the Alix board

If you plan to use an Alix board, here is a quick procedure to install OpenBSD and connect to the board over a serial console.

Insert the compact flash card into a compatible reader (internal or USB) and attach it to a 32‑bit (i386) VM as a disk device (for example /dev/sdX in libvirt).

Install OpenBSD as usual. During installation enable com0 at 38400 baud and do not configure network interfaces.

After installation, shut down the VM, run sync on the host to flush buffers, remove the compact flash card and insert it into the Alix board. Power on the board.

If all goes well, OpenBSD will boot on the board just like on a standard server.

Network configuration

We will bridge the network interfaces so the system behaves as a switch.

Ethernet configuration

The Alix 2d13 board has three Ethernet interfaces. We only need to bring them up:

echo "up" > /etc/netstart vr0
echo "up" > /etc/netstart vr1
echo "up" > /etc/netstart vr2
sh /etc/netstart vr0
sh /etc/netstart vr1
sh /etc/netstart vr2

Wi‑Fi configuration

Now configure the Wi‑Fi interface.

Edit /etc/hostname.athn0 and add the following configuration:

nwid "mySSID"
wpa
wpaprotos wpa2
wpakey yourwpaKeyHere
media autoselect mediaopt hostap
up
chan 1

Notes:

  • nwid: your SSID
  • wpa & wpaprotos: enable WPA; if wpaprotos is not specified both WPA and WPA2 will be available
  • wpakey: your WPA key
  • media autoselect mediaopt hostap: set the card to AP mode and let it auto-select 802.11 options
  • chan: Wi‑Fi channel. Pick 1, 6 or 11 to avoid neighbor interference

I found that setting the channel after bringing the interface up avoids issues with some drivers.

Finally, start the interface:

sh /etc/netstart athn0

Loopback interface configuration

For neatness, create a loopback-style interface that will carry the access point IP address. You could assign the address to an Ethernet or Wi-Fi interface instead, but using a dedicated virtual interface is cleaner.

echo "inet 10.0.0.1 255.255.255.0 NONE" > /etc/hostname.vether0
echo "description Bridge-WiFi" >> /etc/hostname.vether0
sh /etc/netstart vether0

Bridge configuration

Finally, create the bridge. Edit /etc/hostname.bridge0:

up
add vether0
add vr0
add vr1
add vr2
add athn0

Then start the bridge:

sh /etc/netstart bridge0

If your equipment is connected to a switch that supports spanning tree, add stp <iface> options in /etc/hostname.bridge0.

Conclusion

If everything worked, the SSID you configured should now be visible. This tutorial does not provide DHCP; if you want clients to receive IP addresses automatically, configure dhcpd with the proper subnet and listening interfaces.