I am trying to configure multiple Wireless interface in Raspberry Pi Stretch. The objective is to allow an ad-hoc network to access the internet through that Pi device. For that I need to configure the in-built wlan0 in ad-hoc mode, whereas, an external wlan adapter, wlan1 to connect to the available wifi AP. The information here actually allows me to activate the ad-hoc mode but causes the dhcp service to stop working. I need the dhcp client enabled on wlan1. So far I have found that modifying /interfaces file causes problem with the dhcp service. In that case, how can I activate the ad-hoc mode and solve the above mentioned scenario?
2 Answers
As you noted in a comment you are also comfortable with using systemd-networkd. Any device conforming to IEEE 802.11 must provide the ad-hoc Independent Basic Service Set (IBSS) so it is possible to use it by just configuring the WiFi driver. In addition you can also use wpa_supplicant to setup an IBSS ad-hoc network. IBSS was initial specified only without encryption because it was thought to be done by higher protocol levels. Later encryption was also added to IBSS but it must be supported by the WiFi device. Raspberry Pi does not support encryption on IBSS. Maybe your external wlan adapter will do it? How to setup all of this you can look at Configuring 2 wifi interfaces, one DHCP and the other ad-hoc, in Stretch.
I've solved it by a simple approach that has been used here. I have created two files, wlan0 and wlan1 in /interfaces.d/
. Then, I have configured each of them accordingly. For instance, the ad-hoc network was configured as,
auto wlan0
iface wlan0 inet static
address 192.168.42.5 //the assigned IP address
netmask 255.255.255.0
wireless-channel 1
wireless-essid Pi-Adhoc
wireless-mode ad-hoc
And wlan1 as
auto wlan1
allow-hotplug wlan1
iface wlan1 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
This is necessary so that wlan1 can connect to the specific AP on boot. The network information can now be put in wpa_supplicant.conf
Finally, I have modified the dhcpcd.conf
to ignore both wlan0 as well as wlan1.
On rebooting, only eth0 and wlan1 were getting IP addresses from the DHCP server as expected.
dhcpcd.conf
. I only use systemd-networkd so I have a setup with it. Could this also be a solution for you? Please address me with @Ingo, otherwise I won't see your reply.