I got an email earlier in the week from some students at SoonChunHyang University, about 100km from Seoul, Korea. They are working on a project where they are using Raspberry Pi’s as a web server, but also wanted to be able to control the Pi’s via their smart phones and desktops. They ran into issues because they were using the (previously) unsupported WiFi Adapter (RTL8188CUS chipset) that I wrote about in this Raspberry Pi WiFi Hotspot post.
A computer science graduate myself, I offered to write a tutorial for them to help them out. This entire tutorial might not be relevant for everyone, but I cover a lot of issues that people struggle with.
- -Setting up a DHCP Server
- -Setting up a Wireless Access Point
- -Setting up an rPi as a Router
- -Enabling IP Forwarding
I’ll begin with a fresh image of the Raspbian and just a regular ethernet cable to configure it. I’ve always recommended Raspbian because it is an optimized version of Debian built specifically for Raspberry Pi’s. The last stable downloads can be found here.
To flash your SD Card, you will need to unzip the image and write it your SD card using Win32DiskImager. This tool can also be used to after our initial setup to create an image of our finalized implementation(very useful as a backup).
After the image is flashed, you can boot your device. At this point you can use your HDMI Cable/Mouse/Keyboard for your initial configuration, or you can use an SSH Client like Putty to connect. The default hostname, login, and password are as follows:
host:raspberrypi
Username: pi
Password: raspberry
For this tutorial, I will be using putty. On first boot, you will be prompted with a configuration tool called Raspi-Config. If the raspi-config doesnt load automatically, just enter the following command from the shell to get started.
sudo raspi-config |
The settings I recommend you update are
update
expand_rootfs
change_pass
change_timezone
memory_split
The usual distribution images are 2 GB. When you copy the image to a larger SD card you have a portion of that card unused. expand_rootfs expands the initial image to expand to fill the rest of the SD card, giving you more space. By default, 64mb is reserved for the Graphical UI. Since we plan on using this as a web server, I reduce this to 32mb with the memory_split command.
After you finish your changes to the raspi-config, you should reboot your pi using the following command:
sudo shutdown -r now |
At this point we have a fully functional linux server, but we still need to install apache and get the hotspot/routing functions working. The first part is pretty easy. Run the following commands from the shell to install Apache.
sudo apt-get update sudo apt-get install apache2 |
The location of the Apache configuration file is
/etc/apache2/apache2.conf
After this is completed, give it a try! Navigate to the IP or Hostname of your Rasberry Pi in your browser, and you should see the Apache Splash “It works!” Screen.
I believe this is what the students at SoonChunHyang already have working. But, they want to be able to access this web server over a WiFi Hotspot running on the same Raspberry Pi. In order to do this, we need to install hostapd.
sudo apt-get install hostapd |
The following steps are only for people who have WiFi adapters with the RTL8188CUS Chipset, if you don’t, please skip ahead to the section titled configuring Hostapd.
I believe the whole crux of their problem so far is that it is the apt hosted copy of hostapd is not compatible with the RTL8188CUS chipset they are using. But, thanks to the Edimax team, I’ve got a replacement hostapd binary to resolve this issue. I don’t think they will be able to get this working without it.
To download and replace the installed binary version of hostapd we just installed, they need to issue the following commands:
wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip unzip hostapd.zip sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak sudo mv hostapd /usr/sbin/hostapd.edimax sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd sudo chown root.root /usr/sbin/hostapd sudo chmod 755 /usr/sbin/hostapd |
Configuring Hostapd
Now that we’ve updated the binary copy of hostapd, we need to configure it. To do so, create the following file
sudo nano /etc/hostapd/hostapd.conf |
with the following contents:
interface=wlan0
driver=rtl871xdrv
ssid=DaveConroyPi
channel=6
wmm_enabled=1
wpa=1
wpa_passphrase=0000000000
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
In previous tutorials, I have used bridge-utils here to help bridge the connection between the interfaces wlan0 and eth0, but in this case we want the wireless card and rPi to handle the routing and dhcp. So , we may be able to connect to the access point, but we won’t get an IP just yet. To do that, we need to define a subnet for our wireless card.
sudo nano /etc/network/interfaces |
and add the following 3 lines
iface wlan0 inet static
address 10.10.0.1
netmask 255.255.255.0
Then we have to enable dhcp on the pi for this network so that any devices that connect can get an IP addresss
sudo apt-get install isc-dhcp-server |
sudo nano /etc/dhcp/dhcpd.conf |
and make sure you have the following contents:
authoritative; #be careful with this setting
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
#for the wireless network on wlan0
subnet 10.10.0.0 netmask 255.255.255.0 {
range 10.10.0.25 10.10.0.50;
option domain-name-servers 8.8.8.8, 8.8.4.4;
option routers 10.10.0.1;
interface wlan0;
}
At this point we should reboot to test HostAPD and DHCP.
sudo reboot |
After the rPi comes back up, start hostapd in the background, then reboot the dhcp server
sudo hostapd -B /etc/hostapd/hostapd.conf sudo /etc/init.d/isc-dhcp-server restart |
At this point you should be able to join the wireless network, get an IP, and also hit the local apache web server. If it connects, we will want to start this wireless access point on boot with the following commands
sudo nano /etc/default/hostapd |
and uncommenting and updating the following line
DAEMON_CONF="/etc/hostapd/hostapd.conf"
So, if you have followed these steps correctly, you can now provide DHCP servers to any clients, and also allow serve those clients your Apache web pages.
There is only one problem remaining. The clients who have connected to your access point can not get further than your Raspberry Pi, therefore have no internet access.
To solve this, we need to enable IP forwarding on the rPi. You can not reboot at this point forward or all future changes will be lost. To save time, we are going to run the final commands as root.
sudo su echo 1 > /proc/sys/net/ipv4/ip_forward |
Then, update /etc/sysctl.conf and uncomment this line
nano /etc/sysctl.conf |
net.ipv4.ip_forward=1
Save the file.
The final step is to insert an iptables rule to allow NAT. (eth0 being the interface which is connected to the internet)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
We also need to save these IP Table settings so they are enabled every time you boot the rPi. To save these settings to a file, use the following command.
iptables-save > /etc/iptables.up.rules |
To load them at boot, we need to create a script in /etc/network/if-pre-up.d/
nano /etc/network/if-pre-up.d/iptables |
with the following contents:
#!/bin/sh
#This script restores iptables upon rebootiptables-restore < /etc/iptables.up.rules exit 0
Then, verify the permissions so that it will start on boot.
chown root:root /etc/network/if-pre-up.d/iptables chmod +x /etc/network/if-pre-up.d/iptables chmod 755 /etc/network/if-pre-up.d/iptables |
And we are done! When you reboot your Raspberry Pi should be working as an Access Point, a Web Server, a DHCP Server, and an Internet Ready Router!
hey~! hi dave. i’m students at SCH Univ. before i send you e-mail guy.
I’m really stuck few days in RTL8188CUS chipset issue.
but this post save me now.!!! this is really truly works!!!!!!!
I worry about because of this. but now relieved.:)
i’m really appreciated make this post for me.
Thank you very much for your kindness again Dave.!
Thanks for the great tutorial. It works like a charm. But shouldn’t the RaspberryPi have a static ip of 10.10.3.142 ? 😉
3.1.41.59
3.14.159.27
i followed the above step however, i cant get internet access on the pcs connected. Here’s my setup and my requirements. hope you can shed some light on this
I setup a debian(Wheezy) system that will server as a dhcp server, webserver, and a router
-DHCP server works fine
-Webserver works fine
-I can ping external website
-I can ping my eth1 from the laptop connected to eth0
Laptop with 2 NIC
Eth1(DHCP)- Connected to my company’s internet
Eth0(Static)-will be used for Webserver and DHCP
Connected to desktop switch with 1 laptop connected (wired)
address 192.168.98.76
netmask 255.255.255.0
#route
Default 10.10.10.254 0.0.0.0 UG 0 0 0 eth1
10.10.10.0 * 255.255.255.0 eth1
192.168.98.0 * 255.255.255.0 eth0
Need your help please..
Thanks
Jorge
how do you connect to the access point on the rpi after you’re done with the tutorial?
thanks dave for your great work!!!
I am almost there but as soon as I launch
sudo hostapd -B /etc/hostapd/hostapd.conf
I get the error:
Line 2: invalid/unknown driver ‘rtl871xdrv ‘
my wifi dongle is a DLINK DWA 140 and work well with my raspberry . I mean I can connect the rasberry to my hom wifi network smoothly
thanks for your help
pierandrea
I have seen two of your tutorials, both well done, thank you so much.
The only issue I have is, every time I reboot I need to enter sudo /etc/init.d/isc-dhcp-server restart If I don’t then I will see the access point but won’t get an IP number.
After that everything rocks, any ideas on how to make this automatic?
Hi,
Sorry for the big log post. But i’ve got everything working, but for some reason i cannot get an ipad or android phone to connect. It works fine with my laptop (still need to test using another comp). Im thinking its a dhcp issue, see log:
Aug 22 07:57:28 raspberrypi dhcpd: DHCPDISCOVER from a0:88:b4:32:94:18 via wlan0
Aug 22 07:57:28 raspberrypi ifplugd(wlan0)[1670]: Link beat detected.
Aug 22 07:57:28 raspberrypi ifplugd(wlan0)[1670]: Executing '/etc/ifplugd/ifplugd.action wlan0 up'.
Aug 22 07:57:29 raspberrypi dhcpd: DHCPOFFER on 10.10.0.26 to a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 07:57:29 raspberrypi ifplugd(wlan0)[1670]: Program executed successfully.
Aug 22 07:57:29 raspberrypi dhcpd: Wrote 1 leases to leases file.
Aug 22 07:57:29 raspberrypi dhcpd: DHCPREQUEST for 10.10.0.26 from a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 07:57:29 raspberrypi dhcpd: DHCPACK on 10.10.0.26 to a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 07:57:30 raspberrypi ntpd[2100]: Listen normally on 3 wlan0 10.10.0.1 UDP 123
Aug 22 07:57:30 raspberrypi ntpd[2100]: peers refreshed
Aug 22 07:58:53 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 07:58:53 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 07:58:57 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 07:58:57 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:00:09 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:00:09 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:00:12 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:00:12 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:00:33 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: associated
Aug 22 08:00:33 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f RADIUS: starting accounting session 52154F4B-00000001
Aug 22 08:00:33 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: pairwise key handshake completed (WPA)
Aug 22 08:00:33 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: group key handshake completed (WPA)
Aug 22 08:01:22 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:01:22 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:01:25 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:01:25 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:01:33 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: disassociated
Aug 22 08:01:34 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: associated
Aug 22 08:01:34 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f RADIUS: starting accounting session 52154F4B-00000002
Aug 22 08:01:34 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: pairwise key handshake completed (WPA)
Aug 22 08:01:34 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: group key handshake completed (WPA)
Aug 22 08:01:51 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: disassociated
Aug 22 08:02:29 raspberrypi dhcpd: DHCPREQUEST for 10.10.0.26 from a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 08:02:29 raspberrypi dhcpd: DHCPACK on 10.10.0.26 to a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 08:03:11 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:03:11 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:03:14 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:03:14 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:03:16 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: associated
Aug 22 08:03:16 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f RADIUS: starting accounting session 52154F4B-00000003
Aug 22 08:03:16 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: pairwise key handshake completed (WPA)
Aug 22 08:03:16 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: group key handshake completed (WPA)
Aug 22 08:03:28 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: disassociated
Aug 22 08:05:29 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:05:29 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:05:32 raspberrypi dhcpd: DHCPINFORM from 10.10.0.26 via wlan0
Aug 22 08:05:32 raspberrypi dhcpd: DHCPACK to 10.10.0.26 (a0:88:b4:32:94:18) via wlan0
Aug 22 08:06:44 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: associated
Aug 22 08:06:45 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f RADIUS: starting accounting session 52154F4B-00000004
Aug 22 08:06:45 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: pairwise key handshake completed (WPA)
Aug 22 08:06:45 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: group key handshake completed (WPA)
Aug 22 08:07:04 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: disassociated
Aug 22 08:07:20 raspberrypi hostapd: wlan0: STA a0:88:b4:32:94:18 WPA: group key handshake completed (WPA)
Aug 22 08:07:29 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f IEEE 802.11: associated
Aug 22 08:07:29 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f RADIUS: starting accounting session 52154F4B-00000005
Aug 22 08:07:29 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: pairwise key handshake completed (WPA)
Aug 22 08:07:29 raspberrypi hostapd: wlan0: STA 70:de:e2:7f:db:0f WPA: group key handshake completed (WPA)
Aug 22 08:07:29 raspberrypi dhcpd: DHCPREQUEST for 10.10.0.26 from a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 08:07:29 raspberrypi dhcpd: DHCPACK on 10.10.0.26 to a0:88:b4:32:94:18 (Stewarts-Laptop) via wlan0
Aug 22 08:07:30 raspberrypi dhcpd: DHCPDISCOVER from 70:de:e2:7f:db:0f via wlan0
Aug 22 08:07:31 raspberrypi dhcpd: DHCPOFFER on 10.10.0.27 to 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:32 raspberrypi dhcpd: DHCPDISCOVER from 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:32 raspberrypi dhcpd: DHCPOFFER on 10.10.0.27 to 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:36 raspberrypi dhcpd: DHCPDISCOVER from 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:36 raspberrypi dhcpd: DHCPOFFER on 10.10.0.27 to 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:44 raspberrypi dhcpd: DHCPDISCOVER from 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:44 raspberrypi dhcpd: DHCPOFFER on 10.10.0.27 to 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:53 raspberrypi dhcpd: DHCPDISCOVER from 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:07:53 raspberrypi dhcpd: DHCPOFFER on 10.10.0.27 to 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:08:01 raspberrypi dhcpd: DHCPDISCOVER from 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Aug 22 08:08:01 raspberrypi dhcpd: DHCPOFFER on 10.10.0.27 to 70:de:e2:7f:db:0f (Lauras-iPad) via wlan0
Just noticed that the time is out by 1 hour?? will try changing it to see of that has an effect.
Hope you can help.
it comes to life when i run: sudo /etc/init.d/isc-dhcp-server restart
sorted it!
in /etc/rc.local add this before exit 0:
sudo service isc-dhcp-server restart
Thanks for this tutorial, its the only one that has worked! 🙂
Glad it worked! I might trim down that error log!
I actually have the exact same problem as you Stew. I can connect from my laptop/PCs without issue but as soon as I try to connect from any of my iDevice’s it just spins without ever getting an IP. I tried your solution suggested here but it still doesn’t work, I have to manually run:
sudo /etc/init.d/isc-dhcp-server restart
before I can connect. Anyone else still having this problem?
PS Dave these Tutorials are amazingly helpful.
Adam, you could add this to rc.local and itd work every time…
That’s actually what I ended up doing. Seems to do the trick. Still can’t get it to work from boot every time, but I’d say 80% of the time it works. Stable enough for now.
Thanks
Thanks for the great tutorials. I tried this 6 months ago without ever getting it to work. I completed the previous wifi access point tutorial w/ no problem. On this tutorial, so far, wireless is working, dhcp is working. My android phone connects and is assigned 10.10.0.25, but I can’t ping 10.10.0.1 from my phone. Can you give me an idea of where to look for the problem. I am a networking noob, and don’t know how to debug. ( I can ping and see the website from my laptop across the wired ethernet on my local 192.168.0.5 static IP)
For those of you that had network issues connecting, I had to comment out two lines in my network config and I got this to work:
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
#iface wlan0 inet manual
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
iface wlan0 inet static
address 10.10.0.1
netmask 255.255.255.0
The wifi was installed by default when I ran my Pi for the first time, hence the line “iface wlan0 inet manual” was conflicting with the addition
Thank you for that tip Paul – I had the same issue, and that fixed it.
Texy
Ok, basically this tutorial is different to others – it lets me finally to run the server. But I have few more problems. Other PCs connect to pi successfully, but they dont get their ip addresses and android device won’t connect at all (error code 8). Any suggestions where to look at? Thanks!
Hello,
I am today running into the same issue. Did you get a solution ?
Hi David, I followed your tutorials so far and I was able to make my Rpi work as intended…
I wanted to redirect all trafic to the Rpi local server to serve some files to the users and after reading this page:
I tried:
/sbin/iptables -A PREROUTING -s 10.10.0.20/255.255.255.0 -p tcp -j DNAT --to-destination 10.10.0.1
But i’m getting errors… I’m a total NOOB so any help is really appreciated.
(I dont want user’s to actually be able to use the network while connected to the Rpi… I might not even have a network connected).
What I’m trying to accomplish is a standalone box where people can connect and see some local files.
Thanks
Forgot the URL to the page I was using to accomplish the IPTABLES configuration:
http://www.ex-parrot.com/pete/upside-down-ternet.html
Hey Moises, did you ever get this sorted? I’m trying to accomplish the exact same thing
Hi
Nice tutorial. Works fine.
I use the RasPi as Router and Webserver without P Forwarding.
When I use the settings like you, then it works in WLAN Mode “b”.
When I add the following line “hw_mode=g” and make a restart, then I can connect with the RasPi, but I can’t load a website.
Have I forgot something for use the WLAN-Mode “g”?
Hello, thnx for this tutorial.
I’m going to try Raspberry Pi as a home router and torrent station.
Is Pi CPU and RAM enough for routing packets? Doesn’t it reduces speed of downloading files through it?
What I’m going to install on Raspberry Pi B:
wifi router services
iptables
samba for sharing connnected to USB HDD
i2p sservice
rtorrent
I would like to set my Rpi to get wifi from one dongle and send internet to another dongle.
I changed the eth0 in your tutorial for wlan1, that is my internet source.
I can connect to the AP, but I don’t get connected to the web, to make this via wifi to wifi is different from eth0 to wlan0?
Hi Carlos,
I have exactly the same problem, did you already found the solution?
Cheers, Hein
Superb, what a blog it is! This web sit gives helpful information to us, keep it up.
Hello,
Can you help me to do the other way around?
I want to connect rpi to internet by Wi-fi and on the eth0 to connect a CCTV camera.
I want to see images from the camera from another network.
Camera connected to eth0 , external network connected to wlan0.
Thank you
Hi,
thank you for this great tutorial. I have a question in regards to the ability of RP to work as splash screen for a café, so the customer when he connect to the wireless a splash screen will pop up and asking to like the place to the facebook. is this doable with RP?
Thanks again
Hi Dave
What a great post, really helpful 🙂
I have a little special need; I want to answer all request on port 80 with my apache; regardless if the AC user wants to access google.com or other website. I am thinking I can install a DNS server for this and resolve all hosts to the ip of my apache. All other traffic I want to go though like the example you have done.
Do you have som pointers on that; how do I reroute all traffic except port 80 ?
Hi Robert,
what’s your exact goal for implementing this? Some kind of authorization first time user logs on like they use in the hotels where you have to provide a valid password (usually changed on a daily basis)?
If so my idea is definitely not optimal however what about having it all handled on your rPi’s webserver with a script allowing access to the destination site if authorized?
Something like CGI binary or PHP script what will access the site (e.g. http://www.google.com from the HTTP_HOST header) and issue a request there for you? Of course, you’d need to set the alternative hosts file to be used for the dhcp clients (computers connected to your router).
Michal
Dear Dave
I am trying to use the Pi to setup a small web server for local need (internet not needed). Your tutorial was very helpful, but still I am getting stuck somewhere.
Thank to you, Wifi is broadcasting ok (I am using Edimax dongle !). But it seems I cannot get an IP address and therefore connect to the network. For info, I am trying to connect with Mac & iDevices !
Any idea ?
PS: your page is now in my favorite
Hi Dave,
Thank you very much for your tutorial.
Spent 4 nights re-installing the os and changing configurations until I found your post. It’s all working now.
Could you please expend this tutorial to include the use of dnsmasq?
Upon installing dnsmasq, the wlan0 static ip would disappear on boot.
And the traffic goes right through without resolving to my /etc/hosts entires.
Thanks,
Hey, i tried this tutorial and it worked great! Worked because now every time i type “sudo hostapd -B /etc/hostapd/hostapd.conf” i get this output:
Configuration file: /etc/hostapd/hostapd.conf
drv->ifindex=3
l2_sock_recv==l2_sock_xmit=0x0x12fb638
+rtl871x_sta_deauth_ops, ff:ff:ff:ff:ff:ff is deauth, reason=2
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
rtl871x_set_key_ops
Using interface wlan0 with hwaddr 80:1f:02:9a:b6:39 and ssid 'Heli_Cam'
rtl871x_set_wps_assoc_resp_ie
rtl871x_set_wps_beacon_ie
rtl871x_set_wps_probe_resp_ie
rtl871x_set_key_ops
rtl871x_set_beacon_ops
rtl871x_set_hidden_ssid_ops
ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
Any Ideas ?
Hi,
Great tutorial really. I have the some warnig (All work fine). It is possible to know the fix that you have made at hostapd? I am very interesting to this.
Thank you for your great job!
I got everything working correctly, and can get to the Internet through the AP on my Pi.
However, while at work, Outlook exchange server says Offline. Also, I cannot connect to a VPN. Is there some additional step I need to tunnel traffic correctly to get Outlook Exchange and VPN working?
In your tutorial is NAT routing just taking care of web traffic? Is that why Exchange thinks I’m offline? I also can’t see other computers on my network.
Thanks for tutorial and any insight you can give me on this issue.
Thnx for the tutorial. I connected my laptop with pi but when I tried to enter pi’s ip address:8081 for live video streaming it says page not found. Please help
also when I try to see wlan0 ip in ifconfig.it displays no ip.
Please help thanks
Hi Dave,
This is working awesome except for one thing. If the pi is disconnected from ethernet, it doesn’t create the wifi network and I can’t connect to it. I’m trying to run it so it broadcasts a network while disconnected from the internet, so I can control some robotics remotely. Is there any way to do this?
Thanks–
I’m looking for the same thing, basically a way to control the raspberry’s pins but without any ethernet or wifi connection around you ( except maybe the one you will create with the pi to connect to it ) just the raspberry and your computer/smartphone . Does anyone have an idea to help ?
Thanks a lot
Excellent tutorial. I notice that it was written a year ago now and would have thought that the mods made to hostapd by Edimax would have been rolled into the OS distribution by now.
Is this modification still needed?
Amazing Tutorial and I’m really happy we get the freedom to make our own customized Pi.
In my own experiences…
So, I figured out why wlan0 doesn’t get an IP address when hostapd starts up.
ifplugd messes about with the interfaces when they go up and down, so the simplest solution is to disable ifplugd for wlan0 !
in /etc/default/ifplugd, the default configuration is this
INTERFACES=”auto”
HOTPLUG_INTERFACES=”all”
ARGS=”-q -f -u0 -d10 -w -I”
SUSPEND_ACTION=”stop”
Simply changing it to this
INTERFACES=”eth0″
HOTPLUG_INTERFACES=”eth0″
ARGS=”-q -f -u0 -d10 -w -I”
SUSPEND_ACTION=”stop”
will ensure that wlan0 will not lose it’s static IP address that’s configured in /etc/network/interfaces when wlan0 goes up.
—
But I do have a problem, I need to make a hidden network name, however, for some reason hostapd and the key ‘ignore_broadcast_ssid’ doesn’t work when it is set to 1. It still broadcasts the network name for some reason. Help?
Thanks Again!
I have same problem.
Any solution found until now?
Thansk in advance
Great tutorial, Dave! Thanks for publishing this, it works a treat.
Hi Dave,
Thanks for this post! I’m looking to make a Raspberry Pi wifi router, and this tutorial covers all the bases.
I do have one question before I get started – Can you set up the Pi to auto-direct to the stored html page on (wireless) connection, without having to type in the IP address of the Pi in the browser?
I want to show users the page as soon as the connect to the hotspot, or open their browser after wirelessly connecting.
Please let me know if this is possible!
Thanks,
JP
Dave Conroy. You rock.
Hi Dave,
Thanks for the tutorial. Right now i’m trying to connect the RPI to a RFID reader, the reader is ready to connect to a wireless network using wpa psk. To be honest, i don’t know a thing about networks…. so, when I saw this tutorial I decide to try it. So far I can see the name of the network, but i cannot connect to it, it says incorrect password. There’s something that seems to be wrong when is booting, says
starting advanced IEEE 802.11 management : hostapdioctl [RTL_IOCTL_HOSTAPD]: Invalid argument
The goal of the project is to communicate wirelesly with the reader, but the reader uses serial comunication, by any chance do you know how to read this serial communication recieved by wifi?
Thank you very much for your time.
Cheers from Colombia!
Daniel
Hey Dave.. thanks for the awesome tut.. I have a question though for a project I am doing, You know when you log in to certain wifi networks the browser is automatically redirected to a log in page which restricts access to the internet resource. Can this be done with the rpi? or is that a feature that is independent of the router? Say for instance if I want to only allow internet access at a cost then it would come in handy right? Another question i have is can this dhcp server work the same with a nodejs based webapp/server. If I run a local nodejs server on the rpi that I want users to access, can this method work?
thanks for the awesome tut.. I have a question though for a project I am doing, You know when you log in to certain wifi networks the browser is automatically redirected to a log in page which restricts access to the internet resource. Can this be done with the rpi? or is that a feature that is independent of the router? Say for instance if I want to only allow internet access at a cost then it would come in handy right? Another question i have is can this dhcp server work the same with a nodejs based webapp/server. If I run a local nodejs server on the rpi that I want users to access, can this method work?
Hi is there any way of makeing it so people have to pay to use your internet like paypal
Yes just put phone nr on the server with prices and when they call you give them paypal email and when is transaction done send wifi pass ! 😉
At first, thanks for this great tutorial.
I’ve seen many people asking about automatically open page in browser when someone is connecting to the AP. I’ve been struggling with this by myself for a day now. Someone already got a good working solution? w
i have used dnsmasq to redirect all request on my AP to my apache default page. But this is only working for url with .com etc.
How can i make this work for unknown url. Just like a search word in the browser.
I am using the AP only for acces to my apache webserver on the RPI.
Many thanks for this awesome work! Got my pi finally working as intented! (standalone music player, controllable via wifi with squeezer) 😀
Hey Dave Thanks for you awesome guide! I have used it and it all works. But it seems that the edimax dongle goes to sleep after some time. I have tried to ad the file suggested in this thread
https://www.raspberrypi.org/forums/viewtopic.php?t=61665
but it did not help. I guess it is because when using the setup in your guide the raspberry never looks for that file name at start up. Could you give a hint of what to do?
Your tutorial was awesome, and so was the binary you supplemented for the rtl, I also ran into the same issues as above user James Park. Now I am rocking in rolling. Do you have a tutorial on dnsmasq for an immediate redirect to local website? Thank you for the awesomeness!!!
Any luck getting this to work with osmc?
I can connect to the AP but kodi doesn’t see my phone at all.
Like it’s not on the same network.
I want this for a car pc project I’m building.
thank you!
I have followed the instruction and can not get it to work correctly. I can connect but can not even ping the pi. I also can not connect to the internet. Any help would be great.
Hi, Thanks for article. I have tried to use two wireless instead the ethernet adapter. But when I connect second wireless adapter to raspberry in return error in starting DHCP and startup of system. Could you please help? how can I solve this problem?
For the error: ioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
Just do: sudo apt-get remove hostapd
and install it again. do not modify it anymore.
Change the hostapd driver by: driver=nl80211
I hope it solves your problem.
hello!I am curious about how to get your hostapd.zip file, because it didnot work when I input the cmd into my Rpi .
Hi:
i know it has been a while but i am running into a strange issue:
when i try:
sudo /etc/init.d/isc-dhcp-server restart
i get:
[….] Restarting isc-dhcp-server (via systemctl): isc-dhcp-server.serviceJob for isc-dhcp-server.service failed. See ‘systemctl status isc-dhcp-server.service’ and ‘journalctl -xn’ for details.
any ideas to help? thanks
Hi.
I’ve been using the default image of musicbox (modipy) on an RPi zero W.
I keep hitting brick walls..
I realise that I need this to not only have standard client access but also be directly accessible so that, when I’m out and about without a router, I can still access via my mobile direct.
I tried to setup as an AP and client, but some really random stuff was happening..
Also, I can’t seem to expand the file system successfully for some reason, it’s stuck at 2GB no matter what I do.
If I do expand it, it messes up the system.
Is there a way to expand to the full capacity of the card (32GB), still allow as a client for use at home and also act as an AP to serve the web application so that it can be accessed directly (rather than passing it to the internet, such as in this example).
I’ve looked around but can’t figure out which driver I should put in the config file, or what else I am doing wrong.
When it boots it first connects to my router, then disappears, shows up as an AP and then gets stuck in a loop (keeps disconnecting devices).