Turn your laptop into a wireless access point using Hostapd

This is a guide to turn your old laptop into an access point, using Ubuntu or Debian as your operating system.

We are assuming your laptop have only one wireless card installed, if you have an extra usb wireless adapter during performing the steps in this guide, you may need to do extra steps to not apply the wrong settings to the wrong device.

Step 1

Run everything from here as root:

sudo -i

Install necessary tools:

apt-get install iw hostapd bridge-utils

Step 2

First you need to find whether your wireless card driver support running in access point mode.
Run this to check for ability to run in AP mode:

iw phy0 list | less

Scroll until you see this section: (click ‘q’ to finish scrolling, and return to terminal)

        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * WDS
                 * monitor
                 * mesh point
        software interface modes (can always be added):
                 * AP/VLAN
                 * monitor

The line saying (* AP) means that we it is supported, if there is no AP under “Supported interface modes”, then you might try installing a different driver for your wireless device.

Step 3

Find out the name of your wireless device using

iwconfig

You will get an output like this:

wlan0     IEEE 802.11bg  Mode:Master  Tx-Power=20 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
 
lo        no wireless extensions.
 
eth0      no wireless extensions.

The name we are looking for is ‘wlan0’

Step 4

Stop the default network manager that comes with ubuntu/mint/debian, that will try to override some of our new settings on every boot:

echo manual > /etc/init/network-manager.override

Set the network configuration manually

nano /etc/network/interfaces

Copy the following:

auto lo
iface lo inet loopback
 
iface eth0 inet manual
 
auto br0
iface br0 inet static
  address 192.168.1.2
  netmask 255.255.255.0
  network 192.168.1.0
  broadcast 192.168.123.255
  gateway 192.168.1.1
  bridge_ports eth0

The ip “address” above is the address your computer will have, the ip should be chosen in a range outside of the ip addresses range assigned by the router’s DHCP, so, we are here assuming the router uses a DHCP range like for example 192.168.1.128-192.168.1.254

The ip “gateway” should be your ip of the router or modem providing the internet

Add your own domain name servers:

nano /etc/resolvconf/resolv.conf.d/tail

Copy in it the following line, and if you want, you can also add any other 3rd party dns you prefer, each on a separate line, like ‘8.8.8.8’ or ‘208.67.222.222’

192.168.1.1

Run to apply

resolvconf -u

Step 5

Create a network bridge, that will be used to connect the ethernet and the wireless AP through your laptop
and add the ehternet to the bridge

brctl addbr br0
brctl addif br0 eth0

At this point, you should restart you computer to verify that everything is ok, on the next boot, your should have network connectivity.

Try to ping 192.168.1.1 , ping google.com

Step 6

Create a new settings file for your access point,

nano /etc/hostapd/hostapd.conf

Copy the following in the file:

interface=wlan0
bridge=br0
driver=nl80211
ssid=your-network-name
channel=11
hw_mode=g
wme_enabled=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=your_secret_password
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP

Step 7

Start the access point to test it:

hostapd /etc/hostapd/hostapd.conf

Using another laptop or phone, you should see the new wireless access point and connect to it and have internet through it.

Step 8

If all went ok, make hostapd start on system startup

nano /etc/default/hostapd

Find the line containing DAEMON_CONF, uncomment it and change it to:

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

Restart to verify that everything is working as expected.

Leave a Reply

Your email address will not be published. Required fields are marked *

(Your message will only be visible after moderation)