Contacting DNS server via command line interface

As you note, DNS primarily uses UDP but service is actually also provided over TCP (typically used for large responses and zone transfers).
This is why you managed to establish a connection in the first place when you tried telnet. Your connection was closed because you weren't interacting with the service in the expected way, not because telnet uses TCP.

The important difference is that, unlike HTTP and SMTP which are plain text protocols and easy enough to work with directly, DNS is a binary protocol.

This means that you will need some DNS client program to interact with nameservers in any reasonable fashion.

dig has been the de facto standard for DNS troubleshooting for a very long time as it is very good in terms of both constructing queries and in terms of pretty-printing all the information in the response in a concise way. (Part of BIND code-base and included in the Windows build from ISC.)

drill is another alternative with similar capabilities and essentially the same output formatting as dig.

nslookup is well known as it has been around since the dawn of time. It has been largely abandoned except on Windows and has some undesirable quirks and limited capabilities in comparison to the previously mentioned alternatives. The debug option (set debug) makes it usable for troubleshooting in a pinch as it greatly improves the completeness of the output, although the formatting of the debug output leaves a lot to be desired.


You can use the dig utility, like this:

dig @your.dns.server www.foo.bar

Example:

dig @8.8.8.8 www.google.com

If you want to see the step-by-step name resolution, you can do this:

dig +add +trace @8.8.8.8 www.google.com

Best regards!


For Windows you can use NSlookup

   nslookup [-opt ...]             # interactive mode using default server
   nslookup [-opt ...] - server    # interactive mode using 'server'
   nslookup [-opt ...] host        # just look up 'host' using default server
   nslookup [-opt ...] host server # just look up 'host' using 'server'