Jump to content

Mk4 Usb Wifi Dongle Internet Sharing How-To


Recommended Posts

The latest firmware the Pineapple now has a fantastic amazing new feature - built in the drivers for various USB wifi chipsets. Primarily the Ath9k driver from what I can tell so far. In order to use this guide you'll need a supported USB wifi dongle and a MKIV Pineapple. I used a TP-Link WN722N (Also works well with reaver). Before you buy a wifi adaptor please google the model number to determine its chipset.

Supported USB Wifi Devices:

Assumptions:

  • You'll be connecting to an existing access point that's running WPA2 encryption & you know the password for the network.
  • Your pineapple is running v2.4 or greater.

To begin, connect your wifi adaptor to the pineapple and issue the command

iwconfig[/CODE]

To confirm you adaptor is compatible there should be an entry for wlan1 in the list. wlan0 is the pineapple's internal wifi adaptor.

Next you'll need to create your wpa supplicant configuration file. WPA supplicant is the program used to negotiate WPA2 encryption and the configuration file holds your network password.

[CODE]vi /etc/wpa_supplicant.conf[/CODE]

Press the i key then paste this text in the file, then save the file by typing these characters :wq

[CODE]network={
ssid="Your network name here"
psk="Your password here"
}[/CODE]

To save myself from entering the ip forwarding commands each time I put them in a shell script.

Create the script file in your home directory and insert the following code. Follow the step above for inserting text into the vi editor.

The script makes some assumptions, such as you haven't changed the ip range for the pineapple wireless lan and that the usb wifi adaptor you plugged in is wlan1.

The script will also clear any existing iptables, if you have iptables entries you don't want lost remove the -F and -X lines.

[CODE]vi ~/wireless_connect.sh[/CODE]

[CODE]#!/bin/sh

#Change the Mac address of the usb wifi to something random.
ifconfig wlan1 down
macchanger -A wlan1
ifconfig wlan1 up


#WPA2 - Let's assume we're going to connect to a WPA2 network
wpa_supplicant -B -D nl80211 -i wlan1 -c /etc/wpa_supplicant.conf

#WEP - Uncomment if you want to conect to a WEP network
#iwconfig wlan1 mode managed key your_key_here
#iwconfig wlan1 essid "your access point name here"

#OPEN - Uncomment if you want to conect to a WEP network
#iwconfig wlan1 essid "your access point name here"


#Setup ipforwarding via iptables.
echo 1 > /proc/sys/net/ipv4/ip_forward

#Reset iptables
iptables -F
iptables -X

iptables -A FORWARD -o wlan1 -i br-lan -s 172.16.0.0/24 -m conntrack --ctstate NEW -jACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

#Wait for 6 seconds to give enough time for association.
sleep 6

#Grab an ip via DHCP
udhcpc -i wlan1[/CODE]

Change the permissions of your script so you can execute it.

[CODE]chmod +x ~/wireless_connect.sh[/CODE]

Execute the script and then if all goes well you'll have internet on the pineapple which can be shared out to clients that connect to the Karma/Pineapple SSID. No more needing a USB 3G dongle.

[CODE]cd ~
./wireless_connect.sh[/CODE]

[u][b]Troubleshooting[/b][/u]

[b]It does not associated with the access point [/b]

[indent=1]Bummer. Try running the WPA supplicant connection without the -B flag. The -B mode makes it run as a daemon task in the background.[/indent]

[indent=1]wpa_supplicant -Dnl80211 -iwlan1 -c/etc/wpa_supplicant.conf[/indent]

[indent=1]Check the errors that are output for a hint as to what's going wrong. If it complains about the wireless driver change the text 'nl80211' (This is the driver that worked for my TP-Link USB stick) to wext.[/indent]

[b]It does not get an ip via DHCP[/b]

[indent=1]Did you check that wpa_supplicant could associate with the access point? If it does associate correctly then perhaps there is no DHCP server running on that network. Try setting an ip address manually for the wlan1 adaptor.[/indent]

[indent=1]ifconfig wlan1 192.168.0.10 255.255.255.0[/indent]

[b]Karma wont start after running the above steps[/b]

[indent=1]I had this issue running version 2.4.1. Upgrading to 2.5.0 corrected this issue. Unsure what the cause was, perhaps it was some other development of my own interfering.[/indent]

[b]How do I test to see if it's working?[/b]

[indent=1]ping google.com

Did it reply with a ping? It's working, if not damn something has gone wrong.[/indent]

Edited by Isc
Link to post
Share on other sites

Nice write up Isc! I particularly appreciate how you voice your assumptions to head off the otherwise inevitable clarification questions and even did up a little troubleshooting guide - saves everyone time! Thanks man

telot

Link to post
Share on other sites

Yep, it'll work with WEP and unsecured connections. To connect to a WEP network you have to use iwconfig and enter the password using that command. In the script you'd replace the line

wpa_supplicant -B -Dnl80211 -iwlan1 -c/etc/wpa_supplicant.conf[/CODE]

[color=#000000]with whatever method you use to connect to your wireless lan.[/color]

[color=#000000][b]For WEP[/b], r[/color][color=#000000]eplace the wpa_supplicant line with ... and change the '[/color]your_key_here' to your wep key

[CODE]
iwconfig wlan1 mode managed key your_key_here
iwconfig wlan1 essid "your access point name here"
[/CODE]

[b]For open networks[/b], replace the wep_supplicant line with

[CODE]iwconfig wlan1 essid "your access point name here"[/CODE]

Edited by Isc
Link to post
Share on other sites

Thank you so much for shareing:-D

I made a mod to the bash script so it works better/quicker


#!/bin/sh

ifconfig wlan1 down
macchanger -A wlan1
ifconfig wlan1 up


#WPA2
wpa_supplicant -B -D nl80211 -i wlan1 -c /usb/wpa_supplicant.conf

#WEP
#iwconfig wlan1 mode managed key your_key_here
#iwconfig wlan1 essid "your access point name here"

#OPEN
#iwconfig wlan1 essid "your access point name here"


#Setup ipforwarding via iptables.
echo 1 > /proc/sys/net/ipv4/ip_forward

#Reset iptables
iptables -F
iptables -X

iptables -A FORWARD -o wlan1 -i br-lan -s 172.16.0.0/24 -m conntrack --ctstate NEW -jACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

#Wait for 6 seconds to give enough time for association.
sleep 6

#Grab an ip via DHCP
udhcpc -i wlan1
[/CODE]

what I changed was I keep my wpa_supplicant.conf in /usb/

added ifconfig wlan1 up

and sleep 6 before the dhcp process

EDIT:

added both WEP and OPEN commands, just uncomment and comment out the other:-)

added random mac via macchanger -A wlan1

Great work Hackling:-D

Edited by petertfm
Link to post
Share on other sites

I can confirm that this worked out of the box on my MK4 with a TP-LINK TL-WN722N.

This thread is an example of an epic win for the new player nice job!

EDIT: MK4 running 2.4.1 Karma functions normally.

Edited by itsm0ld
Link to post
Share on other sites

I plan to make this into a pineapple module within the next few days, maybe over the weekend.

Whistlemaster is already working on one, maybe talk to him about it.

We are actually going to include it directly into the firmware under a "Connections UI".

That is also nearing completition.

Best,

Sebkinne

Link to post
Share on other sites

Whistlemaster is already working on one, maybe talk to him about it.

We are actually going to include it directly into the firmware under a "Connections UI".

That is also nearing completition.

Best,

Sebkinne

Great:-)

Seb is it WM's code that you are planning on including into the firmware? currious

Link to post
Share on other sites

Whistlemaster is already working on one, maybe talk to him about it.

Indeed ;)

The module will support different modes (AP, client) and protocols (WPA / WPA2 Personal & Enterprise, WEP), Interface Connection Sharing. It is almost ready.

Edited by Whistle Master
Link to post
Share on other sites

I have Mk IV with 2.5.1 firmware. I have Atheros based AWUS036NHA USB wifi adapter which came with Mk IV as a package. I followed your wpa_supplicant script. The card seems to be brought up ok as wlan1, macchanges OK, but the script quits with error "ifconfig: SIOCGIFFLAGS: No such device". After this happens, the adapter is no longer recognized; plugging, unplugging, etc., doesn't help. Only thing that will fix it is reboot. After reboot, the adapter is recognized again, but the same thing happens. I tried AWUS036H adapter I had which works fine with your wpa_supplicant script, but for some reason, randomly drops out after about an hour or so. Then I have to reboot again. Any ideas? Is this a driver issue? Hardware?

Link to post
Share on other sites

I have Mk IV with 2.5.1 firmware. I have Atheros based AWUS036NHA USB wifi adapter which came with Mk IV as a package. I followed your wpa_supplicant script. The card seems to be brought up ok as wlan1, macchanges OK, but the script quits with error "ifconfig: SIOCGIFFLAGS: No such device". After this happens, the adapter is no longer recognized; plugging, unplugging, etc., doesn't help. Only thing that will fix it is reboot. After reboot, the adapter is recognized again, but the same thing happens. I tried AWUS036H adapter I had which works fine with your wpa_supplicant script, but for some reason, randomly drops out after about an hour or so. Then I have to reboot again. Any ideas? Is this a driver issue? Hardware?

mk4 firmware 2.5.1?

I would say a power issue, I have to use a usb powered hub in order to get the NHA to function, there is not enough power in the mk4 usb port for the NHA unless you take the txpower down iwconfig wlan1 txpower 8

Edited by petertfm
Link to post
Share on other sites

oops. 2.4.1.

Anyways, I'm trying it with an old low power Hawking adapter with Ralink set. It seems to be working well given lower power consumption. I just ordered a powered usb hub from Amazon so I can try it out with the NHA. Thanks for the info.

Link to post
Share on other sites

Im having a problem with getting the TP-Link WN722N going.

I have mk4 with 2.5, First run with standard script it attempts to get an IP address and then stopped so I removed the -B from the wpa_supplicant line it then returns "wlan1: Failed to initiate AP scan" three times then and stops. Commenting out everything but the wpa_supplicant line gives the same results.

This is the output with the normal commenting.


root@Pineapple:~# iwconfig wlan1
wlan1 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off



root@Pineapple:~# cat ./wireless_connect2.sh
#!/bin/sh

#Change the Mac address of the usb wifi to something random.
ifconfig wlan1 down
macchanger -A wlan1
ifconfig wlan1 up


#WPA2 - Let's assume we're going to connect to a WPA2 network
wpa_supplicant -D nl80211 -i wlan1 -c /etc/wpa_supplicant.conf

#WEP - Uncomment if you want to conect to a WEP network
#iwconfig wlan1 mode managed key your_key_here
#iwconfig wlan1 essid "your access point name here"

#OPEN - Uncomment if you want to conect to a WEP network
#iwconfig wlan1 essid "your access point name here"


#Setup ipforwarding via iptables.
echo 1 > /proc/sys/net/ipv4/ip_forward

#Reset iptables
iptables -F
iptables -X

iptables -A FORWARD -o wlan1 -i br-lan -s 172.16.0.0/24 -m conntrack --ctstate NEW -jACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

#Wait for 6 seconds to give enough time for association.
sleep 6

#Grab an ip via DHCP
udhcpc -i wlan1


root@Pineapple:~# cat /etc/wpa_supplicant.conf
network={
ssid="ssid"
psk="password"
}

[/CODE]

Putting in the correct SSID has helped, but now its telling me this.

[CODE]
root@Pineapple:~# ./wireless_connect2.sh
Current MAC: 00:60:04:b0:90:58 (Computadores Modulares Sa)
Faked MAC: 00:c0:c3:40:34:66 (Acuson Computed Sonography)
wlan1: Failed to initiate AP scan
wlan1: SME: Trying to authenticate with 90:f6:52:48:43:30 (SSID='Mack_2.0' freq=2412 MHz)
wlan1: Trying to associate with 90:f6:52:48:43:30 (SSID='Mack_2.0' freq=2412 MHz)
wlan1: Associated with 90:f6:52:48:43:30
wlan1: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
wlan1: CTRL-EVENT-DISCONNECTED bssid=90:f6:52:48:43:30 reason=3
wlan1: CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=3
wlan1: SME: Trying to authenticate with f8:d1:11:93:c2:3f (SSID='Mack_2.0' freq=2412 MHz)
wlan1: Trying to associate with f8:d1:11:93:c2:3f (SSID='Mack_2.0' freq=2412 MHz)
wlan1: Associated with f8:d1:11:93:c2:3f
wlan1: CTRL-EVENT-DISCONNECTED bssid=f8:d1:11:93:c2:3f reason=3
wlan1: CTRL-EVENT-DISCONNECTED bssid=00:00:00:00:00:00 reason=3
wlan1: SME: Trying to authenticate with 90:f6:52:48:43:30 (SSID='Mack_2.0' freq=2412 MHz)
wlan1: Trying to associate with 90:f6:52:48:43:30 (SSID='Mack_2.0' freq=2412 MHz)
wlan1: Associated with 90:f6:52:48:43:30
wlan1: WPA: 4-Way Handshake failed - pre-shared key may be incorrect
[/CODE]

Edited by TunezNZ
Link to post
Share on other sites

I have got it working now on a different network. I think it has something to-do with having the pineapple connected on the lan connection and trying to join the same network, I find funny things happen when I connect the pineapple up to my lan (With the exit gateway/router 172.16.42.42) such as it stealing all the DHCP clients and setting the pineapple as the default gateway.

Edited by TunezNZ
Link to post
Share on other sites

To TunezNZ - have you tried other wifi cards, dongles, etc.? It could be either driver or hardware issue. In my case, an old Hawking dongle actually works most reliably.

Also ... I thought I had all this figured out till ... firmware 2.5. Since I upgraded, the connection seems much less reliable. It takes much longer to get an IP assigned by DHCP from the AP. Also when I ping various IP's to test the connection (signed in as root from the pineapple and as a client going through the pineapple), I get approximately 30-40% packet loss pinging google, yahoo, AND my own gateway. I'm in S. California, but 100-200msec response times from google and yahoo seems way too long. response time for my router @ 192.168.1.254 is about 30-40msec which is WAAAY too long. When I'm signed in directly to the router/AP, the response time is about 1-2msec. (My entire relay set-up is about 5 feet from the AP and I'm about 5 feet from AP and the pineapple.

It almost feels like my packets are getting lost and wondering around the inside of the pineapple. Some make it; some don't.

Any thoughts or suggestions?

PS Any other driver than nl80211 I can try?

Edited by 7ncubane
Link to post
Share on other sites
  • 1 month later...

This. Is. Fantastic. And it just so happens that I happen to have that exact model of USB dongle already. ;)

I got caught up on one thing, though. It's pretty silly, but worth mentioning methinks: make sure you put in the quotes around the SSID and PW fields in the wpa_supplicant.conf.

Link to post
Share on other sites
  • 1 month later...

Hey guys,

Is anyone having issues with their card turning off after a period of time?

I'm running mark IV 2.7 firmware, a NHA card that came with the pineapple.

I have been getting the card to boot up and scan but after a little while the card just turns itself off. This happens with my old alfa card too.

Any ideas?

Link to post
Share on other sites

Hey guys,

Is anyone having issues with their card turning off after a period of time?

I'm running mark IV 2.7 firmware, a NHA card that came with the pineapple.

I have been getting the card to boot up and scan but after a little while the card just turns itself off. This happens with my old alfa card too.

Any ideas?

Sounds like a power issue, the mk4 can't supply enough amperage to most USB devices. Try a powered hub.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...