KEuVUe149Y7e320zVKJqOjpo0SGIHzz7ueew9qo8
Bookmark

Create Hotspot On Linux And Share Internet Connection To Android Device

Create Hotspot On Linux Android Supported - As 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 :

Create Hotspot On Linux And Share Internet Connection To Android Device

And this is screenshot which I've take from my ASUS Zenfone 5.

Create Hotspot On Linux And Share Internet Connection To Android Device

You should make sure that your wifi adapter supports infrastructure hotspots. First, we need to install an additional tools : hostapd (hotspot server) and dnsmasq (dns dhcp server). Open your terminal, type and run this command :

apt-get install hostapd dnsmasq

If the service already start, stop it and prevent them from starting on system start up :

service hostapd stop
service dnsmasq stop
update-rc.d hostapd disable
update-rc.d dnsmasq disable

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

gedit /etc/dnsmasq.conf

Add this config 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

Open your hostapd.conf use text editor to configure it :

gedit /etc/hostapd.conf

Add this code and save it :

# 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 code file to launch hostpot that we set up before. Save anywhere and give it name anything you want. And please don't forget save as .sh extension.

#!/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. And now, this time to start and launch it.

cd Desktop/LauchNyong/ && bash startwipi.sh

Those command means :
cd Desktop/LauchNyong/ - Open LaunchNyong directory which bash file to launch hotspot saved.
&& bash startwipi.sh - Run startwipi.sh file to start hostspot.

Enjoy! Looking for GUI version? Already posted. Read Share Internet Connection From Ubuntu to Any Android Devices

This tutorial tested on my Kali Linux. So, that's all I can write how to set up infrastructure hotspot on Linux and share connection from Linux to Android device. Thanks for visit.