Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi client AP mode #297

Merged
merged 47 commits into from
Apr 8, 2019
Merged

Wifi client AP mode #297

merged 47 commits into from
Apr 8, 2019

Conversation

billz
Copy link
Member

@billz billz commented Mar 6, 2019

First stab at creating a "one-click" configuration to enable a simultaneous wifi client + AP mode. This works by adding a uap0 interface and binding this with known-good settings to dnsmasq, dhcpcd & hostapd. A servicestart.sh script brings up services in a specific order and timing to avoid race conditions.

Only tested thus far on Stretch Lite with a 3B+. Some notes:

  • Assumes a wifi client is configured
  • Bringing up uap0 with the toggle is functional
  • Switching back to non-wifi (wired) client AP is buggy
  • Won't work on reboot unless persisted in /etc/rc.local
  • iptables rules should be moved from servicestart.sh to the installer

raspap

Updated the Advanced tab of Hostapd config UI to use bootstrap toggles 😎

@billz billz self-assigned this Mar 6, 2019
@billz billz requested review from SirLagz and jrmhaig and removed request for SirLagz March 6, 2019 20:47
@cleanev
Copy link

cleanev commented Mar 21, 2019

Hello @billz - how can I test this branch? I am bit of a newbie to Linux world and though I can read and follow sometimes this type of questions arise on how to do something. Will appreciate if you can highlight it so I can initiate testing to provide you with any errors I may get. Thank you

@billz
Copy link
Member Author

billz commented Apr 3, 2019

@clean-ev very kind of you to offer to test.

Let's assume you are starting with a clean install of Stretch Lite on a Pi Zero W or RPi 3B/B+, followed the usual prerequisites, have the Pi connected as a WiFi client and accessible via ssh. Connect via ssh and follow the steps below:

  1. Begin by cloning the project to the web root and check out the feature branch.
sudo git clone https://github.com/billz/raspap-webgui.git /var/www/html
cd /var/www/html
sudo git fetch origin
sudo git checkout -b wificlient-ap origin/wificlient-ap
  1. The Quick Installer works by fetching the latest code from the master branch. We want it to use the local feature branch instead. Move into the /installers directory and edit two files.
cd installers
sudo nano raspbian.sh

Comment out or delete the first two lines in raspbian.sh and edit the source command:

#UPDATE_URL="https://raw.githubusercontent.com/billz/raspap-webgui/master/"
#wget -q ${UPDATE_URL}/installers/common.sh -O /tmp/raspapcommon.sh
source /var/www/html/installers/common.sh

Edit common.sh and comment out or delete the function call download_latest_files on line 343:

sudo nano common.sh
function install_raspap() {
    display_welcome
    config_installation
    update_system_packages
    install_dependencies
    optimize_php
    enable_php_lighttpd
    create_raspap_directories
    check_for_old_configs
    #download_latest_files  <<<
    change_file_ownership
    create_hostapd_scripts
    move_config_file
    default_configuration
    patch_system_files
    install_complete
}
  1. While still in the /installers directory, start the Quick Installer on the wificlient-ap branch.
./raspbian.sh
  1. Accept the default settings. Do not reboot when installer finishes.

  2. Open the RaspAP gui. Choose Configure Hotspot > Advanced and enable WiFi client AP mode. Optionally, enable logging as this is often helpful. The UI should indicate that hostapd is not running. Save the settings and start the hotspot. Wait a few seconds as the RaspAP service starts. You should see output like this:

hostapd

  1. If all goes well, refreshing the Configure Hotspot page should display a new interface uap0, like so:

hostapd2

  1. Connect a client to the AP. Confirm that you have internet access. The logfile output should look something like the following:
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.uap0: -95 (Operation not supported)
uap0: interface state UNINITIALIZED->COUNTRY_UPDATE
uap0: Could not connect to kernel driver
Using interface uap0 with hwaddr b8:27:eb:13:e8:1b and ssid "raspi-webgui"
uap0: interface state COUNTRY_UPDATE->ENABLED
uap0: AP-ENABLED 
uap0: STA 14:10:9f:e5:5a:23 IEEE 802.11: associated
uap0: AP-STA-CONNECTED 14:10:9f:e5:5a:23
uap0: STA 14:10:9f:e5:5a:23 RADIUS: starting accounting session A657E712B4EF6F17
uap0: STA 14:10:9f:e5:5a:23 WPA: pairwise key handshake completed (WPA)
uap0: STA 14:10:9f:e5:5a:23 WPA: group key handshake completed (WPA)

Glad to clarify any of the above.

@cleanev
Copy link

cleanev commented Apr 4, 2019

Hell @billz,

Thank you for detailed instructions.

I used RPi3B+ as I don’t have RPiZeroW, will order after success

I was able to install stretch lite (cloned in berry boot), connected to WiFi and then go thru the steps and on first try got the hotspot showed up. Changed password for web GUI, changed DHCP address and reboot and after clicking Start hotspot I got online. Traffic shows flowing thru WiFi that I can check on my router.

I already have ipheth-utils & usbmuxd installed on gold stretchlite image so I plugged in my iPhone and traffic moved over to eth1 automatically. Then while eth1 was alive I plugged in eth0 and traffic moved to new connection. Disconnecting eth0 pushed back to eth1 and disconnecting eth1 pushed traffic back to WiFi.

So far this has been the easiest to work with.

Connected devices are not shown on dashboard

Can I suggest as enhancement where I can change wireless mode to ‘a’ and accordingly change channels to AC mode channels available for selected country?

I will destroy this again and try once more later this afternoon and report

@cleanev
Copy link

cleanev commented Apr 4, 2019

@billz I tried this one more time following steps you outlined above and hotspot was available on first try as it did earlier. This was again tested on RPi3B+ and not RPiZeroW.

After this second try I tried to install pi-hole and get all this working harmoniously. Not so easy it seems

So I followed this link and did what is mentioned-
https://discourse.pi-hole.net/t/raspap-pihole/14739/6
Steps mentioned are:
Install RaspAP
Install Pi-Hole
sudo touch /var/lib/misc/dnsmasq.leases
sudo chown pihole:pihole /var/lib/misc/dnsmasq.leases
reboot

Post reboot i can connect to 172.20.10.3 which is eth1 and also to pihole admin page at 172.20.10.3/admin. Upon starting hotspot it shows up and I can join, however there is no internet access. I tried to check for dnsmasq.conf file and that file seems to be replaced by pihole installation with a single line
conf-dir=etc/dnsmasq.d

dnsmasq.d is a directory that has 01-pihole.conf file and a README file in it.

I believe I am close to making this work with pihole as well but am missing something subtle.

@cleanev
Copy link

cleanev commented Apr 4, 2019

Few more updates-

  1. When changing dhcp server settings, the settings do get saved in dnsmasq.conf, however dhcpcd.conf file still has the static IP address showing 19.2168.50.1/24 - can this be fixed?
  2. If a password has $ sign in it then upon saving the same gets converted to a number - I edit hostapd.conf file to make sure the $ sign is there before restarting hotspot

@billz
Copy link
Member Author

billz commented Apr 7, 2019

@clean-ev excellent feedback, many thanks.

Re: connected devices, this was added after the feature branch was created. It will be merged later.
Re: change wireless modes and auto-updating available channels, great idea and on the todo list.

Good point re: the static 192.168.50.1/24 address. At the moment this is used only for the uap0 configuration, but it certainly can and should be managed from the DCHP settings UI. I'll push an update shortly.

Thanks for pointing out $ symbol in the password. At the moment hostapd.php simply writes the wpa_passphrase out to hostapd.conf. This could be improved by converting the ASCII passphrase to PSK or HEX.

@billz
Copy link
Member Author

billz commented Apr 8, 2019

Tested with wired ethernet and as a wireless client ("managed" mode) using RPi 3B & Stretch Lite in 3 different scenarios:

  1. Wired AP (eth0). Run Quick Installer & reboot. AP is up and functional with no changes to default config.
  2. Wifi client on local network (wlan0). Connect to wireless router as a managed device.
  3. Simultaneous AP and managed mode Wifi (uap0). When configured in managed mode, enable AP from Advanced hostapd setting toggle. AP is functional without restart.

Repeated tests 2 & 3 with RPi Zero W (Stretch Lite) also with Quick Installer. Stopping/starting AP presented no issues. AP in managed mode is observed to be stable on both RPi 3B and Pi Zero W. A sample throughput analysis on the Pi Zero W is below.

speedometer-wlan0-uap0-rpizero-w

Note: Simultaneous AP and managed mode Wifi uses a known-good default config. Changes to dhcp server settings in this mode are ignored.

@billz billz merged commit 96717de into master Apr 8, 2019
@cleanev
Copy link

cleanev commented Apr 11, 2019

@billz - seems this is no longer working - went thru the steps you have highlighted earlier on a new stretch install on 3B+. I configure WiFi,reboot, install git, clone your code and go thru all the steps above.
Upon rebooting WLAN takes 10.3.41.n address and when connecting to AP it complains that there is no internet. all this worked during my previous tests. Is there something else I need to do?

@billz billz deleted the wificlient-ap branch April 11, 2019 19:31
@billz
Copy link
Member Author

billz commented Apr 11, 2019

@clean-ev this branch was merged with master. You can do a normal install as per the project readme. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants