Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to use netcat to relay SSH traffic (bidirectionally) from port 2222 on one host to port 22 on a different host. For test purposes, I redirect to here instead of the remote host.

Here is the command and the error I am getting:

nc -n –l 2222 0<backpipe | nc -n 22 1>backpipe
getaddrinfo: Name or service not known

I must be missing something really obvious here, but I fail to see it. I am using only IP addresses (and even "-n" to not resolve anything), but it appears to still be trying to do a DNS lookup.

This is CentOS 6.x [64].

What am I missing?

share|improve this question
up vote 1 down vote accepted

I got this working. The issue was that I had to specify the host for the first nc command, like so:

nc -n -l 2222 0<backpipe | nc -n 22 1>backpipe" 

Normally the host should not be needed with "-l" (it defaults to local host), according to the man page.

share|improve this answer

Your Answer


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.