Open terminal and type sequentially
sudo lshw | less
sudo apt-get install hostapd dnsmasq
sudo service hostapd stop
sudo service dnsmasq stop
sudo update-rc.d hostapd disable
sudo update-rc.d dnsmasq disable
Now set up config file
sudo gedit /etc/dnsmasq.conf
or
sudo kate /etc/dnsmasq.conf
ADD those lines to config file
# 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 hotspad config file
sudo gedit /etc/hostapd.conf
ADD those lines
# 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 and password also
Now open an empty document @home named start.sh and type those lines
#!/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 eth0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
sudo iptables -D POSTROUTING -t nat -o eth0 -j MASQUERADE
# Disable routing
sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
sudo service dnsmasq stop
sudo service hostapd stop
Finally run this by typing
sudo sh start.sh
Note: Common error:
dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use [fail]
Solution:
Open Network configuration manager
sudo gedit /etc/NetworkManager/NetworkManager.conf
Just comment out
//dns=dnsmasq
It should be like that:
[main]
plugins=ifupdown,keyfile
//dns=dnsmasq
no-auto-default=E8:03:9A:0F:4E:DC,
[ifupdown]
managed=false
Now restart your PC and run
./start.sh
and enjoy.....
No comments:
Post a Comment
Thanks for your comments