Wiki

Clone wiki

mobilityfirst / Click_Router / Configurations / WiFi_Access_Router

Setting up WiFi Access on Router

The following instructions assume a Debian derivative Linux distro.

#!bash

# Install required packages
# -------------------------

sudo apt-get -qq -y install hostapd dnsmasq


# Bring up driver for the local wifi adaptor
# ------------------------------------------

# If the wifi interface is not up already, you can use tools such as 'lspci' 
# or 'lsusb' to find which wifi adaptor is installed and load the appropriate
# driver. E.g., for all Atheros IEEE 802.11n PCI/PCI-Express and AHB WLAN based 
# chipsets use the 'ath9k' driver.
sudo modprobe ath9k

# To determine which interface came up from above driver action, check using
sudo ifconfig -a 

# Note: if your node uses NetworkManager to manage an active Internet connection 
# (e.g., if you are using a laptop to run as an access router), you may have to 
# disable this daemon first and activate the device if blocked:
sudo nmcli nm wifi off
sudo rfkill unblock wlan


# Configure interface 
# -------------------

# bring up WiFi interface with IP and netmask. This will be the AP's IP.
sudo ifconfig wlan0 192.168.1.1 netmask 255.255.255.0 up


# Set up DHCP (optional)
# ----------------------

# Edit DHCP configuration in /etc/dnsmasq.conf to alter interface, IP range,
# and to add any particular MAC-IP assignment bindings to be enforced
# See sample configuration in section below.
sudo vi /etc/dnsmasq.conf

# restart DHCP service:
sudo service dnsmasq restart


# Configure and Bringup hostapd
# -----------------------------

# Create/edit a hostapd.conf (sample shown below) to configure interface, essid, 
# channel, passphrase etc., for the AP. Using '/etc/hostapd/hostapd.conf' as
# the location makes it convenient for automation
sudo vi /etc/hostapd/hostapd.conf

# To automate initialization, edit '/etc/default/hostapd' to uncomment and set 
# DAEMON_CONF to the absolute path of your hostapd configuration file. This also 
# enables hostapd to be started at boot.
sudo vi /etc/default/hostapd

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

# To start, stop, restart hostapd:
sudo /etc/init.d/hostapd {start|stop|restart}

# or use 'service' tool
sudo service hostapd {start|stop|restart}

# Here's the manual way to bring up hostapd if needed (-B sets background mode):
sudo hostapd -BtKd /etc/hostapd/hostapd.conf

Sample hostapd Configuration

#!bash
interface=wlan0
driver=nl80211
ssid=mfaccess-test
# hw_mode: always a subset of a, b, g
hw_mode=g
channel=11
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
# wpa=3 enables wpa & wpa2
wpa=3
wpa_passphrase=mfaccess-test
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Refer to the hostapd documentation for further details.

Sample Dnsmasq Configuration

#!bash
interface=wlan0
# dhcp-range=<startIP>, <endIP>,<lease time>
dhcp-range=192.168.1.128,192.168.1.254,24h
dhcp-host=aa:22:bb:44:cc:66,192.168.1.128

Bringing up Access Router

Now that the wireless interface is setup for clients to connect and authenticate, bring up MobilityFirst access router as show in router configurations page

Updated