29

With the telnet program one can connect to any TCP port on any host, but is there a way to listen on some port on current host?

i.e.

1) on host a: telnet listen 12345

2) on host b: telnet host_a 12345

I don't want any service behind the listening side, just connection and whatever typed to be transferred as is both ways.

I know I can already do the 2), but is there any way to achieve the 1)? I'm interested in both Windows and Linux solution.

user1020218
  • 291
  • 1
  • 3
  • 4

7 Answers7

49

The usual tool for this is something called netcat. It's available in most Linux distros, and may even be installed by default in some (the command is nc). There are even ports for Windows, but nearly every antivirus package on the planet considers it deeply suspicious due it's use in malware which makes it hard to download and use.

sysadmin1138
  • 131,083
  • 18
  • 173
  • 296
  • Note that the `nc` tool which is installed in __cygwin__ is a different implementation than the `ncat` tool which is installed with __nmpap__. For example the command `nc -v -l xxx xx ` on __cygwin__ doesn't print the ip of the remote host or when a connection is establish by a remote client. On the contrary if you have nmap installed the command `ncat -v -l xxx xx` gives you this important details. This is why I prefer to use `ncat` instead of `nc`. *Another advantage of `ncat` is that probably it is not black listed by the AV software*. – Bemipefe Oct 14 '21 at 16:45
19

1) on host a: telnet listen 12345

$ ls | nc -l -p 12345

Depends on the distro and netcat version, you may not need -p option.

2) on host b: telnet host_a 12345

$ telnet host_a 12345
1159.rar
12030.mp4
123.mp4
124.mp4
129
129.bak
...
quanta
  • 50,327
  • 19
  • 152
  • 213
13

You are looking for a program called netcat. It is the swiss army knife of network utilities. You can tell it to listen on any arbitrary port as well as many other things.

Flimzy
  • 2,375
  • 17
  • 26
Zypher
  • 36,995
  • 5
  • 52
  • 95
4

Netcat, is what you're looking for.

http://netcat.sourceforge.net/

Kvisle
  • 4,113
  • 23
  • 25
4

Download Netcat. Swiss army knife of network utilities. http://netcat.sourceforge.net/

Bart Silverstrim
  • 31,092
  • 9
  • 65
  • 87
2

Even better than netcat is socat.

It provides a lot more control over socket options, and also many more choices for where to send received data.

Ben Voigt
  • 473
  • 5
  • 20
0

Internet Maniac can listen on any TCP and UDP port in Windows world

Lazy Badger
  • 3,067
  • 14
  • 13