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

Use wlan1 as wlan client #196

Closed
Bigdesaster opened this issue May 16, 2018 · 12 comments
Closed

Use wlan1 as wlan client #196

Bigdesaster opened this issue May 16, 2018 · 12 comments

Comments

@Bigdesaster
Copy link

Bigdesaster commented May 16, 2018

Subject of the issue

Hello I'd like to use wlan1 as wlan client because i need an external antenna for the client.
Wlan0 is configured as AP.
Edit:

  • Also it's not possible to disable and enable wlan1 on the webif
  • If wlan1 is hotspot, it's not possible to scan wlan0

Your environment

  • Raspberry Pi hardware: Pi 3B+
  • Raspbian version: Stretch
  • RaspAP: Quick Install
  • Other software or services running with RaspAP: OpenHAB

Steps to reproduce

Use onboard wifi and usb wlan stick.
Goto WebIF section "ClientMode"

Expected behaviour

  • It should be possible to select the interface which schould be configured as client
  • It should be possible to start/stop other interfaces
  • It should be possible to scan other networks when another interface is ap mode

Actual behaviour

it's only possible to scan wlan0 or stop wlan0 on
it's not possible to scan for wifi if one interface is set to ap

@billz
Copy link
Member

billz commented May 23, 2018

You can change the default setting in /includes/config.php:

define('RASPI_WIFI_CLIENT_INTERFACE', 'wlan0');

@Bigdesaster
Copy link
Author

Bigdesaster commented May 23, 2018

Thank you. I did allready but it doesn't work yet. I found that the permission for 'wpa_cli' is missing in sudoers for interfaces. My workaround is with wildcard for wlan[0-9]
But that's not all. I want to use wlan0 as hotspot and wlan1 as client.
I'm currently trying to get it work. I will tell you here

@Bigdesaster
Copy link
Author

Bigdesaster commented May 23, 2018

hello billz,
i think i got a quick workaround now:

with visudo i changed some permissions. In install\common.sh (function patch_system_files() )that should be:
/sbin/wpa_cli -i wlan[0-9] scan_results
/sbin/wpa_cli -i wlan[0-9] scan
/sbin/ip link set wlan[0-9]
/bin/cat /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf
/bin/cp /tmp/wifidata /etc/wpa_supplicant/wpa_supplicant-wlan[0-9].conf
But maybe there should be used other wildcards because of compatinility to 'predictable network interface name'

I needed to change 2 lines in /includes/config.php and added another one:
define('RASPI_WIFI_CLIENT_INTERFACE', 'wlan1');
define('RASPI_WPA_SUPPLICANT_CONFIG', '/etc/wpa_supplicant/wpa_supplicant-wlan1.conf');
define('RASPI_WIFI_COUNTRY_CODE','DE');

In /includes/configure_client.php i added the line (56):
fwrite($wpa_file, 'country=' . RASPI_WIFI_COUNTRY_CODE . PHP_EOL); to add the country code.
This will be save into wpa_supplicant-wlan1.conf now, but maybe you should write the lines without the network {} part to wpa_supplicant.conf too.

Now i can acces my accespoint (wlan0) and connect to a client with wlan1. Unfortunately the routing from wlan0 to wlan1 does not work yet, but at the moment that's not part of your project.
Maybe it will be one time, i hope so. ;).
Now im going to hollidays. Maybe i can help to improve your nice project after my holidays. Just let me know, if you like.

Greetings
Chris

@gherlein
Copy link

I want this exact functionality as well. I'll take a peek and maybe send a pull request.
I'm also wondering how this can be templatized so that on install the key variables (SSID, IP address, Password) could be optionally specified to simplify the steps for an install - in other words, to configure the AP without even needing to use the GUI even that first time

@gherlein
Copy link

And Country code. I'm imagining a file that could be dropped onto the /boot partition of the SD card before first boot that would "just configure" this all to install and configure on first boot and still enable the interface after.

@gherlein
Copy link

However, this article: https://medium.com/poka-techblog/diy-wifi-router-using-kali-linux-on-a-raspberry-pi-3-model-b-89b8e5497cbf says that the BCM2837 is unstable in master mode, which matches my experiences this morning playing around with it. I wonder if shifting to wlan1 for the AP using another adapter may be a better overall option.

@randyoo
Copy link
Contributor

randyoo commented Jul 6, 2018

Just found this issue. I had already issued a pull request adding wlan1 to /etc/sudoers, but your solution looks nicer. Predictable interface name support looks like a nightmare, though!

@gherlein : I had lots of trouble in the past with stability of the internal WLAN in AP mode, but they have been working on the driver, and my recent experience is that it's been perfectly stable for nearly a week, whereas previously it would crash within hours, sometimes minutes.

@teklot
Copy link

teklot commented Jul 31, 2018

Hello @Bigdesaster,
I am not sure what I missed here. I was going to add the wlan1 (usb dongle) as wifi client but no success so far!
Would you please indicate which permissions you changed with visudo?
In the steps you described above, did you change install\common.sh, /includes/config.php, and configure_client.php before or after installing the raspap?

@Dude4Linux
Copy link

@gherlein - I've experienced problems keeping hostapd running on my Rpi 3B. I recently discovered that it has something to do with TKIP. After switching to CCMP, it has been working well.

@randyoo
Copy link
Contributor

randyoo commented Mar 25, 2019

@gherlein - I've experienced problems keeping hostapd running on my Rpi 3B. I recently discovered that it has something to do with TKIP. After switching to CCMP, it has been working well.

I had the same experience.

@billz
Copy link
Member

billz commented Apr 9, 2019

I'm also wondering how this can be templatized so that on install the key variables (SSID, IP address, Password) could be optionally specified to simplify the steps for an install - in other words, to configure the AP without even needing to use the GUI even that first time

The next step for this project will be using JSON for config management. Stay tuned

@billz
Copy link
Member

billz commented Apr 13, 2019

@tekzoom I've added @randyoo's input to our FAQ, please check it out.

Closing this issue for now, feel free to update if you have more info. Thanks

@billz billz closed this as completed Apr 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants