I wanted to create my own Linux based Wireless Access Point, but after trying unsuccessfully to follow several different sets of instructions I decided to see if I could simplify things a bit and came up with my own solution.
I’d tried following these instructions but found that although I could ‘see’ the wireless network I couldn’t connect. The encryption keys were being exchanged but after about 30 seconds the client was being disconnected, and though several hours experimentation later I was sure the problem was that DHCP wasn’t working and the client was not getting an IP address, I couldn’t figure out why.
After going round in circles for a bit it occurred to me that I didn’t really need the Wireless Access Point to be a DHCP server, I just needed the client to be able to connect wirelessly and get an IP address, as I already had a perfectly good DHCP server. Then I realized that I’d already done something similar when bridging a virtual network to the physical ethernet port on my desktop. Would it work if I simply bridged the wireless network interface and ethernet interface…?
Install the firmware
To enable wireless networking you need will need to install the appropriate firmware for your wireless card from the non-free repository.
To do this you need to be running as root.
$ su Password:
$ sudo -i Password:
Then add the non-free repository to the list of repositories that will be used when installing new packages.
# vi /etc/apt/sources.list
# /etc/apt/sources.list # deb http://archive.raspbian.org/raspbian/ wheezy main non-free deb-src http://archive.raspbian.org/raspbian/ wheezy main # deb http://archive.raspbian.org/mate wheezy main
Then update the local package lists.
# apt-get update Hit http://archive.raspbian.org wheezy Release.gpg : : : Reading package lists... Done #
Then install the firmware for the wireless adaptor. To help identify the type of wireless network card you are using you can list all the devices that are recognised using lsusb or lspci.
# lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 148f:5370 Ralink Technology. RT5370 Wireless Adapter # apt-get install firmware-ralink Reading package lists... Done Building dependency tree Reading state information... Done Suggested packages: initramfs-tools linux-image The following NEW packages will be installed: firmware-ralink 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 0 B/21.4 kB of archives. After this operation, 96.3 kB of disk space will be used. : : : #
Enable the wireless interface
# apt-get install wireless-tools Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libiw30 The following NEW packages will be installed: libiw30 wireless-tools 0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 168 kB of archives. After this operation, 385 kB of additional disk space will be used. Do you want to continue [Y/n]? Y : : :
To check that the wireless interface is detected
# iwconfig wlan0 IEEE 802.11bgn ESSID:off/any Mode:Managed Access Point:Not-Associated Tx-Power=0dBm Retry long limit:7 RTS thr:off Fragment thr:off Encryption key:off Power Management:on lo no wireless extensions. eth0 no wireless extensions.
If there is not an entry corresponding to your wireless network then your wireless device is not supported, you may find that upgrading to a newer kernel (using apt-get upgrade), or newer Linux release solves this problem.
Configure the network
Disable the firewall (if running), otherwise this will block DHCP requests and any other traffic. Then install the bridge-utils and hostapd.
# ufw disable Firewall stopped and disabled on system startup # apt-get install bridge-utils hostapd Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libnl-3-200 libnl-genl-3-200 The following NEW packages will be installed: bridge-utils hostapd libnl-3-200 libnl-genl-3-200 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 524 kB of archives. After this operation, 1,246 kB of disk space will be used. Do you want to continue [Y/n]? Y : : :
Configure the network interfaces.
# vi /etc/network/interfaces
#/etc/network/interfaces # # This file describes the network interfaces available on # your system and how to activate them. For more information, # see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface allow-hotplug eth0 #iface eth0 inet dhcp #Comment out this line. # Wireless interface auto wlan0 # Create a bridge between eth0 and wlan0 auto br0 iface br0 inet dhcp bridge_ports eth0 wlan0
Configure the wireless access point properties, using your own ssid and password.
Note – Don’t make the password too long initially as I found a long password didn’t work, you can always change it later when you know everything is working.
# vi /etc/hostapd/hostapd.conf
# /etc/hostapd/hostapd.conf # interface=wlan0 driver=nl80211 bridge=br0 ssid=private channel=1 auth_algs=1 wpa=2 wpa_passphrase=Password wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP CCMP rsn_pairwise=TKIP CCMP
Configure it to start automatically at boot.
# vi /etc/default/hostapd
# /etc/default/hostapd # # Defaults for hostapd initscript # DAEMON_CONF="/etc/hostapd/hostapd.conf"
Then reboot for the changes to take effect…
These instructions were tested using a N150 Nano USB wireless adaptor with a Raspberry Pi, but should work with other types of wireless network adapter that support AP mode and other type of hardware running Debian as well. Providing your kernel includes support for your wireless adapter, and the firmware packages are included in you distribution.
Raspberry Pi is a trademark of the Raspberry Pi Foundation