this post was submitted on 08 May 2024
6 points (100.0% liked)

raspberrypi

3243 readers
1 users here now

Community about the single-board computers, micro-controllers and related projects.

https://www.raspberrypi.com/

Other RaspberryPi communities on Lemmy

founded 4 years ago
MODERATORS
 

I have a Raspberry Pi 02W running Pi-Hole and ordinarily things work perfectly, but I've got something in my house tripping my fuse box which I'm unable to locate. The tripper, not the fuse box. Anyway, what it means is occasionally, I lose power and so my router and my Pi-Hole go down.

I've configured my /etc/dhcpcd.conf so that my RPi02W can have a static IP

interface wlan0
static ip_address=192.168.1.100/24
static routers=192.168.1.1
static domain_name_servers=194.168.4.100 194.168.8.100

And have rebooted to confirm it's fine, and it's fine.

However when the router goes down and I bring everything back up, the Pi-Hole can't reconnect to the router. I can log in to the router and see it connect briefly, but it's only briefly and then nothing. I even try enabling DHCP on the router and it still refuses to reconnect. Ultimately the only way to get it to reconnect is to factory reset the router, change the password back to my usual password, wait for the RPi02W to connect and then disable the DHCP again. Needless to say it's a pain in the arse.

What am I doing wrong? How do I fix this?

#Solution I switched the DNS servers from Virgin Media to 8.8.8.8 and that seems to fix it. Not sure why, but it does.

top 3 comments
sorted by: hot top controversial new old
[–] [email protected] 4 points 6 months ago* (last edited 6 months ago) (1 children)

On routers and modems the DHCP range is usually not allocating the full range for IP addresses to hand out to devices. If I were you I would configure the pi-hole to have a static IP address on the pi-hole itself so it will be independent from your router's DHCP server. For example let's say

  • the DHCP IP range is 192.168.1.20 to 192.168.1.254
  • then you can pick for example 192.168.1.19 for your pi-hole

With that approach you will avoid IP address conflicts and the pi-hole should be fine. If you're using systemd on the pi-hole that is maybe easiest, here an example :

Another option is to use nmtui from NetworkManager

[–] [email protected] 2 points 6 months ago (1 children)

Some routers also have the ability to give a device a static ip address, so that such conflicts should be avoided.

[–] [email protected] 1 points 6 months ago

The IP is reserved on the router, but it's still giving me gip.