0

I setup an ad hoc network between my computer and a pi for a project which works perfectly but when I have the ad-hoc on I have no access to the internet on the pi. There are times I am going to need internet to download code so I will have to switch it off so that I can connect to Wi-Fi. I could write a python script to manually edit the interfaces file each time I want to toggle it but I'm thinking there is a better way. Does anyone know a command of some type I can use to toggle on and off ad-hoc when I want?

5
  • I think, giving the ad hoc network internet access is a better solution. What ad hoc connection do you use? Do you use IBSS interface mode?
    – Ingo
    Commented Nov 18, 2020 at 17:45
  • @Ingo I didn't think it would be possible to do that since it is a private network between two computers but I am very new to this. Yes I used IBSS mode I had to configure that on the laptop side of things. How would I give the Pi internet when I turn on the ad-hoc? Just as a reference I followed this tutorial.
    – Nicokofi
    Commented Nov 18, 2020 at 18:59
  • For permanent internet connection you need a second interface, eth0 or wlan1 with an additional USB/WiFi dongle. Then the RasPi can also provide internet for all other connected ad hoc devices. For switch mode you can simply use systemd-networkd. Are you able to connect the RasPi with an ethernet cable to the internet router or do you can have a USB/WiFi dongle available? Do you really need oldstable Raspbian Stretch? I wouldn't use it anymore.
    – Ingo
    Commented Nov 18, 2020 at 20:45
  • @Ingo Yes I do have a USB WIFI dongle and an Ethernet cable. I would prefer a solution which uses the dongle due to the nature of my project as a drone. I don't have a particular reason for using Raspbian Stretch it's just what I am used to and what I have done all my work on. What would you recommend? What I am gathering from you is that it is possible to have the Pi output a network on wlan0 while also receiving a WIFI connection on a wlan1 over the dongle if I set it up right. I would need to research that. Also, what do you mean by "systemd-networkd"
    – Nicokofi
    Commented Nov 18, 2020 at 21:04
  • I will test a solution with IBSS ad hoc connections and with an additional dongle for internet access, using systemd-networkd with up to date Raspberry Pi OS based on Buster. Just a moment please, then I will write an answer.
    – Ingo
    Commented Nov 19, 2020 at 8:33

1 Answer 1

1

As noted in a comment You also agree with a permanent uplink connection to an internet router. For this you can use the unused eth0 interface or an additional USB/WiFi dongle. With the latter you can use the onboard WiFi device for a protected uplink and the dongle for a RSN protected ad hoc connection if supported. You are always free to use an unprotected connection. Look at How to setup an unprotected Ad Hoc (IBSS) Network and if possible with WPA encryption? and use section ♦ Setup ad-hoc interface with additional USB/WiFi dongle for uplink to internet router.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.