Créez votre propre borne Wi-Fi avec la Raspberry Pi

Create a Wi-Fi hotspot in less than 10 minutes with Pi Raspberry!

Mis à jour le 10 March 2018 - 31 Commentaires - , , , , ,

Have you ever needed to create a second Wi-Fi network in addition to your primary network? If you (or someone close to you) have a business (coffee, restaurant, hairdresser or doctor, in short, a place where people are likely to wait), it is likely that you have already had to provide internet access to your Customers, without wanting to give the password of your box. In the same way, you may have already wanted to create an internal network that is cut off from the Internet, for example to exchange files within a small company, and so on.

For all these situations, the simplest solution is to create what is called a hotspot, that is to say a kind of box that you can control and to which your users can connect to access the internet. In this tutorial, let’s see how we can use a raspberry pi to create our own homemade hotspot, in less than 10 minutes!

The hardware needed to create your hotspot

In order to create our own hotspot, we will need a little bit of hardware, but nothing complicated or too expensive, you will be able to get around for about 50 € to 60 €, and you can use all the equipment for other uses in parallel.

To achieve our hotspot, we will need the following:

As you can see, all these components are just the ones needed to operate a raspberry pi, and you will be able to use the raspberry pi in question for other things in parallel to its role as a hotspot.

Moreover, by tweaking a bit in the configurations, and if you add a second Wi-Fi interface on your raspberry pi, you can also transform your hotspot into a Wi-Fi repeater, in order to increase the range of your box!

Install hostapd and its interface to turn your raspberry pi into a Wi-Fi hotspot

Now that we have all the hardware we need, we will be able to switch to installing the various software needed to transform our raspberry pi to Wi-Fi.

The first step will be to install Raspbian (the lite version, preferably) on your raspberry pi. To do this, we will let you consult our tutorial explaining how to install Raspbian on raspberry pi from Windows, or from Linux.

Once you have installed Raspbian, the first thing to do is to plug your raspberry pi to your internet router using the Ethernet cable and then take control of your raspberry, either directly with a keyboard / screen, or through SSH , as explained in this tutorial.

Once done, we will make sure that the Wi-Fi connection of the raspberry remains available for the creation of the hotspot. For this purpose, we will simply create a copy of the configuration file allowing the connection to a box, in order to keep it aside, and modify the main file.
To do this, go to the terminal of the raspberry pi and run the following commands:

sudo cp /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf.sav
sudo cp /dev/null/etc/wpa_supplicant/wpa_supplicant.conf

Finally, edit in the file /etc/wpa_supplicant/wpa_supplicant.conf and add the following lines:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

Now that we are sure that the Wi-Fi interface is available, all we have to do now is install the various software to make the raspberry pi an access point.

In this tutorial, we will use the hostapd software, which will allow us to turn the raspberry pi into an access point. And to facilitate the installation and administration of this access point, we will also install a web interface that will allow us to control our hotspot, RaspAP (for more info, go to the Github page of the software, https://github.com/billz/raspap-webgui).

Capture d'écran de l'interface RaspAP

With RaspAP, you can manage your Wi-Fi hotspot with a web interface.

And the good news is that to do all this we will need to run only one command:

wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap

Once the command is launched, you only have to answer the few questions that will be asked, and the installation of all the components will be done by itself.

Connect to your Wi-Fi hotspot

When the installation is complete, your raspberry pi restarts, and you should see a “raspi-webgui” network in the list of accessible networks.

If, however, the network does not appear, find the IP of the raspberry pi, and connect to it via your web browser. You should arrive on the hotspot administration interface, the default password is shown on the github page of the software. Once connected, go to the “Configure Hotspot” section, and change the “Wireless Mode” field, this should solve the problem.

Once the network is visible, all you have to do is connect to it, the default password is ChangeMe.
You can change this password, network name, and many other things by connecting to the admin interface of your raspberry hotspot via your web browser, by default the address should be 10.3.141.1.

And if it still does not work?

For some time, we do not know why, but it seems that Internet access is no longer functional by default after installation. To solve this problem you only need to do the following two things.

As a first step, enable the transfer of IPv4 packets. To do this, edit the file /etc/sysctl.confand uncomment (ie remove it #at the beginning) the following line:

#net.ipv4.ip_forward=1

This done, we will modify iptables to define the output IP that will be indicated so that the servers know who to answer (well, from what I understand, if I’m wrong rectifications are welcome ). To do this, open the file /etc/rc.localand add the following line before the “exit 0” part:

iptables -t nat -A POSTROUTING -j MASQUERADE

Restart the pi and everything should now work as it should!

All you have to do is configure your hotspot to suit your needs!

We hope that this tutorial will have helped you, do not hesitate to consult our other tutorials, such as the one on the creation of a retro-gaming console with the Raspberry Pi, and if you need help, do not hesitate to ask for on the comments !

Share
Newsletter
Author:
Raspbian France
Join the Raspberry Pi community
A $35 computer, already sold at 10 millions copies
BUY THE NEW RASPBERRY PI 3
Related tutorials
Install Android on his Raspberry Pi Create a NAS with your Raspberry Pi and Samba How to Setup a VPN on Raspberry Pi How to install a web server on the Raspberry Pi (Apache + PHP + MySQL) Install WordPress on a Raspberry Pi (with Nginx).
31 Comments
  1. Savvy Jain says:

    Thank you so much

  2. Amir Moeen Rahmani says:

    Hi, this worked really nice, but there were 2 things I wanted to make clear
    1. Can I use my other wifi interface? I’m using RPi3 with additional wifi dongle, after I modified hotspot configurations, I still can’t use other wifi interface. How can I access to that one

    2. Is there anyway to start vpn/tor and use this wifi as “proxy-wifi” ?

    After 3 days of straight work on network files and many, MANY websites, your way actually got this thing work. that was really awesome.

    1. Hey, you should take a look at the github page of the project, you could probably find help.

  3. Matt B says:

    Hello,

    I have the hotspot all set up but it is not receiving or transferring any packets/data. The RPi 3B is connected to eth0 and is able to access the internet. When I connect to the hotspot through my iPhone it says there is no internet connection available. On the Hotspot Dashboard, in the Interface Statistics it shows that no data is being recieved or transfered. Is there a step I am missing where I have to connect the ethernet connection to the RaspAP module?
    Please get back to me at my email, mbellucc@villanova.edu

    1. We just add a new part to the tutorial to fix this specific problem.

  4. Carlos says:

    Hi , I was able to see the raspi-webgui network in the list of available networks but when I try to connect it fails. I use the default password stated in the instructions (ChangeMe) and it seems that the networks accepts the password but overall does not succeed in providing internet. It shows a strong signal but again, can’t connect successfully,

    Any help would be appreciated!

    1. Hey, we just fixed that problem in the last section of the article.

  5. Braden A says:

    I do know if this is a dumb question, however, I was wondering if after you have programmed the pi to be a WiFi hub, do you still need to have it hooked up via Ethernet to a router. Or, is it possible to take this with me to somewhere like the beach and have some WiFi? I would appreciate your response greatly, and I apologize for my poor grammar.

    1. Hey, no you cannot have a Wi-Fi access to internet without a router from your FAI. Though, you could steel connect to the Raspberry Pi Wireless Network, but it will not give you access to internet.

  6. Elix says:

    Hi! I’ve installed the hotspot. I can successfully connect to it and access web UI. But there is no Internet, even though Raspberry Pi has access to Internet via Ethernet (i checked via Chromium – it’s working fine)

    1. Hey, check that the hotspot is correctly set to use Ethernet as source for internet.

      1. Vlad says:

        Hi I can successfully connect to it and access web UI. But there is no Internet, even though Raspberry Pi has access to Internet via Ethernet. But If I want to set up use Ethernet as source for internet at Network preferences, I get : “Error saving /etc/dhcpcd.conf access denied”.

        1. The last section of this tutorial now fix this problem.

      2. Carlos says:

        I have the same problem, No internet access. I visited all the options in the configuration web page but I did not find “how to use Ethernet as source for internet”. Please, place some screen shots about how to do it.

        1. Last section of this tutorial should now fixed that problem.

  7. Mark says:

    Hi,

    I get “No wireless Interfaces found” on the RPi after I have done this, I followed this step but still no luck:

    If, however, the network does not appear, find the IP of the raspberry pi, and connect to it via your web browser. You should arrive on the hotspot administration interface, the default password is shown on the github page of the software. Once connected, go to the “Configure Hotspot” section, and change the “Wireless Mode” field, this should solve the problem.

    I can see the raspi-webgui network from my phone but cannot connect with the ChangeMe password but had no luck, tried from my laptop also.

    1. Maybe a bad configuration in encryption protocol, etc. ?

  8. Sh4d0w says:

    Hi,

    Thx for your tutorial.

    Is it possible to enable DNSMasq?
    We will configure DNSMasq to point all domains back to 10.0.0.1 to connect to our local server.

    1. I’ve never tried, but it’s probably possible.

  9. Nathan says:

    Do not empty the wpa_supplicant.conf file by running the below command:
    sudo cp /dev/null /etc/wpa_supplicant/wpa_supplicant.conf

    Instead edit the wpa_supplicant.conf file to contain only the following two lines:

    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1

    Because if you try to connect to a wifi client from RaspAP WebGUI , none will be visible.

    https://cloud.githubusercontent.com/assets/13056292/18283917/ea7e5046-7467-11e6-99af-0b391e9b05b8.png

    1. Thanks for your return, we will modify that !

  10. Amol says:

    Hello,

    I have successfully configured a wifi using above tutorial.

    Now I wanted to remove hotspot password. Can I able to configure hotspot without password if yes how?

    1. I presume it’s possible by empty it via the webinterface.

  11. Adam says:

    I have followed the steps and the hotspot has appeared and I have connected to it however, there is no internet and when I type in the IP address you gave it requires a username and password. I tried the login details that I had setup on the rasp pi but that doesn’t work. Any idea what they could be?

    1. As said in the tutorial login and password are available on the github page of the projet.

  12. Adam says:

    I have now read the last section of the tutorial to enable ethernet, making changes to the .conf files, but when i try save the changes made, I get an error saying “Cant open files to write”. Any idea what went wrong? Also how after turning off the hotspot do i turn it back on again?

    Thanks in advance

    1. Hello, probably need to do a sudo before your command.

  13. Rif says:

    The “And if it still does not work?” section can now be disregarded as the installation script has been fixed as of today. (See: https://github.com/billz/raspap-webgui/issues/174)

    Basically, RaspAP’s quick installer script had a few bugs to prevent adding the IPv4 forwarding and the iptables lines to the /etc/rc.local file.

    I did a test just now of the quick installer method (wget -q https://git.io/voEUQ -O /tmp/raspap && bash /tmp/raspap) on a clean Raspbian Stretch (2018-03-13) installation, and it worked fine without having to do anything in the “And if it still does not work?” section.

    1. Okay, thanks for the return, we keep it for now as it may still help peoples. Maybe we will remove it in futur.

  14. Dana says:

    Thank you for this tutorial.
    I followed the instructions and I got the hotspot working and it connects to the internet.
    However, it is only if it connected directly to the router.
    I connected it to another ethernet wall jack that is active, and I can see the hotspot but there is no internet.
    I was hoping to use it to extend my router, is that possible?
    In addition, can the RPI3 B connect to the router via wifi, and then serve as a hotspot?
    Thank you

    1. Hello, i can’t see why ethernet wall can’t work if it’s directly link to router :/ Maybe a rule on the port or something like that, i just dont know :/.
      I presume it’s possible to use Wi-Fi instead of Ethernet, but you will probably need to modify some configuration to use a second Wi-Fi adapter instead of Ethernet for that.

Share
Suscribe to Newsletter
Inscrivez-vous à la Newsletter.
Vous avez aimé cet article ?
Inscrivez-vous et restez informé !