0

I have a raspi 4B running headless raspbian version 10 (buster) on it. I have configured my wpa_supplicant.conf as follows:

Header...        
network={
            ssid="wifi_A"
            psk="passwordOfA"
            priority=1 #lower priority
        }
        network={
           ssid="wifi_B"
           psk="passwordOfB"
           priority=2 #higher priority
        }

After reboot I can see (using iwconfig), that it is first connected to wifi_B (laptop hotspot) and when I turn the hotspot off it immediatley joins wifi_A (router). So far so good. Checking sudo route -n there is only one line: 10.0.0.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0 (sorry for the layout I have to type since I cannot copy it). I do actually have a dhcpcd.conf file in /etc/dhcpcd.conf, which contains:

interface wlan0
static ip_address=10.0.0.1/24

The problem is, I cannot ping google or any other server and I cannot ping other clients or the host in my network I am connecting two (neither network A nor B). However, if I run sudo dhclient -v wlan0 I am getting access to other devices in my network and the internet.

The routing table looks like this afterwards:

Destination    Gateway           Genmask     ...
0.0.0.0        192.168.137.1     0.0.0.0          UG   0     0    0  wlan0
10.0.0.0       0.0.0.0           255.255.255.0    U    303   0    0  wlan0
192.168.137.0  0.0.0.0           255.255.255.0    U    0     0    0  wlan0

So my questions are

  • Why is no IP address assigned during boot?
  • How can I solve the issue without having to manually call dhclient after every boot?

Note that I am quite new to networking on the raspi and /etc/network/interfaces.d is empty.

2
  • You are putting nonsense in dhcpcd.conf Do NOTHING, let it connect to your router and it should work. Setting static IP Address is an abomination - unfortunately common in Pi users who don't understand networking.
    – Milliways
    Commented Sep 22, 2022 at 10:06
  • You are so right - on so many levels.
    – Slev1n
    Commented Sep 22, 2022 at 15:12

1 Answer 1

0

So, as @Milliways stated, the dhcpcd.conf content was the problem. It was a relict from a previous session where the raspi was a host opening an access point to a local network. Therefore, the dhcpcd.conf was useful. However, the file content lead to some mischief regarding the IP on the wlan0 interface.

Removing the content of the dhcpcd.conf file resolved the problem and I was able to ping devices in my network or in the internet.

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.