Page 1 of 21

[Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)

Posted: Wed Oct 03, 2012 2:06 pm
by hunternet93

The tutorial has now been moved to: http://elinux.org/RPI-Wireless-Hotspot

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Wed Oct 03, 2012 2:38 pm
by malakai
Looks great can't wait to get home and try it out.

What wireless adapter are you using?

Also want to try out with http://www.raspberrypi.org/phpBB3/viewt ... =41&t=3059 A DIY PoE.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Wed Oct 03, 2012 2:53 pm
by bredman
A warning for all readers...

Most WiFi adaptors cannot support Access Point mode, so be careful if you buy something just for this purpose.

You need a WiFi device which supports "AP mode" or "Master mode".

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Wed Oct 03, 2012 3:56 pm
by hunternet93
malakai wrote:Looks great can't wait to get home and try it out.

What wireless adapter are you using?

Also want to try out with http://www.raspberrypi.org/phpBB3/viewt ... =41&t=3059 A DIY PoE.
I'm currently using a cheap dongle from Amazon using a Ralink chipset, I'm not sure of the exact model. PoE would be cool combined with the Pi, I may try that out.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Wed Oct 03, 2012 4:30 pm
by Linus
The guy in this http://sirlagz.net/2012/08/09/how-to-us ... er-part-1/ tutorial uses

Code: Select all

iw list
to determine if the dongle has Acces Point capabilities.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Wed Oct 03, 2012 7:31 pm
by hunternet93
Unless I am very mistaken, the wireless dongle does not need to support master mode. HostAPD (host access point daemon) uses low-level WiFi magic to turn any supported wireless card into an access point, hardware master mode not required. I just got a really cheap dongle off Amazon for this, it doesn't support master mode but hostapd works great.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Wed Oct 03, 2012 7:47 pm
by malakai
When I get home or time I will test on cards I know that have neither supported I believe the software should handle all the issues that would require such adapters.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Thu Oct 04, 2012 9:08 pm
by poing
This does sound interesting and is exactly what I need for my embedded project, so, after a double backup of my precious installation ;) , I tried it, but it doesn't work :( .

Is the line:
"iptables-restore < /etc/iptables.ipv4.nat " correct, or should it be:
"iptables-restore > /etc/iptables.ipv4.nat" ?

Thanks.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Thu Oct 04, 2012 11:36 pm
by hunternet93
poing wrote:This does sound interesting and is exactly what I need for my embedded project, so, after a double backup of my precious installation ;) , I tried it, but it doesn't work :( .

Is the line:
"iptables-restore < /etc/iptables.ipv4.nat " correct, or should it be:
"iptables-restore > /etc/iptables.ipv4.nat" ?

Thanks.
The first line is correct. The "<" symbol send the contents of the iptables.ipv4.nat file to the iptables-restore program. Sorry it doesn't work. What is the problem, exactly?

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Fri Oct 05, 2012 6:54 am
by poing
I have the Edimax nano stick, which worked great with the setup through the icon in the latest Raspian distro. I then worked through your tutorial, where there were two problems.

The first was that I was not allowed to complete one step using sudo, I had to do "sudo bash #" before I went through. Sadly I didn't record the exact step (but I can repeat the process after replacing the backup), I think it was "iptables-save > /etc/iptables.ipv4.nat".

the next problem was that I had to change, I think, "/etc/udhcpd.conf" or "/etc/hostapd/hostapd.conf" where a value had to be changed from "no" to "yes" to allow changes.

After 'firing up' nothing happened. I then restarted the Pi but still no go. Before the Edimax was blinking all the time with a small blue led, but now it's just dead. I guess I'll retry and carefully note the steps above as I really would like this to work. Sadly I'm a newbie, so I have no clue myself :D

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Fri Oct 05, 2012 11:33 am
by hunternet93
poing wrote:I have the Edimax nano stick, which worked great with the setup through the icon in the latest Raspian distro. I then worked through your tutorial, where there were two problems.

The first was that I was not allowed to complete one step using sudo, I had to do "sudo bash #" before I went through. Sadly I didn't record the exact step (but I can repeat the process after replacing the backup), I think it was "iptables-save > /etc/iptables.ipv4.nat".

the next problem was that I had to change, I think, "/etc/udhcpd.conf" or "/etc/hostapd/hostapd.conf" where a value had to be changed from "no" to "yes" to allow changes.

After 'firing up' nothing happened. I then restarted the Pi but still no go. Before the Edimax was blinking all the time with a small blue led, but now it's just dead. I guess I'll retry and carefully note the steps above as I really would like this to work. Sadly I'm a newbie, so I have no clue myself :D
Hmm. Try running the following commands and posting the results:

Code: Select all

sudo service hostapd status
sudo service udhcpd status
sudo ifconfig
sudo iwconfig
The first two commands check if HostAPD and uDHPD are running, the second two give some information on your network interfaces. It's very possible I missed a step when writing the instructions, I wrote them during a break a work and haven't had time to verify them on a Pi yet.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Fri Oct 05, 2012 1:56 pm
by hunternet93
I found an error in my tutorial. The line

Code: Select all

 iptables-restore < /etc/iptables.ipv4.nat
should be

Code: Select all

 up iptables-restore < /etc/iptables.ipv4.nat
I'll edit my tutorial to fix this.
I'm also having an issue with getting the thing to work on boot, I'll post when I get that worked out.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Fri Oct 05, 2012 2:03 pm
by hunternet93
If you have a network management program running (i.e. NetworkManager, wicd) then you should disable or remove it. I had NetworkManger installed and it tried to take control of wlan0, preventing me from connecting.

EDIT: Also, my iptables rules seem to block traffic of any kind. Oops. I'll fix it ASAP. Also, I can't edit my first post for some reason, I reported it so hopefully an admin will take pity on me. :D

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Fri Oct 05, 2012 2:57 pm
by poing
OK, what I'll do is put the backup back and wait for the update of your tutorial (no reason for haste or anything) and then I'll try again step by step.

Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple

Posted: Sat Oct 06, 2012 7:24 pm
by poing
After looking into this a bit further it appears my Edimax is not compatible with hostapd so I decided to order a Ralink RT5370 as is described here:
http://sirlagz.net/2012/08/09/how-to-us ... er-part-1/

Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple

Posted: Sun Oct 07, 2012 3:52 am
by hunternet93
I found my issue -- NetworkManager was taking control of wlan0 and eth0. I thought I had disabled it, but it was still running. I'll rewrite my tutorial when I get a chance. According to http://linuxwireless.org/en/users/Documentation/hostapd, the mac80211 drivers now used by most wireless cards moves master mode to userspace, so most cards should work in master mode. I've only tested a couple Ralink-based adapters, but I think most cards should work ok.

Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple

Posted: Sun Oct 07, 2012 9:16 pm
by e21c
Hello,
I would like to make web page, which will be working as splash (welcome) screen for clients who connect to my AP.
Now, I have lighttpd server + webpy (fastCGI) working on RPi. I connect wifi dongle (TL-WN722) to hub and run hostap + dhcp.

But I don't know how to configure net traffic redirecting.

Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple

Posted: Mon Oct 08, 2012 11:56 pm
by hunternet93
I've edited the tutorial and sent it to scep, he offered to edit the post for me since I can't edit it for some reason. I believe I've worked the bugs out, I had typed a command backwards which prevented hostapd and udhcpd from starting at boot.

Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple

Posted: Tue Oct 09, 2012 12:01 am
by hunternet93
e21c wrote:Hello,
I would like to make web page, which will be working as splash (welcome) screen for clients who connect to my AP.
Now, I have lighttpd server + webpy (fastCGI) working on RPi. I connect wifi dongle (TL-WN722) to hub and run hostap + dhcp.

But I don't know how to configure net traffic redirecting.
CoovaChilli (http://coova.org/CoovaChilli) looks like it will do what you want. I've never used it but it appears to be what you're looking for.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Thu Oct 11, 2012 6:10 pm
by e21c
I solved my problem with command :
sudo iptables -t nat -A PREROUTING -d 0/0 -p tcp –dport 80 -j DNAT –to MyServerIP:80
Thanks hunternet93 for your attempt to solve it.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Thu Oct 11, 2012 6:22 pm
by hunternet93
e21c wrote:I solved my problem with command :
sudo iptables -t nat -A PREROUTING -d 0/0 -p tcp –dport 80 -j DNAT –to MyServerIP:80
Thanks hunternet93 for your attempt to solve it.
I'm glad you found a solution. That's a great solution, iptables seems to be able to do anything. I may use that in the future.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Tue Nov 06, 2012 4:09 am
by Wolfram23
Hey guys. I made a thread and was pointed here to solve my issue. Basically, I am hooking my Pi up in my car and need to access it to see if it is actually working (communicating over OBD 2 with ECU).

I've got an iPhone and/or iPad to ssh to the Pi already but that's over my home network. Following the instructions did not work for me - my guess being that I'm already connected to a network and using ssh to do all this.

Is there anything I need to do differently to get this working? I can connect to a monitor if required for setup, as long as I'm able to remote into it after without a router (car is in a parkade so no wifi access)

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Tue Nov 06, 2012 12:15 pm
by hunternet93
If you have a laptop available, you can connect via Ethernet. You might be able to connect and complete the steps through WiFi if you skip the commands

Code: Select all

 sudo service hostapd start
sudo service udhcpd start 
and then restart the Pi. After you reboot, the Pi should start broadcasting as a hotspot. If it doesn't you'll need to connect with Ethernet or connect to a monitor to see what went wrong.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Tue Nov 06, 2012 3:20 pm
by poing
hunternet93 wrote: Hmm. Try running the following commands and posting the results:

Code: Select all

sudo service hostapd status
sudo service udhcpd status
sudo ifconfig
sudo iwconfig
The first two commands check if HostAPD and uDHPD are running, the second two give some information on your network interfaces. It's very possible I missed a step when writing the instructions, I wrote them during a break a work and haven't had time to verify them on a Pi yet.
I have two Ralink dongles now. I tried the sirlagz tutorial and had initial success where I could log into my Pi with my phone and see the webpage on the Pi (that's what I need), but then MySQL went corrupt. So I decided to install everything from scratch but now it won't work anymore :( After five tries I'm a bit disparate.

Anyway I tried this tutorial again. What I had to do was change

Code: Select all

DEAMON_CONF=""
into

Code: Select all

DEAMON_CONF="/etc/hostapd/hostapd.conf"
in the file /etc/init.d/hostapd otherwise hostapd wouldn't start.

Next I had to remove the line

Code: Select all

auth_algs=0
from /etc/hostapd/hostapd.conf for it was not allowed to have arguments.

That's where I am, I can see the Access Point but it refuses to give me an IP address, which is the same status I can reach with the sirlagz tutorial (after likewise editing as above, only then I need to change a "group" line in /etc/hostapd/hostapd.conf)

Here's the output from the requested commands:

Code: Select all

[email protected] ~ $ sudo service hostapd status
[ ok ] hostapd is running.
[email protected] ~ $ sudo service udhcpd status
Usage: /etc/init.d/udhcpd {start|stop|restart|force-reload}
[email protected] ~ $ sudo ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:13:26:2e  
          inet addr:192.168.1.123  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1302 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1086 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1140902 (1.0 MiB)  TX bytes:175176 (171.0 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

mon.wlan0 Link encap:UNSPEC  HWaddr 00-0F-54-0A-AC-E2-00-00-00-00-00-00-00-00-00-00  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:130 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:12684 (12.3 KiB)  TX bytes:0 (0.0 B)

wlan0     Link encap:Ethernet  HWaddr 00:0f:54:0a:ac:e2  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:18 errors:0 dropped:0 overruns:0 frame:0
          TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:6196 (6.0 KiB)  TX bytes:6520 (6.3 KiB)

[email protected] ~ $ sudo iwconfig
lo        no wireless extensions.

wlan0     IEEE 802.11bgn  Mode:Master  Frequency:2.427 GHz  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          
eth0      no wireless extensions.

mon.wlan0  IEEE 802.11bgn  Mode:Monitor  Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Power Management:on
          
[email protected] ~ $ 
Hope someone can help.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot

Posted: Tue Nov 06, 2012 3:43 pm
by Sonny_Jim

Code: Select all

[email protected] ~ $ sudo service udhcpd status
Usage: /etc/init.d/udhcpd {start|stop|restart|force-reload}
It looks to me udhcpd isn't running, hence why no IP addresses are being given out. Try running udhcpd from the command line to make sure the configuration file is correct.

EDIT: Or just use static addresses if you can't get udhcpd to work. Or use dnsmasq as a dhcpd server.