-1

After meticulously following the instructions in this thread. I have a problem with my Raspberry Pi 4 on Raspberry Pi OS. Indeed, when I use this script:

#!/bin/bash
# This script will stop Hotspot (AP+DHCP) and will Switch your Raspberry to a WIFI Client (Definitely) 
# Effect is dynamic and definive --> Next start will be as Client mode
# Run : bash sap2cl.sh

echo "========================================" echo " Switch from Hotspot (AP+DHP) to Client " echo " Next start will be : Wifi Client mode " echo "========================================" echo " " echo "Stopping hostapd, dnsmasq " sudo systemctl stop hostapd.service sudo systemctl stop dnsmasq.service

echo "Configure Client to recover dhcp" sudo cp /etc/dhcpcd-dynamic.conf /etc/dhcpcd.conf sudo systemctl daemon-reload

echo "Restart wpa_supplicant" sudo pkill wpa_supplicant sleep 2 sudo wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -B -Dnl80211,wext

echo "Done." exit

My wlan0 interface remains in DOWN, i.e.:

wlan0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN

I tried various solution like reboot, using the command :

sudo wpa_cli -i wlan0 reconfigure

But nothing does, I searched different article, but most of it is cut for Raspian Buster (Pi3).

wpa_supplicant being started by dhcpcd, shouldn’t I re-start dhcpcd instead?

Today I am looking to you for help, and I thank you in advance.

EDIT 29/08/2022 :

Is it valid if I disable the hostapd services and the dnsmasq service to just enable the dhcpcd service? dhcpcd is the one who manages wpa_supplicant on Raspberry Pi OS?

├─dhcpcd.service 
            │ ├─581 /usr/sbin/dhcpcd -b -q
            │ └─654 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0

My question may seem a bit stupid but I would like to understand how it works..

I will still try to switch to wifi management via systemd.

Marty
  • 1
  • 1

2 Answers2

0

You have followed a post by a low reputation user with a single post and no up votes. Not that this is not in and of itself wrong but doesn't inspire confidence that the original works.

Your post combines incompatible concepts; wpa_cli and running wpa_supplicant are futile with dhcpcd.

It IS possible to change from WiFi client to Access Point (there are a few posts on this site and I have done so myself) BUT this ignores a fundamental problem. Your router and all the other devices on your network cache network status! To reliably change you need to restart ALL devices on your network!

NOTE changing from client to AP is usually successful but going from AP to client is difficult.

I occasionally change my Pi to Access Point when I am travelling and entering a new network environment but changing in an existing environment is not simple.

You may find https://raspberrypi.stackexchange.com/a/138392/8697 useful, this is a simpler way of setting up an Access Point, but changing between AP and client mode is subject to the network caching issues.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Thank you very much for your answer, it will no doubt greatly help me. I will post my experiences in Edit. I have edited a my question with a point that could be also interesting (maybe too simple to work lmao). – Marty Aug 29 '22 at 06:23
0

I can not comment on other solutions I have not tested.

If I understand your additional Question it is possible to have a number of services running provided they do not conflict.

It is quite acceptable to have services which are disabled or stopped (NOTE the distinction between start/stop and enable/disable - the latter determine what runs on boot).

See https://raspberrypi.stackexchange.com/a/94985/8697 where I did something along these lines - but this was 3½ years ago. Currently I use systemd-networkd for most of my networking - including Access Point.

Milliways
  • 59,890
  • 31
  • 101
  • 209