Whois query works with telnet but not netcat
Asked Answered
S

1

6

I am trying to write an advanced whois client, so I have been experimenting with sending commands to whois servers using netcat (nc) in Arch Linux. For example, this works great:

$ echo domain google.com | nc whois.crsnic.net 43
# => nc outputs whois data for google.com

However, the whois server that handles suffixes like .br.com is whois.centralnic.net and that server seems to not work with netcat. When I give it any query, it seems to simply close the connection without a response:

$ echo foobar | nc whois.centralnic.net 43
# => No output from nc.

I successfully made the same query using telnet:

$ telnet whois.centralnic.net 43
Trying 193.105.170.136...
Connected to whois.centralnic.net.
Escape character is '^]'.
foobar
DOMAIN NOT FOUND
Connection closed by foreign host.

So what could possibly make a server behave differently for telnet than netcat?

I thought maybe it was a timing issue, so I unsuccessfully tried:

$ { sleep 4; echo foobar; sleep 4; } | nc whois.centralnic.net 43
# => No output from nc.

I saw that netcat has a -T option to make it behave more like telnet, so I unsuccessfully tried:

$ { sleep 4; echo foobar; sleep 4; } | nc -T whois.centralnic.net 43
# => No output from nc.

In my production system I will not be using netcat or telnet, but there seems to be some strange networking issue happening here and I would like to be aware of it. Can anyone shed some light on why netcat would work for all the whois servers but only telnet will work for whois.centralnic.net?

Scherzo answered 12/5, 2013 at 6:19 Comment(0)
H
8

The service expects CRLF in its request, not just LF;

This works (on Ubuntu, there are multiple netcat versions, so can't speak for yours)

$ echo -e "foobar\r\n" | nc whois.centralnic.net 43
DOMAIN NOT FOUND
Honor answered 12/5, 2013 at 6:49 Comment(2)
Note: some WHOIS servers can be a bit slow to respond, toss in a 1 second delay with nc -i 1 $hostname 43Adriaadriaens
This is specified in RFC3912.Tye

© 2022 - 2024 — McMap. All rights reserved.