Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In our campus we have a leased line connection from a service provider, which has an external IP W.X.Y.Z. This connection is distributed from the server several sub-networks / subnets as follows:

  1. Faculty: 172.33....../ 255.255.0.0
  2. Administration: 172.34......./255.255.255.0
  3. Students: 172.35...../255.255.216.0

A student has a laptop with a fixed IP address 172.35.23.123 / 255.255.216.0 where the IP address is on the ethernet port. The gateways for internet access are 172.31.1.1 and 172.31.1.2. Further the student has a wireless port which is inaccessible in the hostel area. The OS of the student is Ubuntu 12.10.

The student in the possession of an android phone on which he wishes to install specific software and therefore wishes to activate the internet therein. The student has already attempted the Wireless hotspot solution which works for 12.04 but has not been successful.

Various instructions on the internet have helped the student to do the following

Installation of dhcp server and hostapd:

sudo apt-get install isc-dhcp-server
sudo apt-get install hostapd

File: /etc/network/interfaces

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 10.10.0.1
netmask 255.255.255.0
dns-nameservers 172.31.1.1 172.31.1.2 

File: /etc/dhcp/dhcpd.conf

subnet 10.10.0.0 netmask 255.255.255.0 { 
range 10.10.0.2 10.10.0.4;
option routers 10.10.0.1; 
option domain-name-servers 172.31.1.1 172.31.1.2; 
default-lease-time 6000; 
max-lease-time 72000; 
} 

File: /etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=my_hotspot
channel=1
hw_mode=g
auth_algs=1
wpa=3
wpa_passphrase=1234567890
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
rsn_pairwise=CCMP

File: /etc/default/hostapd

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

File: /etc/default/isc-dhcp-server

INTERFACES=”wlan0”

File: /etc/rc.local

iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o eth0 -j MASQUERADE
exit 0

After all the configuration, the computer is restarted. The student can see that the hotspot named “my_hotspot” is available. The hotspot also awards an address to the android phone. The student will now be able to browse the internet.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

This is wrong - iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o wlan0 -j MASQUERADE

It should not be wlan0. It should be the interface has the internet connection. It should be

iptables -t nat -A POSTROUTING -s 10.10.0.0/16 -o eth0 -j MASQUERADE

See How to setup a wi-fi hotspot (access point mode)? for more details.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.