Install pi hole, add static ip, when it reboots the ip changes back to dhcp

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

Expected Behaviour:

upon reboot I should be able to access the admin page with the ip I set ex. 192.168.1.4/admin

Actual Behaviour:

after I install and reboot, no access to static ip just created, ifconfig has the ip as 192.168.1.167/admin which is what my routers dhcp server gives it. I can access pi hole at this address.

Debug Token:

oydb8bctd8

1 Like

Your Pi-hole is trying to use 192.168.1.9, not .4. How are you statically setting the IP address?

I know, I used that as an example. Im using your installer on a clean, and updated install of ubuntu server just for the pi hole service to run on. Ive installed ubuntu from disk for this about 10 times and it does the same thing every time. Once the installer is done, it confirms my IP as .9, then when I reboot it doesnt work, but the address given by my router does, and it comes right up. In all honesty it works fine at that address but I wanted it out of my address pool.

By the way, I dont know if it matters or not, but It is running in a VM all of its own

What's in /etc/dhcpcd.conf?

1 Like

Its in there

And ifconfig or ip addr?

Here you go

Do you have anything in /etc/network/interfaces?

Here you go, I think I know what the issue is. The conf file is set to dhcp, but I dont know how thats possible, all I did was restart after it installed.

It wont let me set it to static...i reset the network and I get errors. any idea whats going on?

FYI I just recreated this on debian stretch. Same thing happens. Not sure if thats helpful or not.

Are you using NetworkManager to control your network settings?

I dont know. I dont think so. Heres what I did in both debian and ubuntu

  1. spun up a command line server from iso
  2. updated it to current
  3. installed pihole with the script on your main page
    4, Set the static ip in the installation process
  4. Rebooted and it picked up DHCP

Im not sure which service manages the network settings by default on the server versions

I am using proxmox for these VM's and I am just using the default network config from the gui, I switched the interface to an intel e1000, thats the only thing I changed from bone stock

You need to set the interface to "manual" in the "/etc/network/interfaces" file or else dhcpcd5 cant assign the static IP address configured in "/etc/dhcpcd.conf" to the interface.

Like so:

allow-hotplug ens18
iface ens18 inet manual
2 Likes

Ok, I did do that and all was well. I really appreciate you helping me fix it!

my /etc/network/interfaces had "auto" instead of "allow-hotplug", I dont know why, I never changed it

Thanks
MIke

2 Likes

The old way needed the "auto" directive to indicate you want the interface to be up at boot:

$ man interfaces

INTERFACES(5)                        File formats                       INTERFACES(5)

NAME
       /etc/network/interfaces - network interface configuration for ifup and ifdown

DESCRIPTION
       /etc/network/interfaces  contains  network interface configuration information
       for the ifup(8) and ifdown(8) commands.  This is where you configure how  your
       system is connected to the network.
[...]
INTERFACE SELECTION
       Lines beginning with the word "auto" are used to identify the physical  inter‐
       faces  to  be brought up when ifup is run with the -a option.  (This option is
       also used by the system boot scripts, so interfaces marked "auto" are  brought
       up  at  boot time.)  Physical interface names should follow the word "auto" on
       the same line.  There can be multiple "auto" stanzas.  ifup brings  the  named
       interfaces up in the order listed.

      Lines  beginning  with "allow-" are used to identify interfaces that should be
      brought up automatically by various subsytems. This may be done using  a  com‐
      mand  such  as "ifup --allow=hotplug eth0 eth1", which will only bring up eth0
      or eth1 if it is listed in an "allow-hotplug" line. Note that "allow-auto" and
      "auto"  are  synonyms.  (Interfaces marked "allow-hotplug" are brought up when
      udev detects them.  This can either be during boot if the interface is already
      present,  or at a later time, for example when plugging in a USB network card.
      Please note that this does not have anything to do with  detecting  a  network
      cable being plugged in.)

[...]

Now dhcpcd5 brings up the interface:

$ man dhcpcd5

DHCPCD(8)                    BSD System Manager's Manual                    DHCPCD(8)

NAME
     dhcpcd — a DHCP client

SYNOPSIS
     dhcpcd [-146ABbDdEGgHJKLMNPpqTV] [-C, --nohook hook] [-c, --script script]
            [-e, --env value] [-F, --fqdn FQDN] [-f, --config file]
            [-h, --hostname hostname] [-I, --clientid clientid]
            [-i, --vendorclassid vendorclassid] [-j, --logfile logfile]
            [-l, --leasetime seconds] [-m, --metric metric] [-O, --nooption option]
            [-o, --option option] [-Q, --require option] [-r, --request address]
            [-S, --static value] [-s, --inform address[/cidr]] [--inform6]
            [-t, --timeout seconds] [-u, --userclass class]
            [-v, --vendor code, value] [-W, --whitelist address[/cidr]] [-w]
            [--waitip [4 | 6]] [-y, --reboot seconds]
            [-X, --blacklist address[/cidr]] [-Z, --denyinterfaces pattern]
            [-z, --allowinterfaces pattern] [--inactive] [interface] [...]
     dhcpcd -n, --rebind [interface]
     dhcpcd -k, --release [interface]
     dhcpcd -U, --dumplease interface
     dhcpcd --version
     dhcpcd -x, --exit [interface]

DESCRIPTION
     dhcpcd is an implementation of the DHCP client specified in RFC 2131.  dhcpcd
     gets the host information (IP address, routes, etc) from a DHCP server and con‐
     figures the network interface of the machine on which it is running.  dhcpcd
     then runs the configuration script which writes DNS information to
     resolvconf(8), if available, otherwise directly to /etc/resolv.conf.  If the
     hostname is currently blank, (null) or localhost, or force_hostname is YES or
     TRUE or 1 then dhcpcd sets the hostname to the one supplied by the DHCP server.
     dhcpcd then daemonises and waits for the lease renewal time to lapse.  It will
     then attempt to renew its lease and reconfigure if the new lease changes when
     the lease beings to expire or the DHCP server sends message to renew early.
[...]
   Fine tuning
     You can fine-tune the behaviour of dhcpcd with the following options:

     -S, --static value
             Configures a static DHCP value.  If you set ip_address then dhcpcd will
             not attempt to obtain a lease and just use the value for the address
             with an infinite lease time.

             Here is an example which configures a static address, routes and dns.
                   dhcpcd -S ip_address=192.168.0.10/24 \
                   -S routers=192.168.0.1 \
                   -S domain_name_servers=192.168.0.1 \
                   eth0
[...]
FILES
     /etc/dhcpcd.conf
     Configuration file for dhcpcd.  If you always use the same options, put them
     here.
[...]

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