FicusOnline Blog

Linux, opensource projects tips 

2021/04/26  LInux, Orange Pi, Raspberry Pi, Network


Install RaspAP Web Frontend in Orange Pi PC converted into the router which is attached RTL8188 USB WiFi dongle activated the AP mode. Fiast of all, for matching the network settings already have been configured, modify the files in the "config" directory, then proceed to to the next steps for the installation.

Install Conditions

  • Armbian 21.02.3 Buster with Linux 5.10.21-sunxi
  • Orange Pi PC has to been converted into the router in accordance with the below link(sorry only Japanese).

 RTL8188によるOrangePiのルータ化Vol.2 Orange Pi

iwconfigによるLANインターフェイスの確認で、wlan0またはwlan1という表記ではなくwlx*******という表記になっている場合の対処方法 https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/ $ sudo ln -s /dev/null /etc/udev/…

RaspAP Document
https://docs.raspap.com/manual/

 


Modify config files

Orange Pi PC converted into the routher is set the network interface wlan1 as the access point(AP), so should be changed wlan0 with wlan1, in addition, dhcp-range and so on should be changed.

 

config/090_wlan0.conf Optional : change the file name to 090_wlan1.conf

# RaspAP wlan1 configuration for wired (ethernet) AP mode
interface=wlan1
domain-needed
dhcp-range=11.22.33.44,11.22.33.150,255.255.255.0,12h
dhcp-option=8.8.8.8,1.1.1.1

 

config/config.php

.....
.....
define('RASPI_WIFI_AP_INTERFACE', 'wlan1');
.....
.....

 

config/defaults.json No need of the sectin for wlan0, as DHCP server and Client IP range already has beed set on wlan1.

{
  "dhcp": {
    "wlan1": { 
      "static ip_address": [ "11.22.33.44/24" ],
      "static routers": [ "11.22.33.44" ],
      "static domain_name_server": [ "1.1.1.1 8.8.8.8" ],
      "subnetmask": [ "255.255.255.0" ]
    },
    "wlan0": {
      "static ip_address": [ "192.168.10.10/24" ],
      "static routers": [ "192.168.10.1" ],
      "static domain_name_server": [ "1.1.1.1 8.8.8.8" ],
      "subnetmask": [ "255.255.255.0" ]
    },
    "options": {
      "# RaspAP default configuration": null,
      "hostname": null,
      "clientid": null,
      "persistent": null,
      "option rapid_commit": null,
      "option domain_name_servers, domain_name, domain_search, host_name": null,
      "option classless_static_routes": null,
      "option ntp_servers": null,
      "require dhcp_server_identifier": null,
      "slaac private": null,
      "nohook lookup-hostname": null
    }
  },
  "dnsmasq": {
    "wlan1": {
      "dhcp-range": [ "11.22.33.44,11.22.33.150,255.255.255.0,12h" ]
    },
    "wlan0": {
      "dhcp-range": [ "192.168.10.50,192.168.10.150,12h" ]
    }
  }
}

 

config/dhcpcd.conf DHCP client setting. wlan0 is asigned as DHCP server client network by the router connected to the internet. Set the static IP address within the range of the router assigned.

.....
.....
# RaspAP default configuration
.....
.....

# RaspAP wlan0 configuration
interface wlan0
static ip_address=192.168.0.xx/24
static routers=192.168.0.1
static domain_name_server=192.168.0.1 1.1.1.1

 


Install Related Packeges and Copy Files

Install the following packages.

$ sudo apt-get install dhcpcd5 lighttpd git hostapd dnsmasq iptables-persistent vnstat qrencode php7.3-cgi

 

Activate Lighttpd fastcgi module, then reload it and restart lighttpd.

$ sudo lighttpd-enable-mod fastcgi-php    
$ sudo service lighttpd force-reload
$ sudo systemctl restart lighttpd.service

 

Download RaspAP to /var/www/html directory.

$ sudo git clone https://github.com/RaspAP/raspap-webgui /var/www/html

 

Create the configuration file for lighttpd extension(rewrite module), add it into lighttpd config directory.

$ WEBROOT="/var/www/html"
$ CONFSRC="$WEBROOT/config/50-raspap-router.conf"
$ LTROOT=$(grep "server.document-root" /etc/lighttpd/lighttpd.conf | awk -F '=' '{print $2}' | tr -d " \"")

$ HTROOT=${WEBROOT/$LTROOT}
$ HTROOT=$(echo "$HTROOT" | sed -e 's/\/$//')
$ awk "{gsub(\"/REPLACE_ME\",\"$HTROOT\")}1" $CONFSRC > /tmp/50-raspap-router.conf
$ sudo cp /tmp/50-raspap-router.conf /etc/lighttpd/conf-available/

 

Activate the above setting, and restart lighttpd.

$ sudo ln -s /etc/lighttpd/conf-available/50-raspap-router.conf /etc/lighttpd/conf-enabled/50-raspap-router.conf
$ sudo systemctl restart lighttpd.service

 

For network management, giving the authority allowed only the root user to the server user:www-data. Copy raspap.sudoers into /etc/sudoers.d directory.

$ cd /var/www/html
$ sudo cp installers/raspap.sudoers /etc/sudoers.d/090_raspap

 

raspap.sudoers Optional : Comment out the lines if you want to fix. 

www-data ALL=(ALL) NOPASSWD:/sbin/ifdown
www-data ALL=(ALL) NOPASSWD:/sbin/ifup
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] scan_results
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] scan
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] reconfigure
www-data ALL=(ALL) NOPASSWD:/sbin/wpa_cli -i wlan[0-9] select_network [0-9]*
# www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/hostapddata /etc/hostapd/hostapd.conf
# www-data ALL=(ALL) NOPASSWD:/bin/systemctl start hostapd.service
# www-data ALL=(ALL) NOPASSWD:/bin/systemctl stop hostapd.service
# www-data ALL=(ALL) NOPASSWD:/bin/systemctl start dnsmasq.service
# www-data ALL=(ALL) NOPASSWD:/bin/systemctl stop dnsmasq.service
www-data ALL=(ALL) NOPASSWD:/bin/systemctl restart dnsmasq.service
www-data ALL=(ALL) NOPASSWD:/bin/systemctl start openvpn-client@client
www-data ALL=(ALL) NOPASSWD:/bin/systemctl enable openvpn-client@client
www-data ALL=(ALL) NOPASSWD:/bin/systemctl stop openvpn-client@client
www-data ALL=(ALL) NOPASSWD:/bin/systemctl disable openvpn-client@client
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/ovpnclient.ovpn /etc/openvpn/client/client.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/authdata /etc/openvpn/client/login.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dnsmasqdata /etc/dnsmasq.d/090_*.conf
www-data ALL=(ALL) NOPASSWD:/bin/rm /etc/dnsmasq.d/090_*.conf
# www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dhcpddata /etc/dhcpcd.conf
www-data ALL=(ALL) NOPASSWD:/sbin/shutdown -h now
www-data ALL=(ALL) NOPASSWD:/sbin/reboot
www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan[0-9] down
www-data ALL=(ALL) NOPASSWD:/sbin/ip link set wlan[0-9] up
www-data ALL=(ALL) NOPASSWD:/sbin/ip -s a f label wlan[0-9]
# www-data ALL=(ALL) NOPASSWD:/bin/cp /etc/raspap/networking/dhcpcd.conf /etc/dhcpcd.conf
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/enablelog.sh
www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/disablelog.sh
# www-data ALL=(ALL) NOPASSWD:/etc/raspap/hostapd/servicestart.sh
www-data ALL=(ALL) NOPASSWD:/etc/raspap/lighttpd/configport.sh
www-data ALL=(ALL) NOPASSWD:/etc/raspap/openvpn/configauth.sh
www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/hostapd.log
www-data ALL=(ALL) NOPASSWD:/bin/chmod o+r /tmp/dnsmasq.log
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dnsmasqdata /etc/dnsmasq.d/090_adblock.conf
www-data ALL=(ALL) NOPASSWD:/bin/cp /tmp/dnsmasq_custom /etc/raspap/adblock/custom.txt
www-data ALL=(ALL) NOPASSWD:/etc/raspap/adblock/update_blocklist.sh

 

Create RaspAP directories.

$ sudo mkdir /etc/raspap/
$ sudo mkdir /etc/raspap/backups
$ sudo mkdir /etc/raspap/networking
$ sudo mkdir /etc/raspap/hostapd
$ sudo mkdir /etc/raspap/lighttpd

 

Copy the php file for user auth.

$ sudo cp raspap.php /etc/raspap 

 

Set permissions for the server directory.

$ sudo chown -R www-data:www-data /var/www/html
$ sudo chown -R www-data:www-data /etc/raspap

 

Move hostapd shell scripts and set permissions.

$ sudo mv installers/*log.sh /etc/raspap/hostapd 
$ sudo mv installers/service*.sh /etc/raspap/hostapd
$ sudo chown -c root:www-data /etc/raspap/hostapd/*.sh 
$ sudo chmod 750 /etc/raspap/hostapd/*.sh 

 

Copy Lighttpd shell scripts and set permissions.

$ sudo cp installers/configport.sh /etc/raspap/lighttpd
$ sudo chown -c root:www-data /etc/raspap/lighttpd/*.sh

 


Assign the Default Files

Use the files modified in the beginning as the default setting files.

$ sudo cp config/090_raspap.conf /etc/dnsmasq.d/090_raspap.conf
$ sudo cp config/090_wlan0.conf /etc/dnsmasq.d/090_wlan0.conf
$ sudo cp config/dhcpcd.conf /etc/dhcpcd.conf
$ sudo cp config/config.php /var/www/html/includes/
$ sudo cp config/defaults.json /etc/raspap/networking/

Please refer the document about the other options.

 Access to you allocated the IP address. 

http://192.168.1.xx

 

Dash Board

Access Point Setting

WiFi Connection Setting

comments powered by Disqus