Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Wifi Captive Portal Using Raspberry Pi

Wifi Captive Portal Using Raspberry Pi


Aniket Maithani

September 04, 2017


  1. Captive Portal Using Raspberry Pi with Tornado - Aniket Maithani

  2. About Me My name is Aniket Maithani. I'll keep this

    short • Works @Radiowalla Network Pvt. Ltd • Handles Development & Dev-Ops • B.Tech (CS&E) graduate from Amity University, Noida (UP) • Loves to travel • Blog during free time • Cricket Lover • "CHAI" addict • Plays Guitar too!
  3. Let’s Get Started

  4. What is a Captive Portal?

  5. Definition : A captive portal is a Web page that

    the user of a public-access network is obliged to view and interact with before access is granted. Captive portals are typically used by business centers, airports, hotel lobbies, coffee shops, and other venues that offer free Wi-Fi hot spots for Internet users.
  6. Why to use Captive Portal?

  7. - You need a page identifying it is your business

    and your Wi-Fi network - Using Data to Improve the User Experience - Allowing user’s to accept Terms and Condition for usage.
  8. That’s fine! But how to make one?

  9. Well let’s simplify things - In order to have a

    fully functional Captive Portal we need following things - ROUTER with CUSTOM OS / SOFTWARE - WIFI Enabled Access - ACCESS TO INTERNET [OF COURSE!]
  10. Raspberry Pi [ as a router] The Raspberry Pi is

    a low cost, credit-card sized computer that plugs into a computer monitor or TV, and uses a standard keyboard and mouse. Hence just like a normal computer you can turn Raspberry Pi into a router all you need is external wifi adapter and bit of configuration on the device.
  11. Tornado ? Tornado is a Python web framework and asynchronous

    networking library, originally developed at FriendFeed. By using non-blocking network I/O, Tornado can scale to tens of thousands of open connections, making it ideal for long polling, WebSockets, and other applications that require a long-lived connection to each user.
  12. So let’s dive into a problem statement. - Mr. Rawat

    owns a cafe and most of the evenings are quite hectic for him since there is a huge line of customer he needs to serve. - Recently, he has been seeing some drop in the customer check-in during the evening time. - On inquiring he came to know that his place doesn’t have an internet access. - Mr. Rawat now wants to install Hotspot in his location and also wants to show advertisements/offers when a user gets connected to the wifi hotspot.
  13. Let’s take a look at the block diagram of the

    Wifi Captive Portal
  14. RASPBERRY PI WITH WI-FI Dongle External Internet Connection Internal Wi-Fi

    Adapter as a Base Station Running Tornado coupled with IPSet and IPTables for Traffic Management. Includes HOSTAPD and DHCP Configurations
  15. User Connects to the Open Wifi with a given SSID.

    Request gets passed onto the machine IP Traffic Rules in the machines blocks requests to external side temporarily User is redirected to inbuilt captive portal. Authentication / OTP Page If Auth = Success { Internet_access: “granted” }
  16. Finally your machine would look something like this.

  17. Let’s fuel up the machine - To get started we

    need Rasberry-Pi machine with Raspbian Wheezy installed in it. - For better performance we can use premium grade SD Card Class 10 for this. - The easy way is download Raspbian Image from [https://www.raspberrypi.org/downloads/] and burn it on the SD card using software like etcher.
  18. Once done - Plug the device. Put in the SD

    card and boot up the machine. - Use default username and password : pi and raspberry for log in. - Once logged in we need to install following packages.
  19. Follow the instructions here : https://gist.github.com/aniket maithani/40277f60e2d2048684 e148b0c0ef2d0c

  20. Code base walkthrough. Build by build.

  21. Testing

  22. Demo

  23. Questions?

  24. Queries? Follow me on : FB : fb.com/aniket.maithani GitHub :

    github.com/aniketmaithani Twitter : @2aniketmaithani