-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
[Tutorial] Using the RasPi as a WiFi hostspot (8 Nov 12)
The tutorial has now been moved to: http://elinux.org/RPI-Wireless-Hotspot
Last edited by hunternet93 on Sun Feb 09, 2014 8:54 pm, edited 2 times in total.
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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.
What wireless adapter are you using?
Also want to try out with http://www.raspberrypi.org/phpBB3/viewt ... =41&t=3059 A DIY PoE.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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".
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".
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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.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.
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
The guy in this http://sirlagz.net/2012/08/09/how-to-us ... er-part-1/ tutorial uses to determine if the dongle has Acces Point capabilities.
Code: Select all
iw list
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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
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.
http://www.raspians.com - always looking for content feel free to ask to have it posted. Or sign up and message me to become a contributor to the site. Raspians is not affiliated with the Raspberry Pi Foundation. (RPi's + You = Raspians)
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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.


Is the line:
"iptables-restore < /etc/iptables.ipv4.nat " correct, or should it be:
"iptables-restore > /etc/iptables.ipv4.nat" ?
Thanks.
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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?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.
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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
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

-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
Hmm. Try running the following commands and posting the results: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
Code: Select all
sudo service hostapd status
sudo service udhcpd status
sudo ifconfig
sudo iwconfig
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
I found an error in my tutorial. The line
should be
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.
Code: Select all
iptables-restore < /etc/iptables.ipv4.nat
Code: Select all
up iptables-restore < /etc/iptables.ipv4.nat
I'm also having an issue with getting the thing to work on boot, I'll post when I get that worked out.
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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.
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.

Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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
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/
http://sirlagz.net/2012/08/09/how-to-us ... er-part-1/
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple
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
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.
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.
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple
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.
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the RaspPi as a WiFi hostspot [incomple
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.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.
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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.
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.
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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.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.
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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)
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)
-
- Posts: 336
- Joined: Mon Dec 12, 2011 4:34 pm
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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
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.
Code: Select all
sudo service hostapd start
sudo service udhcpd start
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
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 anymorehunternet93 wrote: Hmm. Try running the following commands and posting the results: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.Code: Select all
sudo service hostapd status sudo service udhcpd status sudo ifconfig sudo iwconfig

Anyway I tried this tutorial again. What I had to do was change
Code: Select all
DEAMON_CONF=""
Code: Select all
DEAMON_CONF="/etc/hostapd/hostapd.conf"
Next I had to remove the line
Code: Select all
auth_algs=0
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
pi@raspberrypi ~ $ sudo service hostapd status
[ ok ] hostapd is running.
pi@raspberrypi ~ $ sudo service udhcpd status
Usage: /etc/init.d/udhcpd {start|stop|restart|force-reload}
pi@raspberrypi ~ $ 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)
pi@raspberrypi ~ $ 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
pi@raspberrypi ~ $
Re: [Tutorial] Using the Raspberry Pi as a WiFi hostspot
Code: Select all
pi@raspberrypi ~ $ sudo service udhcpd status
Usage: /etc/init.d/udhcpd {start|stop|restart|force-reload}
EDIT: Or just use static addresses if you can't get udhcpd to work. Or use dnsmasq as a dhcpd server.