Curl Lynx DNS – Strange Issue with Non-Resolving Domains

curldnslynx

I have a weird issue on my server in that if I use curl or lynx to try and access a
URL that doesn't exist (say a non registered domain, or a domain
that's not in DNS), I don't get an error, it instead delivers me to the
default locally hosted website.

For example:

"lynx http://jksodf89s9df9sudfisdf.com"
or "curl http://jksodf89s9df9sudfisdf.com"

Both of these should clearly return an error (404, "Can't resolve", or
something similar I'm guessing) as they don't exist – but instead I
get the Apache holding page that is currently set as my
default website for Apache on the server.

I can only assume it's a DNS or Apache config issue, but I just can't
see what would allow non existant domains to be redirected to
localhost.

Best Answer

I think you're having the same issue as posted here:

https://serverfault.com/questions/296602/dns-wildcard-and-etc-resolv-conf-problem

Appending a dot to your fqdn queries should work around the issue:
curl http://jksodf89s9df9sudfisdf.com.

Or, if you don't rely on the wildcard DNS entry, just replace it by specific DNS entries for your subdomains (that's the better solution imo).

Related Question