Pi set to static IP but uses DHCP instead (IP changes)

Please follow the below template, it will help us to help you!

Expected Behaviour:

I created a Pi-hole on a Raspberry PI running Raspbian Stretch Lite, and set a static IP of 10.0.10.10, works for about a week. Expectation is that 10.0.10.10 is always going to be the STATIC IP. My PFSense DHCP server provides this address to all DHCP requests.

Actual Behaviour:

After about a week, Raspbian Lite pulls a DHCP address of 10.0.10.104 (in my DHCP scope). The web gui for Pi-hole shows 10.0.10.10 as the IP address and when I SSH into the Raspberry Pi running Raspbian Lite, and run IP ADDR, it shows 10.0.10.104 as the ETH0 IP! Also, /etc/dhcpcd.conf shows the proper information of 10.0.10.10 for the ETH0 interface.
/etc/network/interfaces simply says:

"
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
"

I have run updates and upgrades, as well as pihole -up. I have also done numerous pihole -r attempts with reconfigure but still get the 10.0.10.104 address no matter how many times i tell the wizard I want 10.0.10.10. to be the static IP.

Help!

Debug Token:

7faj18gt5z

Where did you set this static IP - in the Pi OS or at the router DHCP? If the router has not reserved this IP for the Pi, it may get a new one at lease renewal.

This is consistent with a one-week lease period.

I set the 10.0.10.10 when I run the wizard during the Pi-hole configuration and whenever I do pihole -r reconfigure. It says "do you want to use 10.0.10.104/24" and i say hell no, and I change it to 10.0.10.10/24 and it never sticks!

Take a look at this thread. You need to make the IP address for the Pi static (or reserved) in your router, so the router will never give it a different address.

The warning in the setup process that your Pi needs to have a static IP so it isn't subject to change.

The Pi-hole is a SERVER so it needs a STATIC IP ADDRESS to function properly.

As someone who has been assigning static IP's to devices for 20 years, both personally and professionally, I am not understanding where I am failing to assign a static IP. I have specifically stated the static IP of 10.0.10.10 on Pi-Hole OS during configuration. I have never had to once configure my router to allow for this. I have a multitude of networks where I static IP devices outside of my DHCP range and they never ever pull a DHCP address, ever. Sorry if I'm coming off as obstinate but I'm truly confused about how this fixes my problem. If I make a reservation for it at 10.0.10.10 (outside of my DHCP scope), what's to stop it from requesting something inside the DHCP scope of 10.0.10.100 - .200?

1 Like

Personally, I was wondering why pihole needs a static IP address, if using the pihole v4 default blocking mode. All my devices have a MAC assigned DHCP address. This ensures that all devices always get the same IP address, but allow me to change the DHCP options network wide, or assign specific options for specific hosts from a central point of administration (pfsense in my environment).
What might work is:

  • copy dhcpcd.conf before installing pihole
  • install pihole -> dhcpcd.conf now becomes static
  • copy the original dhcpcd.conf over the one pihole wrote.

This would allow me to move the SD card between my production pi and my test pi's, Since they all have different MAC addresses, I know exactly which IP address to use to reach the different pi's.
Downside of course is you need to watch out for changes made by pihole -r.

I've been using IPv6check.sh to handle the IPv6 address change.

I would very much like to be the static address assignment, during pihole installation, optional.

I tried uploading some pictures and failed miserably, trying again...
So here's the Pi-hole GUI, shows .10.10:
piholegui1
But then IP ADDR when I SSH in:
piholessh1
So I run pihole -r and redo it, it wants to use 10.104:
piholessh2
I change it to .10.10:
piholessh3
Am I sure? Yup:
piholessh4
Confirmation page which is clearly a lie:
piholessh5
Then back to /etc/dhcpcd.conf shows .10.10:
piholessh6

BUT IP ADDR STILL SAYS .10.104!

Have you considered not assigning a static IP at the Pi, but setting the IP via a DHCP reservation on the router? That may bypass whatever is causing your problem.

Another option would be to set the Pi-Hole to listen to the 104 address, since that is what the device sets itself to.

sudo service dhcpcd status -l

cat /etc/network/interfaces

sudo grep 10.0.10.104 -R /etc/

?

I ran all three commands and here's the output...

sudo service dhcpcd status -l
● dhcpcd.service - dhcpcd on all interfaces
Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/dhcpcd.service.d
└─wait.conf
Active: active (running) since Fri 2018-09-28 20:17:23 UTC; 2 days ago
Process: 238 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=0/SUCCESS)
Main PID: 426 (dhcpcd)
CGroup: /system.slice/dhcpcd.service
└─426 /sbin/dhcpcd -q -w

Sep 28 20:17:15 raspberrypi dhcpcd[238]: eth0: hardware address 00:0c:29:0f:9a:80 claims 10.0.10.10
Sep 28 20:17:16 raspberrypi dhcpcd[238]: eth0: soliciting a DHCP lease
Sep 28 20:17:17 raspberrypi dhcpcd[238]: eth0: offered 10.0.10.104 from 10.0.10.1
Sep 28 20:17:17 raspberrypi dhcpcd[238]: eth0: probing address 10.0.10.104/24
Sep 28 20:17:22 raspberrypi dhcpcd[238]: eth0: using static address 10.0.10.104/24
Sep 28 20:17:22 raspberrypi dhcpcd[238]: eth0: adding route to 10.0.10.0/24
Sep 28 20:17:22 raspberrypi dhcpcd[238]: eth0: adding default route via 10.0.10.1
Sep 28 20:17:23 raspberrypi dhcpcd[238]: forked to background, child pid 426
Sep 28 20:17:23 raspberrypi systemd[1]: Started dhcpcd on all interfaces.
Sep 28 20:17:27 raspberrypi dhcpcd[426]: eth0: no IPv6 Routers available
Warning: dhcpcd.service changed on disk. Run 'systemctl daemon-reload' to reload units.

cat /etc/network/interfaces
interfaces(5) file used by ifup(8) and ifdown(8)

Please note that this file is written to be used with dhcpcd
For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

sudo grep 10.0.10.104 -R /etc/
grep: /etc/systemd/system/bluetooth.target.wants/bthelper.service: No such file or directory

Why the heck is it asking for a DHCP address when I told it to use a static one? Now, if I were running the GUI version I would just go in and disable that Network Profile and create a new one. The problem I have is that I'm running the LITE version and don't know exactly how to do this.

Yeah seems like it still gets its address through DHCP.
Can you post all settings in that dhcpcd.conf file ?

grep -v '#\|^$' /etc/dhcpcd.conf

Any files with settings in that /etc/network/interfaces.d folder ?

sudo grep -v '#\|^$' -R /etc/network/interfaces.d/

Here are my settings on a Pi with latest Stretch lite for comparison:

pi@noads:~ $ hostnamectl
   Static hostname: noads.dehakkelaar.nl
         Icon name: computer
        Machine ID: 90799a2dc75240ebaaf6bbcd4e7d6a13
           Boot ID: 40ca1e9e6dfa4f8e85f8f51389b42208
  Operating System: Raspbian GNU/Linux 9 (stretch)
            Kernel: Linux 4.14.52-v7+
      Architecture: arm

pi@noads:~ $ sudo grep -v '#\|^$' -R /etc/network/interfaces*
/etc/network/interfaces:source-directory /etc/network/interfaces.d
/etc/network/interfaces.dpkg-old:source-directory /etc/network/interfaces.d

pi@noads:~ $ grep -v '#\|^$' /etc/dhcpcd.conf
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
option interface_mtu
require dhcp_server_identifier
slaac private
interface eth0
    static ip_address=10.0.0.2/24
    static routers=10.0.0.1
    static domain_name_servers=127.0.0.1

Thanks for this. I'll get back to this thread over the weekend.

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