Sunday, March 30, 2014

Create wifi hotspot on Ubuntu 12 04 12 10

Ok, its sad that Android devices dont support connection to ad-hoc wifi but there are some methods. For example, for Windows 7 there is Connectify, its true its not free, but it exist! But for Linux? Im a Linux fan, I work a lot on Linux and I want to have the posibility to connect my gadgets to a hotspot but Linux creates from default ad-hoc connections. But there is a solutions and its FREE!
All you have to do is to open terminal and enter some commands. And Ill publish the steps!

  1. open terminal and type: sudo lshw | less ; find -netwok section and make sure that driver is ath5k or ath9k. If you made a hotspot with Connectify on Windows7 and it worked, you can skip this step.
  2. install hostapd and dnsmasq by typing: sudo apt-get install hostapd dnsmasq
  3. stop those services and prevent them from starting on system start up:
    • sudo service hostapd stop
    • sudo service dnsmasq stop
    • sudo update-rc.d hostapd disable
    • sudo update-rc.d dnsmasq disable
  4. configure dnsmasq:sudo gedit /etc/dnsmasq.conf and add:
    1. # Bind to only one interface
    2. bind-interfaces
    3. # Choose interface for binding
    4. interface=wlan0
    5. # Specify range of IP addresses for DHCP leasses
    6. dhcp-range=192.168.150.2,192.168.150.10
  5. configure hostapd:sudo gedit /etc/hostapd.conf and add:
    1. # Define interface
    2. interface=wlan0
    3. # Select driver
    4. driver=nl80211
    5. # Set access point name
    6. ssid=myhotspot
    7. # Set access point harware mode to 802.11g
    8. hw_mode=g
    9. # Set WIFI channel (can be easily changed)
    10. channel=6
    11. # Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
    12. wpa=2
    13. wpa_passphrase=mypassword
  6. create a file named start.sh and add the following lines:
    1. #!/bin/bash
    2. # Start
    3. # Configure IP address for WLAN
    4. sudo ifconfig wlan0 192.168.150.1
    5. # Start DHCP/DNS server
    6. sudo service dnsmasq restart
    7. # Enable routing
    8. sudo sysctl net.ipv4.ip_forward=1
    9. # Enable NAT
    10. sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
    11. # Run access point daemon
    12. sudo hostapd /etc/hostapd.conf
    13. # Stop
    14. # Disable NAT
    15. sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
    16. # Disable routing
    17. sudo sysctl net.ipv4.ip_forward=0
    18. # Disable DHCP/DNS server
    19. sudo service dnsmasq stop
    20. sudo service hostapd stop
  7. start hotspot by starting your script "start.sh"
PS: Im not the author of this tutorial but it helped me and Im sure that it works!

Related Posts by Categories

0 comments:

Post a Comment