Skip to content

Configuring the wireless hotspot

m-hofmann edited this page Jul 9, 2016 · 18 revisions

Driver Installation

Note: In a previous version of this manual we installed udhcpd. We completely ditched this approach in favor of dnsmasq.

First, install the following two packages: hostapd dnsmasq. The binary of the hostapd package will be replaced by our custom version in the next step. If you somehow feel attached to it, you should probably save it somewhere else now.

We need to find out the name of the wireless interface via ifconfig. The default is wlan0 but based on kernel version and available network interfaces this may differ.

Second, we need a driver that supports access point mode for the Edimax Wireless stick. Use the lsusb command to check the chipset of the dongle. If it's RTL8188CUS, you've found the right manual!

Get the driver package for Linux from the Realtek site. Push it to the Pi via scp. Unpack the zip, and the file wpa_supplicant_hostapd-0.8-rtw_r7457.20130812.tar.gz in the directory RTL8188C_8192C_USB_linux_4.0.2_9000.20130911/wpa_supplicant_hostapd. The newly unpacked directory contains a hostapd directory. make the software within & get a coffee. make install the software as root.

The daemon will be installed to /usr/local/bin/hostapd. However, the SysVInit service we will use later references /usr/local/sbin. To make our patched version of the binary available, issue the following command:

# ln -sf /usr/local/bin/hostapd /usr/sbin/hostapd

DNSmasq DHCP daemon

After a device has connected to the Raspberry Pi via our access point, we need to assign a IP address for it. This service shall be provided by DNSmasq. For this to work you need to edit the file /etc/dnsmasq.conf:

no-resolv
interface=wlan0
dhcp-range=wlan0,192.168.0.2,192.168.0.120,12h
dhcp-authoritative
server=192.168.0.1 # use the Pi for DNS
log-queries # logs to /var/log/daemon.log

The Pi should have the static IP address 192.168.0.1. This should be set on boot. Edit the file /etc/network/interfaces and set the definition for the interface wlan0 (or whatever ifconfig returned) to a static address:

allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.0.1
  netmask 255.255.255.0

Uncomment allow-hotplug and wpa-conf for this interface.

hostapd configuration

For now we will create a secured network. We can later change this to allow everyone access to the rover. Edit /etc/hostapd/hostapd.conf:

interface=wlan0
driver=rtl871xdrv
ssid=ROVER
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=passphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Remember not to use the actual wpa_passphrase from above, use your own password!

As a next step, the hostap daemon should be enabled in /etc/default/hostapd:

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

Starting the services

Now we can start the services to test the setup:

# service hostapd start
# service dnsmasq start

Forward traffic to local webserver

Add the following line to /etc/dnsmasq.conf
address=/#/192.168.0.1
As soon as the rover has its own domain one can simply replace the '#' character with the given domain.

Our webserver needs to listen to port 80 in order to not append the portnumber to the domain. Otherwise we need to write the Rover URL like this:
rover.com:8000

Running without a password

Attention: This configuration is insecure! Only use it for demo purposes. Edit your hostapd.conf like this:

interface=wlan0
driver=rtl871xdrv
ssid=ROVER
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0

Operating with different IP addresses

The rover's IP address can be configured. This is useful if the rover is connected to a developer's PC that in turn is connected to a gateway that has the IP 192.168.0.1. To set your custom IP address, just replace the 192.168.0.1 in hostapd.conf, dnsmasq.conf, and interfaces by your own IP. Keep in mind to only use an IP address that is valid for home networks -- in our setup we use 192.168.42.1 and 192.168.23.1. Keep in mind to also adjust the IP range for dnsmasq's DHCP range.

Troubleshooting

  • DNSmasq logs to /var/log/daemon.log
  • # service hostapd status shows whether hostapd is still there
  • # hostapd -dd /etc/hostapd/hostapd.conf starts hostapd in debug mode
  • if DNS is not working, use # ifconfig to check if wlan0 really uses IP 192.168.0.1. If not, fix it with # ifconfig wlan0 192.168.0.1

Not yet working

  • https protocol is currently not working with our server. As a result we cannot connect to https urls or bookmarks
  • Androids connection check realizes that the rover is not connected to the www and redirects the traffic to UTMS
Clone this wiki locally