Whois request works with telnet but not netcat

I'm trying to write an advanced whois client, so I experimented with sending commands to whois servers using netcat (nc) on Arch Linux. For example, this works great:

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

However, a whois server that processes suffixes such as .br.com , whois.centralnic.net , and this server does not seem to work with netcat. When I give him any request, it just closes the connection without an answer:

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

I successfully executed the same request 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 can make a server behave differently for telnet than netcat?

I thought this was a time problem, so I tried unsuccessfully:

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

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

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

On my production system, I will not use netcat or telnet, but there seems to be some strange network problem here, and I would like to know about that. Can anyone shed some light on why netcat will work on all whois servers, but only telnet will work on whois.centralnic.net?

+4
source share
1 answer

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

This works (on Ubuntu, there are several versions of netcat, so it cannot speak for you)

 $ echo -e "foobar\r\n" | nc whois.centralnic.net 43 DOMAIN NOT FOUND 
+6
source

Source: https://habr.com/ru/post/1480314/


All Articles