How do I get Pi-hole to return the server on which it's running's reserved & static 192.168.* IP address in response to a query for that server's hostname?

I have Pi-hole running on a Debian 10 server named DellOptiPlex390-1. Currently, when I run nslookup on DellOptiPlex390-1, I get:

○ → nslookup DellOptiPlex390-1
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   DellOptiPlex390-1
Address: 127.0.1.1

I'd like it to return 192.168.0.139 as the 1st result. I think this reply in Discourse might be helpful:

You can also map them in a dnsmasq configuration file in directory /etc/dnsmasq.d The advantage of mapping here is that this configuration file will be exported by the teleporter, while the /etc/hosts file will not be.

Currently DellOptiPlex390-1's /etc/hosts looks like this:

127.0.0.1       localhost
127.0.1.1       DellOptiPlex390-1.lan   DellOptiPlex390-1
# 192.168.0.139 DellOptiPlex390-1.lan   DellOptiPlex390-1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Questions:

1) Do I edit /etc/hosts to:

192.168.0.139 DellOptiPlex390-1.lan   DellOptiPlex390-1
127.0.0.1       localhost
127.0.1.1       DellOptiPlex390-1.lan   DellOptiPlex390-1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

OR

192.168.0.139 DellOptiPlex390-1.lan   DellOptiPlex390-1
127.0.0.1       localhost
# 127.0.1.1       DellOptiPlex390-1.lan   DellOptiPlex390-1

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

?

2) Exactly what do I put in the /etc/dnsmasq.d directory?

3) What do I restart to push the changes through, and what's the command do to so?

# pihole restartdns?

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