DHCP server gives out wrong IP for DNS

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

Expected Behaviour:

Client receives IP address of Pi-hole server's eth1 interface as DNS server via DHCP.

Actual Behaviour:

Client receives IP address of Pi-hole server's eth0 interface as DNS server via DHCP, even though Pi-hole appears to be configured to issue the eth1 interface address.

Debug Token:

pecv95zftv

On Pi-Hole:

$ cat setupVars.conf
WEBPASSWORD=xxx
WEBUIBOXEDLAYOUT=traditional
TEMPERATUREUNIT=F
PIHOLE_INTERFACE=eth1
IPV4_ADDRESS=192.168.1.105/24
IPV6_ADDRESS=
QUERY_LOGGING=true
INSTALL_WEB=true
LIGHTTPD_ENABLED=1
DNSMASQ_LISTENING=all
PIHOLE_DNS_1=8.8.8.8
PIHOLE_DNS_2=8.8.4.4
PIHOLE_DNS_3=2001:4860:4860:0:0:0:0:8888
PIHOLE_DNS_4=2001:4860:4860:0:0:0:0:8844
PIHOLE_DNS_5=208.67.222.222
PIHOLE_DNS_6=208.67.220.220
PIHOLE_DNS_7=2620:0:ccc::2
PIHOLE_DNS_8=2620:0:ccd::2
DNS_FQDN_REQUIRED=true
DNS_BOGUS_PRIV=true
DNSSEC=false
DHCP_ACTIVE=true
DHCP_START=192.168.1.2
DHCP_END=192.168.1.254
DHCP_ROUTER=192.168.1.1
DHCP_LEASETIME=1
PIHOLE_DOMAIN=local
DHCP_IPv6=false

$ ifconfig eth0
eth0      Link encap:Ethernet  HWaddr b8:27:eb:xx:xx:xx  
          inet addr:192.168.1.147  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: xxxx/64 Scope:Link
          inet6 addr: xxxx/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:66992 errors:0 dropped:7 overruns:0 frame:0
          TX packets:14531 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:27223283 (25.9 MiB)  TX bytes:3491163 (3.3 MiB)

$ ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 70:88:6b:xx:xx:xx  
          inet addr:192.168.1.105  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: xxxx/64 Scope:Global
          inet6 addr: xxxx/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:6970 errors:0 dropped:7 overruns:0 frame:0
          TX packets:1790 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2181922 (2.0 MiB)  TX bytes:192255 (187.7 KiB)

On OSX client:

$ cat /etc/resolv.conf
#
# macOS Notice
#
# This file is not consulted for DNS hostname resolution, address
# resolution, or the DNS query routing mechanism used by most
# processes on this system.
#
# To view the DNS configuration used by this system, use:
#   scutil --dns
#
# SEE ALSO
#   dns-sd(1), scutil(8)
#
# This file is automatically generated.
#
search site.example.com
nameserver 2601:xxx:xxx:xxx:xxx:xxx:xxx:xxxx
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844
nameserver 192.168.1.147

What does

scutil --dns

report on your macOS client?

Output is:

MacBook-Air-Steve-WiFi:~ stevej$ scutil --dns
DNS configuration

resolver #1
  search domain[0] : site.example.com
  nameserver[0] : 2601:xxxxxxxxxxxxxxx
  nameserver[1] : 2001:4860:4860::8888
  nameserver[2] : 2001:4860:4860::8844
  nameserver[3] : 192.168.1.147
  if_index : 5 (en0)
  flags    : Request A records, Request AAAA records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)

resolver #2
  domain   : local
  options  : mdns
  timeout  : 5
  flags    : Request A records, Request AAAA records
  reach    : 0x00000000 (Not Reachable)
  order    : 300000

resolver #3
  domain   : 254.169.in-addr.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records, Request AAAA records
  reach    : 0x00000000 (Not Reachable)
  order    : 300200

resolver #4
  domain   : 8.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records, Request AAAA records
  reach    : 0x00000000 (Not Reachable)
  order    : 300400

resolver #5
  domain   : 9.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records, Request AAAA records
  reach    : 0x00000000 (Not Reachable)
  order    : 300600

resolver #6
  domain   : a.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records, Request AAAA records
  reach    : 0x00000000 (Not Reachable)
  order    : 300800

resolver #7
  domain   : b.e.f.ip6.arpa
  options  : mdns
  timeout  : 5
  flags    : Request A records, Request AAAA records
  reach    : 0x00000000 (Not Reachable)
  order    : 301000

DNS configuration (for scoped queries)

resolver #1
  search domain[0] : site.example.com
  nameserver[0] : 2601:xxxxxx
  nameserver[1] : 2001:4860:4860::8888
  nameserver[2] : 2001:4860:4860::8844
  nameserver[3] : 192.168.1.147
  if_index : 5 (en0)
  flags    : Scoped, Request A records, Request AAAA records
  reach    : 0x00020002 (Reachable,Directly Reachable Address)

Also, I reran repair and rebooted for good measure. No change -- except the RPI picked up a new dynamic IP this time on eth0... which shouldn't matter if the eth1 were being issued as the DNS server to clients.

Hmm very perplexing...Have you flushed your Mac's DNS cache?

Please send us the token generated by

pihole -d

or do it through the Web interface:

To keep things a bit more stable while tinkering with this, I just set a DHCP reservation for eth0. So now what I WANT is eth1/192.168.1.105. What I don't want (but what is getting handed out) is eth0/192.168.1.104).

Just tried a pihole -r and chose reconfigure. Noticed something interesting. When it asks if I want to use the "current IP" as the static IP, it shows the .104 address I don't want. I suppose it just looks for the first valid IP address that would be shown by ifconfig, which is .104. But even when I manually override it, and I get the correct .105 address in the installation success message:

 You may now configure your devices to use the Pi-hole as their DNS server
  [i] Pi-hole DNS (IPv4): 192.168.1.105
  [i] Pi-hole DNS (IPv6): 2601:xxxxxxxxx
  If you set a new IP address, please restart the server running the Pi-hole

  [i] The install log is located at: /etc/pihole/install.log
  Installation Complete! 

DHCP is still giving out the wrong IP to clients. Unplugging eth0 is the only way to make it work properly, so that's what I've done. But I shouldn't have to do that. :slight_smile:

Also, it's not just the Mac. Every DHCP client is picking up the "wrong" IP.

That token up top was generated prior to me unplugging eth0, so that's going to be the most useful for you. I can plug it back in and tinker more if needed.

Try making a new dnsmasq config under /etc/dnsmasq.d/ with this content:

dhcp-option=6,192.168.1.105
1 Like

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