[Share] Create Hotspot+Share Internet Connection To Android
#1
As many of you know, most of your android device (not only android) can't connect to ad hoc hotspots. If you using Windows no matter Windows7 / Windows 8 running in your machine,  there's a solution to setup infrastructure hotspot using software like mHotspot, connectify and many others. For Linux users also allows to create wifi hotspot to share an internet connection, but it will be ad hoc mode. So I write this tutorial how to set up infrastructure hotspot on Linux and share connection from Linux to Android device.

This's result of this tutorial which run in my Kali Linux :
Spoiler! :
[Image: sharing%2Bunixsquad.png]

And this is screenshot which I've took from my ASUS Zenfone 5.
Spoiler! :
[Image: result%2Bcreate%2Bhotspot%2Bon%2Blinux%2...ad%2B2.jpg]

You should make sure that your wifi adapter supports infrastructure hotspots. Let's start :-)

We need to install an additional tools : hostapd (hotspot server), dnsmasq (dns dhcp server). Open your terminal, type and run this command :
Spoiler! :




Code:
root@kurawa:~# apt-get install hostapd dnsmasq
If the service already start, stop it and prevent them from starting on system start up :
Spoiler! :

Code:
root@kurawa:~# service hostapd stop
root@kurawa:~# service dnsmasq stop
root@kurawa:~# update-rc.d hostapd disable
root@kurawa:~# update-rc.d dnsmasq disable

After all stoped, we need to configure somre files. Open dnmasq.conf with your favorites text editor : 
Spoiler! :

Code:
root@kurawa:~# gedit /etc/dnsmasq.conf

Add this config code :
Spoiler! :

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

Next, we need to configure hostapd config.
Spoiler! :

Code:
root@kurawa:~# gedit /etc/hostapd.conf

add this code :
Spoiler! :

Code:
# Define interface
interface=wlan0
# Select driver
driver=nl80211
# Set access point name
ssid=Unix Squad Labs
# 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=UnixSquad#123

That config will create hotspot named Unix Squad Labs with UnixSquad#123 as password. You can change ssid and password with anything you want. All done, now we just need to create bash file to launch hostpot that we setup before. Save anywhere and give name anything you want. And please dont forget save as .sh extension.
Spoiler! :

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 eth1 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
sudo iptables -D POSTROUTING -t nat -o eth1 -j MASQUERADE
# Disable routing
sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
sudo service dnsmasq stop
sudo service hostapd stop

Probably you need to change eth1 to ppp0 or eth0 or any other number which refers to your wired connection. This time to start and launch it.
Spoiler! :

Code:
root@kurawa:~# cd Desktop/LauchNyong/ && bash startwipi.sh

Enjoy :-)

So, that's all I can write how to set up infrastructure hotspot on Linux and share connection from Linux to Android device. 

Maaf bahasanya amburadul kaya tahu gejrot :v
Abisnya baru nulis diblog males buat nulis ulang. Hehehe.. Udah gitu aja semoga bermanfaat.

VISIT MY BLOG http://unixsquad.blogspot.com


Messages In This Thread




Users browsing this thread: 1 Guest(s)