I'm trying to get netcat to listen on port 4444, but it doesn't seem to be working. I am checking to see if the port is open using nmap, but it doesn't pick it up and I can't figure out why. I have tried various ports with no joy.
Here is a copy of my terminal so you can see what I am doing and what I have tried:
#iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination # nmap localhost -p 4444 Starting Nmap 5.61TEST4 ( ) at 2012-07-31 16:37 BST Nmap scan report for localhost (127.0.0.1) Host is up (0.00019s latency). Other addresses for localhost (not scanned): 127.0.0.1 PORT STATE SERVICE 4444/tcp closed krb524 Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds # nc -l 4444 & [1] 1951 # nmap localhost -p 1-65535 Starting Nmap 5.61TEST4 ( ) at 2012-07-31 16:42 BST Nmap scan report for localhost (127.0.0.1) Host is up (0.0000070s latency). Other addresses for localhost (not scanned): 127.0.0.1 Not shown: 65532 closed ports PORT STATE SERVICE 22/tcp open ssh 7337/tcp open unknown 33507/tcp open unknown Nmap done: 1 IP address (1 host up) scanned in 1.37 seconds # ps -e | grep nc 12 ? 00:00:00 sync_supers 1156 tty1 00:00:00 ck-launch-sessi 1232 tty1 00:00:00 dbus-launch 1274 ? 00:00:00 klauncher 1951 pts/2 00:00:00 nc 1 Answer
I ran the verbose mode -v and got a clue back:
4444: inverse host lookup failed: Unknown server error : Connection timed out` listening on [any] 41579 ...` so I tried specifying a port with -p like this nc -lvp 4444 and it works:
listening on [any] 4444 ... Obviously I need to use -p with -l with this version of nc.
I'd love it if anyone could tell my why there is this difference. Am I running an old version? (-h reports v1.10-38)