Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 ( http://nmap.org ) 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 ( http://nmap.org ) 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
share|improve this question
add comment

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)

share|improve this answer
2  
There are lots of different versions of Netcat (nc). The -lp syntax is from Hobbit's original version, I believe. Versions derived from BSD forbid the use of -p with -l. Many do not support -e. Always check your installation's man page or -h option output. –  bonsaiviking Jul 31 '12 at 16:53
1  
Just to satisfy your question as to whether your running an old version, I'd say yes. 1.89-3 stock here. –  tao Jul 31 '12 at 18:11
    
Thanks guys. That explains the inconsistency between my Linux nc (hobbit/debian version) and my OS X nc (BSD version). –  Grezzo Jul 31 '12 at 21:10
    
You have probably installed netcat-traditional instead of netcat or netcat-openbsd –  SeMeKh May 13 '13 at 8:09
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.