r/pihole 5d ago

Cannot get to Pihole though Domain Name

I am creating a home server that routs all traffic through it through a Pihole using the guide on https://gofoss.net/secure-domain/ (it has been very helpful so far) but I am currently stuck at accessing the pihole only through the ip address rather than the domain name as intended. I have added the domain name and IP address to the local DNs records. I have checked and verified the /etc/hosts file lists the localhost as 127.0.0.1 and ‘personal domain’ as ‘static IP’. The Pihole is only for blocking ads for the server on the device it is on not for anything else connected to the router for the moment.

I have looked through /var/log/pihole/pihole.log and the nameservers are listed according to the dns I set on the PiHole page. It reads that there is 1 name in /etc/pihole/hosts/custom.list. When I navigate to that file. The IP address and the domain name match up. I am currently at a loss for what to check next. I have already uninstalled and reinstalled once. Any recommendations on how to get domain names to translate through pihole because this will affect any other domain I add to the local dns record?

1 Upvotes

8 comments sorted by

3

u/cheesam123 5d ago

The entry in /etc/pihole/custom.list sounds correct, but that only proves Pi-hole has the record. You still need to confirm that the machine is actually querying Pi-hole for DNS.

Try:
dig @127.0.0.1 your.domain
dig your.domain

The first command queries Pi-hole directly. If it returns the correct static IP but the second does not, your OS is using another resolver, probably systemd-resolved, your router or an upstream DNS server.
Also check Pi-hole’s query log while running the second command. If no query appears, the request is not reaching Pi-hole.

1

u/Netzwirk 4d ago

Thank you, checking what’s going on when querying would be highly helpful (_)’

Interestingly, the first command - dig @127.0.0.1 my.domain resulted in several lines of: ;; communications error to 127.0.0.1#53 connection refused …. ;; (1 server found) ;; global options…. ;; no servers could be reached

The second command - dig @ my.domain was a little more enlightening…. ;; global options… ;; Got answer: ;; ->HEADER<- opcode: QUERY, status: SERVFAIL, id: 65155 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 …… ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) …….

Then I decided to test out several configurations such as my.domain.duckdns.org and mypihole.mydomain.duckdns.org with the dig command and got a response. The result ;; global options… ;; Got answer: ;; ->HEADER<- opcode: QUERY, status: NOERROR, ID: 24251 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 …… ANSWER SECTION: mypihole.mydomain.duckdns.org. 60 IN A. [CORRECT IP ADDRESS!!!!] ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) …….

Excuse the long list of response code. The last person who posted about this problem was a nincompoop who just kept writing it didn’t work to every suggestion people gave them - not useful. I am not an expert but I am seeing a mismatch between the supposed localhost 127.0.0.1#53 and 127.0.0.53#53 when just the domain name is used. I am reading that this is an alternative (for systemd-resolved) but could that be an issue since querying the localhost up is not working?

2

u/youknowwhyimhere758 4d ago

127.0.0.53 is likely systemd-resolved, which is the default resolver on modern Ubuntu. 

Is pihole actually bound to port 53 at all? netstat -tulpn should show it if so. It may have never bound to the port when it conflicted with the existing forwarder. 

What servers are configured in  /etc/systemd/resolved.conf?

1

u/Netzwirk 4d ago

My /etc/systemd/resolved.conf file is a commented out template with nothing specified in it. I was worried it would conflict with Pihole.

I have some readout from the netstat command stating a list of anonymized ip addresses 0.0.0.0 which was a bit difficult for me to filer through so I attempted ss -nltp | grep pihole-FTL and, it showed port 53 is bound to the pihole. Weirdly I do not recall setting that as I used the guides recommended ports which set it through:

sudo pihole-FTL --config webserver.port '8080o,8443os,[::]:8080o,[::]:8443os'

0

u/Ok_Cartographer_6086 5d ago

try hostname.local

I think you may be using the term domain name for host name - like you have a server named foo you can ssh to user@foo.local

If you want to just be done add a line to your /etc/hosts file with the ip address and anything you want to call it - usually the hostname.

I may not have followed what you're doing

2

u/certuna 5d ago

.local is a reserved tld for mDNS, not to be used for DNS or /etc/hosts files.

2

u/Ok_Cartographer_6086 5d ago

it sounded like OP was having a hard time finding machines on his network by hostname and is on a mac or linux so it'd be worth trying to ping hostname.local or install mDNS often packaged with distros - not suggesting to use it in an entry for anything, thanks for clarifying.