[GUIDE] Making infrastructure wifi hotspot on ubuntu 12.04/12.10

Search This thread

ambiguousTK

New member
Jul 22, 2013
1
0
Big Fail

i did just like you said, it didn't work... i don't care, but now i removed the two packages you mentioned and my wireless broke.... the hotspot won't stop anymore, any solution ? i installed the packages again and stop them but the wireless haven't been fixed:eek:
 

sarkar1990

Senior Member
Dec 7, 2012
951
528
New Delhi
Lol. I just turn the wifi off and then on. Stops the hotspot and returns to normal

Sent from my C5302 using Tapatalk 4 Beta
 

Hardhik

New member
Aug 18, 2013
1
0
got an error !!

Configuration file: /etc/hostapd.conf
Using interface wlan0 with hwaddr 00:16:44:61:73:2d and ssid 'myhotspot'
Station 00:92:c3:d6:6c:d6 trying to deauthenticate, but it is not authenticated.
wlan0: STA 00:92:c3:d6:6c:d6 IEEE 802.11: authenticated
wlan0: STA 00:92:c3:d6:6c:d6 IEEE 802.11: associated (aid 1)
wlan0: STA 00:92:c3:d6:6c:d6 WPA: received EAPOL-Key 2/4 Pairwise with unexpected replay counter
wlan0: STA 00:92:c3:d6:6c:d6 IEEE 802.11: deauthenticated due to local deauth request
Station 00:92:c3:d6:6c:c6 trying to deauthenticate, but it is not authenticated.
wlan0: STA 00:92:c3:d6:6c:d6 IEEE 802.11: authenticated
wlan0: STA 00:92:c3:d6:6c:d6 IEEE 802.11: associated (aid 1)
wlan0: STA 00:92:c3:d6:6c:d6 IEEE 802.11: deauthenticated due to local deauth request



somebody please help and asap ! :crying:
 
Last edited:

krishansubudhi

New member
Aug 14, 2012
4
0
set some variables

I've never worked with a proxy server, but from what I see, it seems like your problem has nothing to do with a proxy server. Something's wrong with configuration on wifi side. Try to disable network manager first, if it doesn't help, try to completely clean dnsmaq and hostapd configs and paste code from this thread again. Unfortunately I can not provide any further help, since I have a different configuration on my side.

try this on the terminal
CONFIG_DRIVER_NL80211=y
CONFIG_IEEE80211N=y

worked for me.
 

ebbano

Member
Oct 31, 2010
19
2
Xiaomi Mi 8
Very usefull!

I can simply create and connect android device to the hotspot,
BUT
i've someting wrong on DNS or DHCP settings because i can't ping to hosts on the other network (eth0).

My network is too complex then the one of your sample, the pc is not direct connect to internet.
 

OMEGA*

New member
Oct 26, 2013
1
0
How to stop!

It works fine for me.
But I can understand how to stop.
I tried Ctrl + Z //Stop
ps //active jobs
kill -9 pid // kill the start.sh process

But still hotspot is active
 
Dec 2, 2012
31
2
The connection works!
The laptop that runs the hotspot has internet. But, every device that connects to it doesn't.
Anyone has an idea how this is possible?
 
Last edited:

rajagennu

Senior Member
Oct 9, 2013
154
24
Working in Debian Wheezy

As many of you know, most of our android(not only android) devices can't connect to ad hoc hotspots. There's a solution for win7/8 users to set up infrastructure hotspot on their laptop using software like connectify and so on. Ubuntu also allows to create wifi hotspot to share internet, but it will be ad hoc one.
So here's the guide how to set up infrastructure hotspot on ubuntu 12.04/12.10. Unlike some other methods described on the internet, this one will not break default network manager.

1. First of all you should make sure, that your wifi adapter supports infrastructure hotspots. If you used connectify on your windows system and it worked, skip this step.

open terminal and type: sudo lshw | less

find -network section and make sure that driver is ath5k or ath9k, this solution will only work for those drivers, but should fit the needs for the most laptop users.



2. We now need to install 2 additional tools to make out hotspot, 1st one is hostapd(hotspot server), 2nd one is dnsmasq(dns dhcp server)

in terminal type: sudo apt-get install hostapd dnsmasq

3. stop those services if started already, and prevent them from starting on system start up.

in terminal type:
sudo service hostapd stop
sudo service dnsmasq stop
sudo update-rc.d hostapd disable
sudo update-rc.d dnsmasq disable


4. Now we need to set up config files.
in terminal type: sudo gedit /etc/dnsmasq.conf
or sudo kate /etc/dnsmasq.conf if you use kde

add those lines to the config file
Code:
# Bind to only one interface
bind-interfaces
# Choose interface for binding
interface=wlan0
# Specify range of IP addresses for DHCP leasses
dhcp-range=192.168.150.2,192.168.150.10
5. hostapd config

in terminal type: sudo gedit /etc/hostapd.conf

and add those lines

Code:
# Define interface
interface=wlan0
# Select driver
driver=nl80211
# Set access point name
ssid=myhotspot
# Set access point harware mode to 802.11g
hw_mode=g
# Set WIFI channel (can be easily changed)
channel=6
# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
wpa=2
wpa_passphrase=mypassword

You can change ssid name and password for anything you want here. Current config will create hotspot named myhotspot with mypassword password.

6. Now create anywhere you want a file named start.sh
edit it with any text editor like this:

Code:
#!/bin/bash
# Start
# Configure IP address for WLAN
sudo ifconfig wlan0 192.168.150.1
# Start DHCP/DNS server
sudo service dnsmasq restart
# Enable routing
sudo sysctl net.ipv4.ip_forward=1
# Enable NAT
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
# Disable routing
sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
sudo service dnsmasq stop
sudo service hostapd stop

You will probably need to change ppp0 in this to eth0 (or any other number which refers to your wired connection.

7. Last step. Now you can start your hotspot by starting our script. just run it using sudo sh
for me it looks like this sudo sh /home/ogyct/Desktop/start.sh because I have it on my desktop


I am not sure who is the author of this guide, I only translated it to english. But anyway if this helped, hit the thanks button. Good day :)


Ok Fellows I have verified that this tutorial is still successfully running in Ubuntu 13.10 and Debian 7 .
 

phoenix.911

Member
Mar 19, 2012
46
11
Manipal
stuck at this !!! what to do ??

* Restarting DNS forwarder and DHCP server dnsmasq
dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use
[fail]
net.ipv4.ip_forward = 1
Configuration file: /etc/hostapd.conf
Failed to create interface mon.wlan0: -23 (Too many open files in system)
Try to remove and re-create mon.wlan0
Failed to update rate sets in kernel module
Using interface wlan0 with hwaddr 94:db:c9:48:7b:88 and ssid 'wifiONlinux'
wlan0: STA 00:15:70:ad:0c:74 IEEE 802.11: disassociated
wlan0: IEEE 802.11 disassociated
net.ipv4.ip_forward = 0
* Stopping DNS forwarder and DHCP server dnsmasq * (not running)
pnx@phoenix:~/HOST
 

neo1691

Senior Member
Dec 19, 2010
1,293
252
Germany
I was also getting the "obtaining the IP address" error. Two hours of tweaking and I find out that dnsmasq, the service responsible for providing IP address to other devices, was not getting started.

So I tweaked the /etc/dnsmasq.conf and stopped bind9 and dnsmasq and then first I started dnsmasq and then bind9 and now everything works like a charm! :)
 

prahladyeri

Senior Member
Jun 2, 2013
79
34
India
prahladyeri.github.io
Program to start infrastructure wifi on ubuntu 12.04

I've developed a python GUI program to seamlessly create a wifi infrastructure hotspot on ubuntu 12.04 and later by a single click. :cowboy:

sourceforge.net/p/pyforward

Please note that hostapd package must be installed on your ubuntu machine prior to running the program:

sudo apt-get install hostapd
 

joshiss

Senior Member
Feb 23, 2014
80
13
mumbai
help in deciding

*-pci:2
description: PCI bridge
product: 5 Series/3400 Series Chipset PCI Express Root Port 4
vendor: Intel Corporation
physical id: 1c.3
bus info: pci@0000:00:1c.3
version: 06
width: 32 bits
clock: 33MHz
capabilities: pci pciexpress msi pm normal_decode bus_master cap_list
configuration: driver=pcieport
resources: irq:42 memory:d0700000-d07fffff
*-network
description: Wireless interface
product: Centrino Advanced-N 6200
vendor: Intel Corporation
physical id: 0
bus info: pci@0000:43:00.0
logical name: wlan0
version: 35
serial: 00:27:10:14:e9:20
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=3.13.0-11-generic firmware=9.221.4.1 build 25532 ip=192.168.0.105 latency=0 link=yes multicast=yes wireless=IEEE 802.11abgn
resources: irq:47 memory:d0700000-d0701fff
+++++++++++++++++++++++++++++++++++++++++++++++++++

does my network card support AP i couldn't figure out whether it is ath5k or ath9k
 

Stanislav GE

Member
May 3, 2014
6
1
I am not sure who is the author of this guide, I only translated it to english. But anyway if this helped, hit the thanks button. Good day :)

Hi,

I'm the author of the original script (here is the original link habrahabr.ru/post/122876/) and today I have updated it.
Initially it was created with "easy to read" in mind however multiple sudo is not good, so I decided to make some cleanup work. It was necessary to make some changes regarding dnsmasq as it is often used by "Network Manager" in modern Linux distributions. Also I put everything in one script, so no need to create conf-files separately. And finally you can mention WIFI and LAN interfaces easily from command line.

github.com/giner/helplinux/tree/master/scripts/wifi-host-ap

Any feedback is welcome.

Best regards,
Stanislav
 

goku911

New member
Jul 2, 2014
1
0
You wireless card doesn't support the AP operation mode. You can look up on the hostapd support website and there is a list of suppored devices. The BCM 4313 is part of brcmsmac which is in the NO section for AP. You would need to get a new card or purchase an external wifi card. Hope this helps.

My wifi device is BCM4313. The brcmsmac driver has been updated as of now. It supports AP mode also. This thing actually works!:laugh::good:
 

Top Liked Posts

  • There are no posts matching your filters.
  • 29
    As many of you know, most of our android(not only android) devices can't connect to ad hoc hotspots. There's a solution for win7/8 users to set up infrastructure hotspot on their laptop using software like connectify and so on. Ubuntu also allows to create wifi hotspot to share internet, but it will be ad hoc one.
    So here's the guide how to set up infrastructure hotspot on ubuntu 12.04/12.10. Unlike some other methods described on the internet, this one will not break default network manager.

    1. First of all you should make sure, that your wifi adapter supports infrastructure hotspots. If you used connectify on your windows system and it worked, skip this step.

    open terminal and type: sudo lshw | less

    find -network section and make sure that driver is ath5k or ath9k, this solution will only work for those drivers, but should fit the needs for the most laptop users.



    2. We now need to install 2 additional tools to make out hotspot, 1st one is hostapd(hotspot server), 2nd one is dnsmasq(dns dhcp server)

    in terminal type: sudo apt-get install hostapd dnsmasq

    3. stop those services if started already, and prevent them from starting on system start up.

    in terminal type:
    sudo service hostapd stop
    sudo service dnsmasq stop
    sudo update-rc.d hostapd disable
    sudo update-rc.d dnsmasq disable


    4. Now we need to set up config files.
    in terminal type: sudo gedit /etc/dnsmasq.conf
    or sudo kate /etc/dnsmasq.conf if you use kde

    add those lines to the config file
    Code:
    # Bind to only one interface
    bind-interfaces
    # Choose interface for binding
    interface=wlan0
    # Specify range of IP addresses for DHCP leasses
    dhcp-range=192.168.150.2,192.168.150.10
    5. hostapd config

    in terminal type: sudo gedit /etc/hostapd.conf

    and add those lines

    Code:
    # Define interface
    interface=wlan0
    # Select driver
    driver=nl80211
    # Set access point name
    ssid=myhotspot
    # Set access point harware mode to 802.11g
    hw_mode=g
    # Set WIFI channel (can be easily changed)
    channel=6
    # Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
    wpa=2
    wpa_passphrase=mypassword

    You can change ssid name and password for anything you want here. Current config will create hotspot named myhotspot with mypassword password.

    6. Now create anywhere you want a file named start.sh
    edit it with any text editor like this:

    Code:
    #!/bin/bash
    # Start
    # Configure IP address for WLAN
    sudo ifconfig wlan0 192.168.150.1
    # Start DHCP/DNS server
    sudo service dnsmasq restart
    # Enable routing
    sudo sysctl net.ipv4.ip_forward=1
    # Enable NAT
    sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
    # Run access point daemon
    sudo hostapd /etc/hostapd.conf
    # Stop
    # Disable NAT
    sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
    # Disable routing
    sudo sysctl net.ipv4.ip_forward=0
    # Disable DHCP/DNS server
    sudo service dnsmasq stop
    sudo service hostapd stop

    You will probably need to change ppp0 in this to eth0 (or any other number which refers to your wired connection.

    7. Last step. Now you can start your hotspot by starting our script. just run it using sudo sh
    for me it looks like this sudo sh /home/ogyct/Desktop/start.sh because I have it on my desktop


    I am not sure who is the author of this guide, I only translated it to english. But anyway if this helped, hit the thanks button. Good day :)
    1
    I have an eth0 connection running behind an authenticated proxy server.
    I followed the steps and managed to create a hotspot which my google nexus 7 detects. However, it seems stuck at "obtaining an ip address" and is not able to connect to the internet.

    I initially received the following error message when running your script in the terminal:

    dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use [fail]​

    I figured it is because of a conflict with the network manager, I uncommented "dns=dnsmasq" line in the nm configuration file. After a network-manager restart, the first error doesn't show up but I get the following:

    Configuration file: /etc/hostapd.conf
    Failed to create interface mon.wlan0: -23 (Too many open files in system)
    Try to remove and re-create mon.wlan0​

    In both cases, however, the hotspot is created and is detected by my android device. only that it cannot "obtain an ip address" and connect to it.
    Is it because my eth0 connects via a proxy server?
    Or could there be something wrong with the dnsmasq config? Any help would be appreciated.

    I've never worked with a proxy server, but from what I see, it seems like your problem has nothing to do with a proxy server. Something's wrong with configuration on wifi side. Try to disable network manager first, if it doesn't help, try to completely clean dnsmaq and hostapd configs and paste code from this thread again. Unfortunately I can not provide any further help, since I have a different configuration on my side.
    1
    My galaxy s2 is able to see the "myhotspot" network created following this guide. I set a static ip and gateway to make it obtain an ip address.
    Now it seems to be connected, but I have no internet access on my phone...
    Could anyone help me?

    I am using ubuntu 12.04 and I just figured out the instructions on ".../questions/180733/how-to-setup-a-wi-fi-hotspot-access-point-mode/" (askubuntu) thread worked like a charm for me. It uses the isc-dhcp-server instead of dnsmasq and a different dhcp range I guess. I really don't know enough to tell the difference but it worked. Maybe ogyct can explain it to us.