diff --git a/Captive-portal-setup.md b/Captive-portal-setup.md new file mode 100644 index 0000000..85486b8 --- /dev/null +++ b/Captive-portal-setup.md @@ -0,0 +1,90 @@ +### Setting up a captive portal + +The [nodogsplash project](https://github.com/nodogsplash/nodogsplash) is a lightweight, highly configurable captive portal solution. It integrates nicely with RaspAP and is recommended over other methods. No configuration changes are needed with RaspAP, however you will need to modify some default settings in the nodogsplash config. This step-by-step guide assumes you have already installed RaspAP, either with the [Quick Installer](https://github.com/billz/raspap-webgui/wiki/Quick-Installer-usage) or [manual setup instructions](https://github.com/billz/raspap-webgui/wiki/Manual-installation). + +1. Begin by updating `apt` with the latest package information: +``` +sudo apt-get update +``` + +2. With our package manager up to date, install a dependency required by nodogsplash: +``` +sudo apt-get install libmicrohttpd-dev +``` + +3. Next, we will clone the nodogsplash GitHub project: +``` +cd ~ +git clone https://github.com/nodogsplash/nodogsplash.git +``` + +4. We can now compile nodogsplash from the source: +``` +cd nodogsplash +make +sudo make install +``` + +5. With nodogsplash installed in the system, we will now make some small changes to its configuration. The nodogsplash GatewayInterface should be set to the interface RaspAP runs on (wlan0 is the default). You will also need to change the GateWayAddress to 10.3.141.1. + +``` +sudo nano /etc/nodogsplash/nodogsplash.conf +``` + +``` +# Default: NONE +# +# GatewayInterface is not autodetected, has no default, and must be set here. +# Set GatewayInterface to the interface on your router +# that is to be managed by Nodogsplash. +# Typically br-lan for the wired and wireless lan. +# +GatewayInterface wlan0 +# Parameter: GatewayAddress +# Default: Discovered from GatewayInterface +# +# This should be autodetected on an OpenWRT system, but if not: +# Set GatewayAddress to the IP address of the router on +# the GatewayInterface. This is the address that the Nodogsplash +# server listens on. +# +GatewayAddress 10.3.141.1 +``` +Save and quit out of the editor by pressing **Ctrl+X** and then pressing **Y** and finally **Enter**. + +6. We can now start up the software. This can be done by simply executing the binary with `sudo nodogsplash`. However, we'll make things a bit easier by adding a `systemd` service provided by the project. Copy the following file and enable the service: +``` +sudo cp ~/nodogsplash/debian/nodogsplash.service /lib/systemd/system/ +sudo systemctl enable nodogsplash.service +``` + +7. Now start the service and check its status: +``` +sudo systemctl start nodogsplash.service +sudo systemctl status nodogsplash.service +``` + +You should see output similar to the following: +``` +● nodogsplash.service - NoDogSplash Captive Portal + Loaded: loaded (/lib/systemd/system/nodogsplash.service; enabled; vendor preset: enabled) + Active: active (running) since Tue 2020-02-11 09:19:44 GMT; 34min ago + Main PID: 10539 (nodogsplash) + Tasks: 4 (limit: 1599) + Memory: 1.7M + CGroup: /system.slice/nodogsplash.service + └─10539 /usr/bin/nodogsplash + +Feb 11 09:19:44 raspberrypi systemd[1]: Starting NoDogSplash Captive Portal... +Feb 11 09:19:44 raspberrypi nodogsplash[10538]: [5][Tue Feb 11 09:19:44 2020][10538](src/main.c:496) Starting as daemon, forking to background +Feb 11 09:19:44 raspberrypi nodogsplash[10538]: [5][Tue Feb 11 09:19:44 2020][10539](src/main.c:271) Detected gateway wlan0 at 10.3.141.1 (dc:a6:32:3d:ff:9d) +Feb 11 09:19:44 raspberrypi nodogsplash[10538]: [5][Tue Feb 11 09:19:44 2020][10539](src/main.c:275) MHD Unescape Callback is Disabled +Feb 11 09:19:44 raspberrypi nodogsplash[10538]: [5][Tue Feb 11 09:19:44 2020][10539](src/main.c:305) Created web server on 10.3.141.1:2050 +Feb 11 09:19:44 raspberrypi nodogsplash[10538]: [5][Tue Feb 11 09:19:44 2020][10539](src/main.c:319) Using config options for FAS or Templated Splash. +Feb 11 09:19:44 raspberrypi systemd[1]: Started NoDogSplash Captive Portal. +Feb 11 09:19:46 raspberrypi nodogsplash[10538]: [5][Tue Feb 11 09:19:46 2020][10539](src/fw_iptables.c:382) Initializing firewall rules +``` + +8. Connect a client to RaspAP's hotspot. You should now see nodogsplash's captive portal screen: + +![captive portal screen](https://i.imgur.com/qS9mgTr.png) \ No newline at end of file