VladoR
Posts: 2
Joined: Sun May 20, 2018 7:18 am

Two wireless networks simultaneous (wlan0-AP, wlan1-Client)

Sun May 20, 2018 7:48 am

I have a Pi 3 B (version 9 stretch) and WiFi USB dongle. I configure wlan0 (internal WiFi) to be as access point (AP) for other devices and wlan1 (USB dongle) to connect to WiFi network as client. When I start RPI and there is no network section in /etc/wpa_supplicant/wpa_supplicant.conf RPI is correctly creating AP. I have connected monitor and keyboard to RPI and via GUI I configure wlan1 to WiFi at that time everything works as I want. Problem is after restart of RPI. Now in /etc/wpa_supplicant/wpa_supplicant.conf is network section with configured ssid and psk, but AP is not created. It seems that he use configured ssid for both wlan0 and wlan1. And he is ignoring configuration for hostapd service. My aim is to have wlan0 as AP and wlan1 connected to configured WiFi network after restart automatically.

epoch1970
Posts: 1840
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Two wireless networks simultaneous (wlan0-AP, wlan1-Client)

Sun May 20, 2018 1:49 pm

First I would rename the wpa_supplicant.conf file to wpa_supplicant-wlan1.conf so that it should not apply to wlan0. (wpa_supplicant.conf is a default file that could apply to any wlan adapter.)
viewtopic.php?t=191453&start=25#p1208039
Hopefully the wlan0 interface will be still unconfigured when hostapd tries to take it over.

If that doesn't work correctly I would check that wlan0 and wlan1 don't exchange places upon reboot (and hostapd would fail because some options are not compatible with the other interface.)
If this is the case you can either enable "predictable network interfaces names" (via raspi-config?) or whip up a udev rule that gives one of your interfaces a specific name. AFAIK it's one or the other options.
PNIN for USB is lame, the name you get is the MAC address with a prefix. It won't change upon reboots, but it is quite ungainly and impractical.
On a Pi eth0 is a USB device so its name will change. wlan0 on Pi3 is an SDIO device, I don't know what PNIN makes of it.
See DougieLawson's post just below.
Last edited by epoch1970 on Sun May 20, 2018 3:01 pm, edited 1 time in total.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
DougieLawson
Posts: 33379
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: Two wireless networks simultaneous (wlan0-AP, wlan1-Client)

Sun May 20, 2018 2:06 pm

epoch1970 wrote:
Sun May 20, 2018 1:49 pm
If this is the case you can either enable "predictable network interfaces names" (via raspi-config?) or whip up a udev rule that gives one of your interfaces a specific name. AFAIK it's one or the other options.
"predictable" network names is easier to use (nothing needed in udev), except that everything gets an ugly name based on MAC address. That's enxb827eb?????? for wired and wlxb827eb?????? (for on-board WiFi). The MAC address is the RPi prefix with the low 24-bits of the serial for ethernet and the low 24-bits of the serial XOR'd with 0x555555 for WiFi.

All 15 of my Raspberries have "predictable" names and use a copy of the same /etc/dhcpcd.conf to assign fixed IP addresses (my old router didn't have an option to do that in its control panel, my new one does but I've not undone the /etc/dhcpcd.conf changes).
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

VladoR
Posts: 2
Joined: Sun May 20, 2018 7:18 am

Re: Two wireless networks simultaneous (wlan0-AP, wlan1-Client)

Sun May 20, 2018 9:20 pm

Thanks @epoch1970 I made two files :
/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
/etc/wpa_supplicant/wpa_supplicant-wlan1.conf
I put all client network configuration to wpa_supplicant-wlan1.conf and for AP I let wpa_supplicant-wlan0.conf with default.
Now it is working after restart like a charm :D
You save me a lot of time thanks again @epoch1970 and @DougieLawson.

User avatar
carry0987
Posts: 6
Joined: Sun Jul 22, 2018 12:16 pm
Location: Taiwan
Contact: Website Twitter

Re: Two wireless networks simultaneous (wlan0-AP, wlan1-Client)

Sun Aug 12, 2018 4:40 pm

VladoR wrote:
Sun May 20, 2018 9:20 pm
Thanks @epoch1970 I made two files :
/etc/wpa_supplicant/wpa_supplicant-wlan0.conf
/etc/wpa_supplicant/wpa_supplicant-wlan1.conf
I put all client network configuration to wpa_supplicant-wlan1.conf and for AP I let wpa_supplicant-wlan0.conf with default.
Now it is working after restart like a charm :D
You save me a lot of time thanks again @epoch1970 and @DougieLawson.
Hello, I have looked for this for long time, may I ask you for the step to set this ? (wlan0-AP, wlan1-Client)
Thanks !!!
Still learning HTML, CSS, PHP, Javascript, Python, C, Java

Return to “Advanced users”

Who is online

Users browsing this forum: No registered users and 24 guests