Skip to content

Dummy wireless access point with bridging

Alexey Brodkin edited this page Apr 6, 2017 · 3 revisions

Introduction

Instructions below help to create the simplest wireless access point on a Linux-powered device (or development board) which at least has one Ethernet controller and [attachable] Wi-Fi networking adapter.

For this example we'll be using TP-Link TL-WN722N USB Wi-Fi adapter (more details about this dongle could be found on Wikidevi).

Prerequisites

Linux kernel requirements

We're going to bridge wired and wireless networking interfaces so they will act as the one and only interface. This allows us to not mess with iptables for routing etc.

So here comes the first requirement - bridging support in Linux kernel. Just fire up kernel's configuration utility with make menuconfig and make sure CONFIG_BRIDGE is enabled.

Given we're going to work with networking adapters we need to have device drivers built-in Linux kernel (alternatively drivers could be built as modules and loaded later on target). Usually support of on-board Ethernet controller is already enabled in kernel's defconfig for the device/board in use but drivers for Wireless device especially if it is a USB-dongle like ours TP-Link TL-WN722N there's a need to select corresponding drivers. Again in make menuconfig select CONFIG_ATH9K_HTC for devices based on Atheros AR9271/AR7010 chipset.

Note to have an ability to select CONFIG_ATH9K_HTC first one has to select CONFIG_MAC80211 and CONFIG_CFG80211.

As a summary, select (right order if important otherwise some components might not be available for selection as they might have dependences):

  • CONFIG_BRIDGE
  • CONFIG_CFG80211
  • CONFIG_MAC80211
  • CONFIG_ATH9K_HTC

User-space requirements

Now when Linux kernel is properly configured it's time to get everything needed in user-space to run desired setup.

If we're talking about embedded Linux case (i.e. there's no full-scale distribution with prebuilt .rpm or .dep packages) it might make sense to use one of available open source buildsystems. We'll proceed here with use of Buildroot.

Following packages are required on target:

To get all items above built in Buildroot just enable following options:

  • BR2_PACKAGE_BRIDGE_UTILS
  • BR2_PACKAGE_HOSTAPD
  • BR2_PACKAGE_IW
  • Firmware for Atheros USB dongles: BR2_PACKAGE_LINUX_FIRMWARE_ATHEROS_9271

If packages above are built the final preparatory step we'll need is setting hostapd on the target. For that copy https://w1.fi/cgit/hostap/tree/hostapd/hostapd.conf to target's /etc folder and disable "eap_server=0" option with "#" or remove that line entirely.

Setting up bridge on the target

All we need on target is to run following commands. That will instantiate open Wi-Fi network with SSID that matches ssid option in /etc/hostapd.conf. As of today it is "test".

ifconfig wlan0 up
ifconfig eth0 up
brctl addbr br0
brctl addif br0 eth0
iw dev wlan0 set 4addr on
brctl addif br0 wlan0
brctl show
ifconfig br0 up
udhcpc -i br0
hostapd -B /etc/hostapd.conf

Below is what I see runinng those commands on Wandboard with TP-Link TL-WN722N Wi-Fi dongle:

IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Atheros 8031 ethernet 2188000.ethernet:01: attached PHY driver [Atheros 8031 ethernet] (mii_bus:phy_ad)
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
br0: port 1(eth0) entered blocking state
br0: port 1(eth0) entered disabled state
device eth0 entered promiscuous mode
br0: port 2(wlan0) entered blocking state
br0: port 2(wlan0) entered disabled state
device wlan0 entered promiscuous mode
bridge name     bridge id               STP enabled     interfaces
br0             8000.001f7bb205ee       no              eth0
                                                        wlan0
IPv6: ADDRCONF(NETDEV_UP): br0: link is not ready
udhcpc: started, v1.25.0
udhcpc: sending discover
fec 2188000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
br0: port 1(eth0) entered blocking state
br0: port 1(eth0) entered forwarding state
IPv6: ADDRCONF(NETDEV_CHANGE): br0: link becomes ready
udhcpc: sending discover
udhcpc: sending select for 10.42.0.119
udhcpc: lease of 10.42.0.119 obtained, lease time 3600
deleting routers
adding dns 10.42.0.1
Configuration file: /etc/hostapd.conf
br0: port 2(wlan0) entered disabled state
IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Using interface wlan0 with hwaddr 60:e3:27:0c:e3:1f and ssid "test"
IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
br0: port 2(wlan0) entered blocking state
br0: port 2(wlan0) entered forwarding state
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
Clone this wiki locally