Losing IP if remove eth0 cable or modem restart

Expected Behaviour:

Dont lose eth0 IP on cable disconnect/reconnect

Actual Behaviour:

If I remove the network cable, or restart the modem, the interface loses the ip and no longer obtains an IP, it only resolves by restarting Linux. I think the pihole does not enable the auto flag in eth0?

Debug Token:

https://tricorder.pi-hole.net/lrpbmvwklx


*** [ DIAGNOSING ]: Networking
[✓] IPv4 address(es) bound to the enp1s0 interface:
   192.168.0.222/24 matches the IP found in /etc/pihole/setupVars.conf
   192.168.0.44/24 does not match the IP found in /etc/pihole/setupVars.conf

Did you configure a static IP an your device hosting Pi-hole? Or a static IP assignment on your router for your Pi-hole device?

The dhcp of my modem was sending the ip 192.168.0.44 to pihole and the LAN interface was getting 2 ips, i change the DHCP reserved IP on modem to 192.168.0.222 and now there is only one ip on the interface, but the cable disconnect and losing IP issue is the same.

*** [ DIAGNOSING ]: Networking
[✓] IPv4 address(es) bound to the enp1s0 interface:
192.168.0.222/24 matches the IP found in /etc/pihole/setupVars.conf

The new log:

https://tricorder.pi-hole.net/lrpbmvwklx

I think I can't follow you.

You device is configured to get an IP via DHCP and your router has reserved IP for that device. If you unplug the cable from your device it looses the connection and therefore looses the assigned IP. If you re-plug the cable it should get the same IP as before via DHCP.

If you don't want to "loose" the IP during the disconnect (but there is no physical connection anyway) you need to configure a static IP on the device itself

I dont know why pihole try to get a dhcp IP, there is a static ip set on: /etc/pihole/setupVars.conf

PIHOLE_INTERFACE=enp1s0

IPV4_ADDRESS=192.168.0.222/24

Because you confuse Pi-hole with your underlying OS (Debian 9). You need to set the interface on the OS level

https://wiki.debian.org/NetworkConfiguration

I read somewhere around here that I shouldn't make manual changes to the ip configuration files ... could you tell me in which file should I insert this information? because I already tried the file / etc / network / interfaces

but it does not auto assign IP after disconnection.

In Debian, this is in /etc/dhcpcd.conf

There will be an entry similar to this for each interface. In this case, the ethernet interface on this device is eth0, the static IP is 160, and the device is using Pi-hole for DNS resolution on the loopback interface.

interface eth0
        static ip_address=192.168.0.160/24
        static routers=192.168.0.1
        static domain_name_servers=127.0.0.1

apparently my dhcpcd.conf is correct ..., maybe I need to add an "auto" after the interfafe?

Screenshot-20210511-233024-Termux

Restart the Pi-hole host and run another debug log and look in the section near the top where Pi-hole checks your DHCP server. You will see that your DHCP server (the router) is offering the Pi the correct address, which matches the IP for which you have Pi-hole configured.

But, your router is also passing a second DNS server to clients, and that server is not the Pi-hole. That will allow some DNS traffic to bypass Pi-hole.

      dns-server: 192.168.0.222
      dns-server: 45.90.30.67

I put this DNS2 intentionally, because if the Pi-Hole turns off for some reason, my users access the secondary dns that is from NextDns.io, which actually does all the filtering, I'm using the pi-hole just to have a fast cache on the local network.

My cenario:

DHCP on Internet Modem:
DNS 1: pihole-IP
DNS: NEXT_DNS1 (with a lot of rules)

DNSs Configured on Pi-Hole:
DNS1: NEXT_DNS1
DNS2: NEXT_DNS2

Always go to NEXTDNS! :slightly_smiling_face:

The advantage of this configuration is that if pihole stop, my devices dont stop, and i can turn off pi-hole at night to save energy :wink:

How much energy are you saving powering off a Pi for 8 hours a day? If you are running a Pi-hole, you should be running it 24/7.

And completely bypass Pi-hole when it is working. I'm guessing you didn't bother to read the FAQ I linked?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.