0

I have a domain that points to the external IP of my webserver. I set up a Pi-Hole server and changed my network settings to use it, and I've verified it is working. I want to redirect the URL of my webserver, which points to the external IP, to the internal IP of the webserver.

I used the command

sudo pihole -a hostrecord example.com 192.168.0.12

to redirect the domain to the IP. But when I try to connect to it through ping, nslookup, and using a browser it goes to the external IP.

I then did the command again, but this time with the domain misspelled.

sudo pihole -a hostrecord eexample.com 192.168.0.12

This time it worked and visiting eexample.com worked as expected and it was redirected to the correct IP.

I've cleared my computer's DNS cache and Pi-Hole's. Also, when I visited the correct domain on my phone (connected to the network and had mobile data turned off), which had never connected to the site before, it worked as expected.

What's going on?

closed as off-topic by slm Jul 17 '18 at 4:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – slm
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Are you doing a upstream DNS server configuration and is the DNS in question also externally resolvable on the internet? If so it' the upstream that's serving your request for example.com, not the local definition. – slm Jul 8 '18 at 2:14
0

I'm not sure what your issue is with that approach, I suspect you're falling prey to this issue titled: Add host-record option #1266. NOTE: This feature seems to make little sense, since it only appears to allow for a single host-record entry.

But I'd just add the host-record entry that you want directly into dnsmasq's /etc/dnsmasq.d/01-pihole.conf config file, and by-pass Pi-Hole's odd feature implementation.

Simply add lines like so:

host-record=google.com,192.168.0.12

Example

Here I overrode www.google.com like so:

$ cat /etc/dnsmasq.d/01-pihole.conf
host-record=www.google.com,192.168.1.107

and then restart:

$ pihole restartdns
  [✓] Restarting DNS service
$

And confirm:

$ dig +short www.google.com
192.168.1.107

Something more permanent

If you're concerned about editing the 01-pihole.conf file you can create your own set of files under /etc/dnsmasq.d to do whatever you want, without having them being impacted by updates to Pi-Hole. You could also use 03-pihole-wildcard.conf, I do not believe this file will get impacted via updates.

I do something similar for my LAN so I can override things:

$ cat /etc/dnsmasq.d/03-pihole-wildcard.conf
address=/babycam.mydomain.com/192.168.2.1
address=/www.yahoo.com/192.168.2.10

Then do the pihole restartdns like above and confirm:

$ pihole restartdns
  [✓] Restarting DNS service

$ dig +short www.yahoo.com
192.168.2.10

References

  • The redirect is working and I can visit the URL on my phone and other computers that haven't visited the site before and each one is redirected to the correct IP. But it isn't working on my Windows computers that have visited , they think the URL is still pointing to the real IP of the domain and not the one that Dnsmasq is redirecting. What's going on? Why can't Windows get the new IP from the server? I've cleared the DNS cache on my computers. – Thunder-Chaser Jul 16 '18 at 20:23
0

Avast Antivirus has a feature called "Real Site" where they silently force your computer to use their DNS servers to protect you against DNS hijacking. This overrides any custom DNS servers you have.

Disabling this fixed this. Go to Protection -> Real Site and disable it "Indefinitely".

  • Ugh what a waste of time for a stupid feature. I'm tempted to delete this since it has nothing to do with Unix/Linux at this point. – slm Jul 17 '18 at 4:25
  • Please leave it for future people who have the same issue. There is no reason to delete it. – Thunder-Chaser Jul 20 '18 at 14:34
  • I was saying that more our of frustration, b/c your actual problem had nothing really to do w/ Unix and was a windows AV issue. I won't delete it. – slm Jul 20 '18 at 14:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.