Sponsored Content
Full Discussion: Telnet vs netcat behavior
Top Forums UNIX for Advanced & Expert Users Telnet vs netcat behavior Post 302910336 by ckmehta on Wednesday 23rd of July 2014 04:27:22 PM
Old 07-23-2014
Telnet vs netcat behavior

Currently I run a number of network tests using netcat that checks for an open port on a remote IP-address, using this syntax:
Code:
netcat -v -w 5 -z 107.249.95.5 4488

For some reason, the netcat command above is hanging (although others work fine), but a telnet is showing a valid connection like below:
Code:
%  telnet 107.249.95.5 4488
Trying 107.249.95.5...
Connected to 107.249.95.5.
Escape character is '^]'.
^]

Normally with my other netcat tests, I see an immediate result like this:
aaaa.XXX.com [102.19.5.62] 22 (ssh) open
aaaa.XXX.com [102.19.5.62] 23 (telnet): Connection timed out

The only thing different/interesting about the 107.249.95.5 address is that it is over a VPN to an MQ server.

Any idea why this network test is failing, even though its obviously connectable over telnet. If it matters, I am running this on a Solaris 10 box.

Last edited by ckmehta; 07-23-2014 at 05:32 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Telnet behavior

Hi there, I've an stupid question. If I make a telnet to a server from my computer and then execute a command that starts an application (on the server), when I disconnect, the application stops running, which is pretty obvious. Is it possible to add a flag at the end of the command so when I cut... (4 Replies)
Discussion started by: piltrafa
4 Replies

2. Programming

netcat like file transfer

Hi Folks I am not a c programmer .But i need help in writing a program which can do this any ideas on how to go about it . i start a server on the target server where files need to be copied start-server -port 5006 & ---start the server and listen it on a partcular port on the source... (2 Replies)
Discussion started by: linuxdba
2 Replies

3. UNIX for Advanced & Expert Users

Netcat with Authentication?

I'd like to do a data transfer without encryption but with a guarantee that my data comes from a legit source. I'm thinking something that uses a public key scheme to sign the data. Does anyone know of something like that? Thanks! -Pileofrogs (1 Reply)
Discussion started by: pileofrogs
1 Replies

4. Shell Programming and Scripting

netcat

Is there a way how to react on the message a client sent to the server? I would like as the client sent message to server: "get information such and such" and server would answer. Thank you for reply! (6 Replies)
Discussion started by: MartyIX
6 Replies

5. Solaris

Please help me to install netcat on solaris

hello guys, i want to install netcat on my solaris. after i tar and gunzip netcat i'm confuse what do i must to do ? please help me to install netcat on my solaris. I'm beginner :( (2 Replies)
Discussion started by: praset
2 Replies

6. Linux

Thank you radoulov for your help on netcat command (nc -lp)

Hello, Thank you very much for the line nc -lp <port> . I tried to run simple chat session with nc as it's shown in catonmatDOTorg but failed miserably with that syntax inspite of opening port 7777 by iptables . But your command example is working nicely. So a bagful of thanks :)) Only one... (0 Replies)
Discussion started by: vectrum
0 Replies

7. Shell Programming and Scripting

Post using nc(netcat)

Hi; I have a url like http://localhost:8080/examples/jsp/dates/nextPageToPost.jsp?name=ajay&password=pas&sex=Male&check=on&nationality=USA&description=aa&submit=submit in which i want to use nc for http post for parameters like "name","password"....etc can neone please help me how to do that... (3 Replies)
Discussion started by: ajaypadvi
3 Replies

8. IP Networking

Help with Netcat

Hi all, I know my question is regarding Windows and not Linux, but I simply need people who know Netcat pretty well and I'm guessing here is a good place for that. So on with my question. I'm doing some research, and I was playing around with netcat on a WinXP VM but I can't seem to get... (0 Replies)
Discussion started by: MrCrumbs
0 Replies

9. Shell Programming and Scripting

Connect to Windows from Linux using NetCat

Hi Need help to connect from Ubuntu to Windows using NetCat nc I can not get my script to send new-line Her is what I have tried(sleep 2 ; echo user ; sleep 1; echo pass; sleep 2; echo netstat) | nc -t 10.10.10.34 23 gives this outputÿý%ÿûÿûÿý'ÿýÿýÿûWelcome to Microsoft Telnet Service ... (1 Reply)
Discussion started by: Jotne
1 Replies

10. Emergency UNIX and Linux Support

Netcat ( nc -l ) as webserver

Dear Linux guru's I am trying to create a webserver using nc (netcat only) on RHEL 7.2 running on bash shell. now the easy thing is to get nc listing to a port and respond back $ while true; do { echo -e 'HTTP/1.0 200 OK\r\n'; set; } | nc -l 7877; done This when called from a... (3 Replies)
Discussion started by: chakrapani
3 Replies
NC(1)							      General Commands Manual							     NC(1)

NAME
nc - TCP/IP swiss army knife SYNOPSIS
nc [-options] hostname port[s] [ports] ... nc -l -p port [-options] [hostname] [port] DESCRIPTION
netcat is a simple unix utility which reads and writes data across network connections, using TCP or UDP protocol. It is designed to be a reliable "back-end" tool that can be used directly or easily driven by other programs and scripts. At the same time, it is a feature-rich network debugging and exploration tool, since it can create almost any kind of connection you would need and has several interesting built- in capabilities. Netcat, or "nc" as the actual program is named, should have been supplied long ago as another one of those cryptic but standard Unix tools. In the simplest usage, "nc host port" creates a TCP connection to the given port on the given target host. Your standard input is then sent to the host, and anything that comes back across the connection is sent to your standard output. This continues indefinitely, until the network side of the connection shuts down. Note that this behavior is different from most other applications which shut everything down and exit after an end-of-file on the standard input. Netcat can also function as a server, by listening for inbound connections on arbitrary ports and then doing the same reading and writing. With minor limitations, netcat doesn't really care if it runs in "client" or "server" mode -- it still shovels data back and forth until there isn't any more left. In either mode, shutdown can be forced after a configurable time of inactivity on the network side. And it can do this via UDP too, so netcat is possibly the "udp telnet-like" application you always wanted for testing your UDP-mode servers. UDP, as the "U" implies, gives less reliable data transmission than TCP connections and some systems may have trouble sending large amounts of data that way, but it's still a useful capability to have. You may be asking "why not just use telnet to connect to arbitrary ports?" Valid question, and here are some reasons. Telnet has the "standard input EOF" problem, so one must introduce calculated delays in driving scripts to allow network output to finish. This is the main reason netcat stays running until the *network* side closes. Telnet also will not transfer arbitrary binary data, because certain characters are interpreted as telnet options and are thus removed from the data stream. Telnet also emits some of its diagnostic messages to standard output, where netcat keeps such things religiously separated from its *output* and will never modify any of the real data in transit unless you *really* want it to. And of course telnet is incapable of listening for inbound connections, or using UDP instead. Netcat doesn't have any of these limitations, is much smaller and faster than telnet, and has many other advantages. OPTIONS
-c string specify shell commands to exec after connect (use with caution). The string is passed to /bin/sh -c for execution. See the -e option if you don't have a working /bin/sh (Note that POSIX-conformant system must have one). -e filename specify filename to exec after connect (use with caution). See the -c option for enhanced functionality. -g gateway source-routing hop point[s], up to 8 -G num source-routing pointer: 4, 8, 12, ... -h display help -i secs delay interval for lines sent, ports scanned -l listen mode, for inbound connects -n numeric-only IP addresses, no DNS -o file hex dump of traffic -p port local port number (port numbers can be individual or ranges: lo-hi [inclusive]) -q seconds after EOF on stdin, wait the specified number of seconds and then quit. If seconds is negative, wait forever. -b allow UDP broadcasts -r randomize local and remote ports -s addr local source address -t enable telnet negotiation -u UDP mode -v verbose [use twice to be more verbose] -w secs timeout for connects and final net reads -z zero-I/O mode [used for scanning] -T type set TOS flag (type may be one of "Minimize-Delay", "Maximize-Throughput", "Maximize-Reliability", or "Minimize-Cost".) COPYRIGHT
Netcat is entirely my own creation, although plenty of other code was used as examples. It is freely given away to the Internet community in the hope that it will be useful, with no restrictions except giving credit where it is due. No GPLs, Berkeley copyrights or any of that nonsense. The author assumes NO responsibility for how anyone uses it. If netcat makes you rich somehow and you're feeling generous, mail me a check. If you are affiliated in any way with Microsoft Network, get a life. Always ski in control. Comments, questions, and patches to hobbit@avian.org. NOTES
Some port names in /etc/services contain hyphens -- netcat currently will not correctly parse those unless you escape the hyphens with backslashes (e.g. "netcat localhost 'ftp-data'"). BUGS
Efforts have been made to have netcat "do the right thing" in all its various modes. If you believe that it is doing the wrong thing under whatever circumstances, please notify me and tell me how you think it should behave. If netcat is not able to do some task you think up, minor tweaks to the code will probably fix that. It provides a basic and easily-modified template for writing other network applications, and I certainly encourage people to make custom mods and send in any improvements they make to it. Continued feedback from the Internet community is always welcome! EXAMPLES
For several netcat recipes, please see /usr/share/doc/netcat/README.gz and /usr/share/doc/netcat/README.Debian.gz. AUTHOR
This manual page was written by Joey Hess <joeyh@debian.org> and Robert Woodcock <rcw@debian.org>, cribbing heavily from Netcat's README file. Netcat was written by a guy we know as the Hobbit <hobbit@avian.org>. NC(1)
All times are GMT -4. The time now is 06:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy