大网数据广告活动
服务器运维问答

Netcat issue, getaddrinfo: Name or service not known

· 52CE 我爱测

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 th…

问题原文

原帖链接 · Zek · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Zek · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2013-08-14)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。