RasPi gets no IP after router change

Hello!

I switched my router today, now I’ve got a Fritzbox 7530. With this change, my Pi doesn’t get an IP anymore. In my previous network, the Pi handled the DHCP (via Pihole), before switching routers, I disabled it in the Pihole settings, so my new router can “work as intended” before I set everything up again. After I set everything up, I connected the Pi again, and the Fritzbox sees the Pi, but it doesn’t assign an IP to it. I tried to assign the old IP manually, but I can’t, since it’s “Out of range” for the Fritzbox.

Now, I can’t access the Pi via SSH (it doesn’t get an IP) and to change that, I’d need to SSH into it, which I can’t. I tried looking through the files, but I didn’t see anything network relevant. What are my options now?

I find it rather strange to have the Pi soliciting for DHCP, while the DHCP server is running on Pihole. Do I understand correctly that Pihole is running on the very same Pi or do you have a secondary device running Pihole?
If you connect any other device on the new Fritz, does it get automatically settings from DHCP?

Yes, it’s the same Pi. Other devices work fine, it’s just the Pi.

I assume the error comes from the static IP that is set in the Pi, which is outside of the range of the addresses the Fritzbox can give.

Can you share IP range of your FritzBox as well as STATIC IP of your Raspberry Pi

Yeah, that clears things up. Pi is using static IP, hence it won’t acquire settings from Fritz DHCP.
Keep the Pi connected on the Fritz. From another device, e.g a PC/laptop, either add a secondary IP on the interface in the same subnet as the Pi, or change the address to match the old subnet if you don’t know how to add a secondary IP. For example:
If Fritz is offering 192.168.178.X/24 addresses and Pi still has 192.168.1.10/24, then assign to the PC the IP 192.168.1.2/24, access the Pi, change the static IP settings to either DHCP or a static in the 192.168.178.X/24 subnet, and revert the IP of the PC back to 192.168.178.X

Keep the Pi connected on the Fritz. From another device, e.g a PC/laptop, either add a secondary IP on the interface in the same subnet as the Pi, or change the address to match the old subnet if you don’t know how to add a secondary IP. For example:

Thank you, that worked - the Fritzbox assigns an IP to the Pi.

I can’t SSH into it, though:

ssh: connect to host 192.168.2.125 port 22: Connection timed out

Could the problem be that the Pi does have a wrong IP for the router?

it might be easier to connect locally to the RPi using keyboard and screen if possible.

Which IP does the router, the Pi, and your PC have?

I think I could do this. I’ll go with this if the other approach doesn’t work.


Which IP does the router, the Pi, and your PC have?

My PC: 192.168.1.22
Fritzbox: 192.168.178.1
RasPi: 192.168.2.125

Range the Fritzbox can adress:
192.168.1.20 - 192.168.177.200 (Subnetmask 255.255.0.0)
Local DNS Server: 192.168.178.1 (the Fritzbox)
DHCP is activated in the Fritzbox.
Both the RasPi and my PC are on a wired connection with the Fritzbox.

why are you going with such a huge IP range? If I’m not mistaken, a netmask of 255.255.0.0 will result in 65536 possible hosts :face_with_raised_eyebrow:

Usually 192.168.178.0/24 should be sufficient.

Fritzbox: 192.168.178.1 (Static)
RasPi: 192.168.178.2 (Static)
Local devices: 192.168.1.20 ff (DHCP)
Netmask 255.255.255.0

Probably, yeah - I just made the lower bound lower, so the original RasPi IP is in it. Can I just change the static IP of the RasPi in the Fritzbox, or do I have to go in the settings of the RasPi (which still doesn’t work :smiley: )?

well you could change the Fritzbox IP address too. This way you would not need to go into RPI. STATIC IP of the RPi can be changed on the RPi only. Or you place the SD card of the RPI into another Linux box and change config files manually.

Probably easiest might be to perform a change as follow

FritzBox change to 192.168.2.1\24 (255.255.255.0)
RasPi keep at 192.168.2.125
Set DHCP Server range to 192.168.2.20-192.168.2.120 (255.255.255.0)
Set DNS Server inside DHCP Server config to 192.168.2.125
My PC: set to DHCP

Thank you so much! Your configuration made everything work again.

ensure the RPi is using STATIC IP, just to be sure :wink:

This is an old thread, but I may have found a bug in DietPi.
Let me clarify my situation, which is very similar to OP’s.
I was using a mobile router and assigned a static IP address to my DietPi.
All was working great until I needed to change routers. The new router is very poor, and only allows 192.168.0.0/24, and this was not the same subnet as original static IP address I had set.
I thought that using dietpi-config and changing to DHCP on the wireless network would resolve the situation… but I was pulling my hair out when the Raspberry kept using the same static address as before.
In the end, I realized why. In the file /etc/dhcpcd.conf at the end, I had this:

interface wlan0
	static ip_address=192.168.26.2/24
	static routers=192.168.26.1
	static domain_name_servers=192.168.26.1

Of course, I needed to remove that, otherwise the DHCP client kept using that address!

Could you see if you can replicate this issue on a new DietPi install? First use a static IP, check if etc/dhcpcd.conf contains those lines, switch to DHCP and see if those lines are still there.

dietpi-config is not managing dhcpcd but isc-dhcp-client/dhclient as DHCP client. Did you install dhcpcd manually for some reason? If not, try to purge it:

apt purge --autoremove dhcpcd5

A long time ago Pi-hole was pulling it as dependency, although we disabled the service. However, that’s where it might have come from. Now Pi-hole doesn’t require or install it anymore.

1 Like

Thanks MichaIng for the explanation.

I didn’t install Pihole, but I did try to install Adguard Home. Maybe that’s where it came from?
I’ll have a look tomorrow; thanks again for your help!

At least from our side we don’t pull any DHCP client while installing AGH.