FYI, for the forward lookup directive server= (name to IP):
$ man dnsmasq
[..]
-S, --local, --server=[/[<domain>]/[doā
main/]][<ipaddr>[#<port>]][@<interface>][@<source-
ip>[#<port>]]
Specify IP address of upstream servers directly. Setā
ting this flag does not suppress reading of /etc/reā
solv.conf, use --no-resolv to do that. If one or more
optional domains are given, that server is used only
for those domains and they are queried only using the
specified server. This is intended for private nameā
servers: if you have a nameserver on your network
which deals with names of the form xxx.interā
nal.thekelleys.org.uk at 192.168.1.1 then giving the
flag --server=/internal.thekelleys.org.uk/192.168.1.1
will send all queries for internal machines to that
nameserver, everything else will go to the servers in
/etc/resolv.conf. DNSSEC validation is turned off for
such private nameservers, UNLESS a --trust-anchor is
specified for the domain in question. An empty domain
specification, // has the special meaning of "unqualiā
fied names only" ie names without any dots in them. A
non-standard port may be specified as part of the IP
address using a # character. More than one --server
flag is allowed, with repeated domain or ipaddr parts
as required.
More specific domains take precedence over less speā
cific domains, so: --server=/google.com/1.2.3.4
--server=/www.google.com/2.3.4.5 will send queries for
*.google.com to 1.2.3.4, except *www.google.com, which
will go to 2.3.4.5
The special server address '#' means, "use the stanā
dard servers", so --server=/google.com/1.2.3.4
--server=/www.google.com/# will send queries for
*.google.com to 1.2.3.4, except *www.google.com which
will be forwarded as usual.
Also permitted is a -S flag which gives a domain but
no IP address; this tells dnsmasq that a domain is loā
cal and it may answer queries from /etc/hosts or DHCP
but should never forward queries on that domain to any
upstream servers. --local is a synonym for --server
to make configuration files clearer in this case.
IPv6 addresses may include an %interface scope-id, eg
fe80::202:a412:4512:7bbf%eth0.
The optional string after the @ character tells dnsā
masq how to set the source of the queries to this
nameserver. It can either be an ip-address, an interā
face name or both. The ip-address should belong to the
machine on which dnsmasq is running, otherwise this
server line will be logged and then ignored. If an inā
terface name is given, then queries to the server will
be forced via that interface; if an ip-address is
given then the source address of the queries will be
set to that address; and if both are given then a comā
bination of ip-address and interface name will be used
to steer requests to the server. The query-port flag
is ignored for any servers which have a source address
specified but the port may be specified directly as
part of the source address. Forcing queries to an inā
terface is not implemented on all platforms supported
by dnsmasq.
Reverse lookups rev-server= (IP to name):
$ man dnsmasq
[..]
--rev-server=<ip-address>/<prefix-
len>[,<ipaddr>][#<port>][@<interface>][@<source-ip>[#<port>]]
This is functionally the same as --server, but proā
vides some syntactic sugar to make specifying address-
to-name queries easier. For example --rev-
server=1.2.3.0/24,192.168.0.1 is exactly equivalent to
--server=/3.2.1.in-addr.arpa/192.168.0.1
For reference:
To tail the Pi-hole logs live to see whats forwarder to whom:
pihole -t
You can use the nslookup tool on a client in a particular segment for diagnosing.
Eg a forward lookup which will append the search/suffix domain to the query:
nslookup <SHORT_HOSTNAME>
Or specify the DNS server to query:
nslookup <SHORT_HOSTNAME> <DNS_SERVER_IP>
For a reverse lookup:
nslookup <IP_ADDRESS>
nslookup <IP_ADDRESS> <DNS_SERVER_IP>
Eg:
C:\>nslookup hakpc
Server: pi.hole
Address: 10.0.0.4
Name: hakpc.home.dehakkelaar.nl
Address: 10.0.0.11
C:\>nslookup 10.0.0.11
Server: pi.hole
Address: 10.0.0.4
Name: hakpc.home.dehakkelaar.nl
Address: 10.0.0.11
$ pihole -t
[..]
10:05:56: query[A] hakpc.home.dehakkelaar.nl from 10.0.0.11
10:05:56: forwarded hakpc.home.dehakkelaar.nl to 10.0.0.2
10:05:56: reply hakpc.home.dehakkelaar.nl is 10.0.0.11
[..]
10:10:42: query[PTR] 11.0.0.10.in-addr.arpa from 10.0.0.11
10:10:42: forwarded 11.0.0.10.in-addr.arpa to 10.0.0.2
10:10:42: reply 10.0.0.11 is hakpc.home.dehakkelaar.nl
$ cat /etc/dnsmasq.d/01-pihole.conf
[..]
rev-server=10.0.0.0/24,10.0.0.2
server=/home.dehakkelaar.nl/10.0.0.2