1

When I curl an invalid domain, I get a response from my own webserver. Ubuntu 16.04.5, curl 7.47.0

For example:

root@l ~ # curl -v foobar.x
* Rebuilt URL to: foobar.x/
*   Trying 148.X.X.X...
* Connected to foobar.x (148.X.X.X) port 80 (#0)
> GET / HTTP/1.1

148.X.X.X is the public IP of my server.

However I get an expected result with nslookup + host:

root@l ~ # nslookup foobar.x
Server:         213.133.99.99
Address:        213.133.99.99#53

** server can't find foobar.x: NXDOMAIN

root@l ~ # host foobar.x
Host foobar.x not found: 3(NXDOMAIN)

/etc/resolv.conf:

root@l ~ # cat /etc/resolv.conf
### Hetzner Online GmbH installimage
# nameserver config
#nameserver 1.1.1.1
nameserver 213.133.99.99
nameserver 213.133.98.98
nameserver 213.133.100.100
nameserver 2a01:4f8:0:1::add:9898
nameserver 2a01:4f8:0:1::add:9999
nameserver 2a01:4f8:0:1::add:1010

So how does curl resolve hostnames and why does it default invalid ones to my own IP?

update

root@l /etc # telnet foobar.x 80
Trying 148.251.19.39...
Connected to foobar.x.sui.li.

Ok, it seems to somehow autocomplete my domain name. *.sui.li has a wildcard DNS entry. The hostname is l.sui.li - Still I have no idea how to prevent that.

  • Really weird. I've removed all /etc/resolv.conf entries and curl can't resolve anything. I add one nameserver like 1.1.1.1 or 8.8.8.8 and curl retrieves my own one again... – sui Feb 18 at 17:08
  • 1
    Did you set up a http proxy server in the environment? – Michael Hampton Feb 18 at 17:18
  • no proxy, nothing suspicious in env – sui Feb 18 at 17:30
  • it seems to autocomplete the domain, see updated question – sui Feb 18 at 17:43
  • In Windows, the DNS suffix search list feature will try adding the domain of the client (typically an Active Directory domain) to the end of the domain you are looking up. So let's say my local domain is example.local, When looking for example.com, my PC will try to resolve example.com.example.local first. And if that fails, it will try to resolve example.com. If I have a wildcard DNS entry in example.local, that will be the result of the lookup. I don't know if Ubuntu does something similar. For Windows, I would suggest looking for example.com. (note the final dot) instead. – Doug Deden Feb 18 at 21:03
0

Did not really find the cause why it adds my base domain (maybe because it's also the reverse dns entry for the host? idk and i don't care any more...) but ended up adding an invalid search nothing entry in /etc/resolv.conf. I assume it now tries to resolve foobar.x, foobar.x.nothing and fails as it's supposed to.

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

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