17
Apr
2014

Using Ubuntu Server 13.10 as a wireless hotspot

In my bedroom the wireless signal from our crappy Virgin Media “Superhub” leaves a lot to be desired. My smartphone (Sony Xperia U) continuously disconnects and reconnects, wasting battery:

Crap Wifi

Mine is the blue network, way down near the bottom. I get better signal from the neighbours!

I had a spare wireless G card lying about, so I loaded it into the home server:

 

Both cards are identical: Edimax Wireless G (model no EW-7128g) using the RT2561ST chipset. This can be done with only one wireless card if you have a wired connection to the internet.

To find out if your card supports Access Point mode, type in the following command:

iw list

The output should produce several lines of text; look for the section labelled “Supported interface modes” and see if AP is listed like so:

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

Here, my card does support Access Point mode. To enable this functionality, the following packages need to be installed:

sudo apt-get install hostapd isc-dhcp-server

Once these two packages have been installed, you need to edit your /etc/network/interfaces file as shown below:

# The connection to the internet (this does not need to be changed)
auto wlan0
iface wlan0 inet static
address 192.168.0.100
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
dns-search home
wpa-ssid ****
wpa-psk ****

# The wireless network interface that will become the hotspot (it could be wlan0 in your case)
auto wlan1
iface wlan1 inet static
address 192.168.1.1
netmask 255.255.255.0

Save and close the file. Next you need to edit /etc/default/hostapd.conf and make sure the file has the following lines:

RUN_DAEMON=”yes”
DAEMON_CONF=”/etc/hostapd/hostapd.conf”
DAEMON_OPTS=”-dd”

Save and close the file. Now open /etc/hostapd/hostapd.conf and specify your Access Point name, security, passphrase etc:

### Wireless network name ###
interface=wlan1
### Driver ###
driver=nl80211
### (IN == INDIA, UK == United Kingdom, US == United Stats and so on ) ###
country_code=UK
### SSID ###
ssid=(insert your network name here)
### Operation mode (could be n if you have a newer card) ###
hw_mode=g
### Wireless channel (select one with the least interference, use WiFi analyser for Android to find this out) ###
channel=3
### WPA mode ###
wpa=3
### Passphrase ###
wpa_passphrase=(insert your passphrase here)
## Key management algorithms ##
wpa_key_mgmt=WPA-PSK
## Set cipher suites (encryption algorithms) ##
## TKIP = Temporal Key Integrity Protocol
## CCMP = AES in Counter mode with CBC-MAC
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP
## Shared Key Authentication ##
auth_algs=1
## Accept all MAC address ##
macaddr_acl=0

Save and close the file. At this point, the hotspot will be functional, but there won’t be any DHCP services to wireless clients! So next, open /etc/default/isc-dhcp-server and specify the interface the server should operate on (remember yours could be different to mine):

INTERFACES=”wlan1″

Save and close the file. Next, open /etc/dhcp/dhcpd.conf (this may be /etc/dhcp3/dhcpd.conf for you) and add the following lines at the bottom:

ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.20;
option domain-name-servers 8.8.8.8;
option routers 192.168.1.1;
}

Save and close the file. Now, reboot your server with the command sudo reboot. Your wireless access point should be active now:

Screenshot_2014-04-17-16-00-51

Aah, that is much better. I could not resist giving it an amusing name. You may notice, however, that there is no internet access! To fix this, an iptables command must be applied to allow packet transfer between your internet interface and the wireless access point interface:

sudo iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o wlan1 -j MASQUERADE

Replace the IP with the IP for the network with the wireless access point and wlan1 with the name for your access point interface.

Reboot and that should be it! Comment below for questions.

Home internet
Hostapd issue in Ubuntu 14.04

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.