0

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?

Milliways
  • 54,718
  • 26
  • 92
  • 182
se7en
  • 13
  • 4
  • See [How to set up networking/WiFi](https://raspberrypi.stackexchange.com/a/37921/8697) you have provided insufficient information for a detailed answer. – Milliways Jul 19 '19 at 12:41
  • You asked how to modify `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. – Ingo Jul 19 '19 at 15:33
  • @Ingo, Hi, Any solution is ok with me. The objective is, I need to formulate an ad-hoc network with _n_ number of pi's. And a gateway that forwards the traffic to the internet. Earlier I did it using only /interfaces file, even most of the helps available online points me that way. I just can't figure out how to do it in Strech or even with the latest release. – se7en Jul 22 '19 at 05:13
  • @Milliways, I've gone through the information but if I haven't missed it, I am still lacking the info about how to activate the ad-hoc mode without touching the file, \interfaces. Any guidance is much appreciated. – se7en Jul 22 '19 at 06:39
  • I am not sure whether it is possible to enable ad-hoc on the on-board interface. You stated "stretch uses dhcpcd.conf for assigning static IP that is required for the ad-hoc network. How do I modify the dhcpcd.conf for the above purpose?" and the link answers that. You have provided virtually no information. – Milliways Jul 22 '19 at 07:01
  • It was doable by adding a few lines as mentioned in [https://raspberrypi.stackexchange.com/questions/49660/ad-hoc-setup-in-rpi-3]. But, in stretch, on doing so, dhcp just fails. And please find the updated version of the question I have put now. – se7en Jul 22 '19 at 07:06
  • This is new information (which belongs in your **Question** NOT Comments), but unless you specify what you have done it is difficult to help. The link clearly explains how to prevent `dhcpcd` from managing an interface and it is possible to use interfaces (in limited circumstances). I haven't actually used Ad-Hoc for years. You seem remarkably reluctant to explain **what YOU did** – Milliways Jul 22 '19 at 07:23
  • @Milliways, I have updated the question itself. ".. it is possible to use interfaces (in limited circumstances)" - do you mean no interference caused to the dhcp service?. – se7en Jul 22 '19 at 07:24

2 Answers2

2

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.

Ingo
  • 40,606
  • 15
  • 76
  • 189
1

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.

se7en
  • 13
  • 4