Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 127.0.0.1:22 here instead of the remote host.

Here is the command and the error I am getting:

nc -n –l 2222 0<backpipe | nc -n 127.0.0.1 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

1 Answer 1

up vote 0 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 192.168.1.2 -l 2222 0<backpipe | nc -n 127.0.0.1 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

 
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.