The first thing to do is find out whether your hardware is capable of running in master mode. The easiest way to check this is like so:

dan@neo:$ sudo apt-get install iw
dan@neo:$ iw list

Look through the output to find the Supported Interface Modes section:

...
Supported interface modes:
         * IBSS
         * managed
         * AP
         * AP/VLAN
         * monitor
         * mesh point
...

If, as in the example above, AP mode is listed, then congratulations you have everything you need! If not, all is not lost. Check out this guide to see how to test older hardware for master mode.

HostAPD

We’re going to use the hostapd service to manage our access point, the first thing to do is install, then configure it.

dan@neo:$ sudo apt-get install hostapd
dan@neo:$ sudo nano /etc/default/hostapd

This will install hostapd and present you with the default service configuration. We need to modify this file to start hostapd at boot and tell it where we’ll store the config file. Do this by editing the DAEMON_CONF line like so:

DAEMON_CONF="/etc/hostapd/hostapd.conf"

Now we need to create a config file at the location above:

dan@neo:$ sudo nano /etc/hostapd/hostapd.conf

Paste the following into it:

ctrl_interface=/var/run/hostapd
###############################
# Basic Config
###############################
macaddr_acl=0
auth_algs=1
# Most modern wireless drivers in the kernel need driver=nl80211
driver=nl80211
##########################
# Local configuration...
##########################
interface=wlan0
bridge=br0
hw_mode=g
channel=1
ssid=danlan
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_passphrase=DONOTFORGETTOCHANGEME
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Most of the options above are fairly self-explantory, however, there are a few things to note. Firstly, “hw_mode=g” should be set as “g” even if you want an 802.11n access point. Furthermore, you need to set a WPA passphrase where indicated.

Bridging the Connections

Your AP is now configured and clients will be able to connect, however, they will not be assigned an IP and they will not be able to access the network on eth0. That’s where bridging comes in. This example assumes that your server has an eth0 connection to the network and wlan0 which is being used as the wireless AP.

First we need to install the bridge utilities:

dan@neo:$ sudo apt-get install bridge-utils

Edit your /etc/network/interfaces file like so:

# 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
#auto eth0
#iface eth0 inet static
#       address 192.168.0.2
#       netmask 255.255.255.0
#       network 192.168.0.0
#       broadcast 192.168.0.255
#       gateway 192.168.0.1
 
auto br0
iface br0 inet static
        address 192.168.0.2
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge-ports eth0 wlan0

Note that the new br0 interface effectively replaces your existing eth0 interface. If you’ve followed the Ubuntu SBS guide to configure DHCP then you’re done! Your new AP should be up and running after a simple reboot. If not, follow the DHCP Server section of the SBS guide on this site.

13 comments so far

Add Your Comment
  1. Thank’s Dan it’s Works

  2. It will this guide work on a desktop ubuntu?
    thx

    • I see no reason why it wouldn’t… but you would probably be better to use network manager…

  3. Hi Dan,

    I see you can also start hostapd under your network/interfaces by adding the lines below.
    What i like about it is that it allows you configure other settings on you wifi interface if needed.

    iface wlan0 inet static
    hostapd /etc/hostapd/hostapd.conf
    address 192.168.168.1
    netmask 255.255.255.0

  4. i’ve tried this on xubuntu, it works, but only for the people connecting to the access point.. on the host computer i don’t have internet the internet symbol in the bar also has a red cross.

  5. Can you bridge two wireless adapters? I’m deployed overseas and the only internet I have is wireless. The signal is very weak. I have a high gain wireless usb adapter (from TP Link) attached to my laptop to get a good signal. I would like to set up a wireless access point using the built in wifi card for my laptop and share the connection I get from the usb wireless adapter. How would I go about doing that?

  6. [...] [...]

  7. [...] di casa, causa (sicuramente) le impostazioni del file /etc/network/interfaces che ho preso da questo tutorial segnalatomi dal buon tHeGoOd. Il mio file /etc/network/interfaces [...]

  8. [...] Dan Bishop’s blog – auf diesem Artikel basiert ein großer Teil dieses Artikels [...]

  9. […] braucht dazu hostapd (eine großartige Zusammenfassung der Funktionen findet ihr im Blog von Dan Bishop), zieht es euch einfach per apt-get install hostap. […]

  10. Hi,

    I got this working on my Raspberry Pi, but actually I don’t want to access the internet, but only set up a local WiFi and access the webserver on my RasPi over a smartphone. So I tried pulling the ethernet cable, leaving the bridge part out, and some other changes, but it doesn’t work.
    I can see the network, but no IP is assigned.
    Can you give me a hint?
    Thank you in advance!

    Best regards
    Zap

  11. how to install “nl80211″ driver in command terminal ? in ubuntu..

    i was already installed. but I uninstalled accidentally…tell the procedure for installing..