This question is an exact duplicate of:

I have two USB wireless cards, wlan0 and wlan1.

wlan0 is connected to a wifi far away using a yagi antenna (I have a house pretty far from "civilization" so I'm using an public open wifi)

So what i want, is to be able to share that connection to my android phone, since i can't really connected the yagi antenna to the android, i want to create a hotspot so that i can get internet to my android phone but still have the connection on my kali machine. Is this possible and if so how?

marked as duplicate by jasonwryan, Rui F Ribeiro, dirkt, schily, andcoz Jul 24 '18 at 10:34

This question was marked as an exact duplicate of an existing question.

  • Why, o why do people have to use Kali Linux for tasks for which is wasn't made, and which will only cause you trouble? Please read this, and use a distro more suitable for this. Any distro but Kali. And yes, making a hotspot is simple. – dirkt Jul 24 '18 at 8:18

First download some necessary drivers from here. Then

 In terminal type lspci If you use usb wireless adapter type command lsusb

apt-get install hostapd dnsmasq

in terminal type:

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

set up config files in terminal type:

 gedit /etc/dnsmasq.conf or kate /etc/dnsmasq.conf if you use kde...

add those lines to the config file:

# Bind to only one interface
# Choose interface for binding
# Specify range of IP addresses for DHCP leasses

In terminal type: 

gedit /etc/hostapd.conf

and add them

# Define interface
# Select driver
# Set access point name
# Set access point harware mode to 802.11g
# Set WIFI channel (can be easily changed)
# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)

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

Now create anywhere you want a file named it hotspot.sh (best way to save script on Desktop) Edit it with any text editor like this:

# Start
# Configure IP address for WLAN
sudo ifconfig wlan0
# 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.

Last step.

Now you can start your hotspot by starting script. Just run it...  For me it looks like this:

root@kali:~# cd /root/Desktop/
root@kali:~/Desktop# ./hotspot.sh

 If you doesn't want to do so, you can install pwnstar which works with any driver

  • I will try that! Btw, my first network adapter: Bus 002 Device 005: ID 0cf3:9271 Atheros Communications, Inc. AR9271 802.11n The second one: Bus 002 Device 006: ID 0846:4260 NetGear, Inc. WG111v3 54 Mbps Wireless [realtek RTL8187B] – Xane Jul 24 '18 at 5:06
  • One more thing: "You will probably need to change ppp0 in this to eth0 or any other number which refers to your wired connection." Since i only have wireless connection should i choose wlan0? – Xane Jul 24 '18 at 5:11
  • try with ppp0 if it doesn't work then try wlan0 – usamypwd Jul 24 '18 at 5:16
  • And in sudo ifconfig wlan0 , replace wlan0 with wlan1 if any error occurs(every wlan0 with wlan1) – usamypwd Jul 24 '18 at 5:17
  • Just tried it but got this: root@Alpha:~/Desktop# ./hotspot.sh net.ipv4.ip_forward = 1 Configuration file: /etc/hostapd.conf nl80211: Could not configure driver mode nl80211: deinit ifname=wlan0 disabled_11b_rates=0 nl80211 driver initialization failed. wlan0: interface state UNINITIALIZED->DISABLED wlan0: AP-DISABLED hostapd_free_hapd_data: Interface wlan0 wasn't started net.ipv4.ip_forward = 0 root@Alpha:~/Desktop# any idea? – Xane Jul 24 '18 at 5:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.