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

What is the iptables equivalent to what socat does?

· 52CE 我爱测

What is the iptables equivalent to the following? socat TCP-LISTEN:8080 TCP:some-random-host-in-another-network.com:80 Now multiple clients can connect to port 8080 of this middle host to actually access some-random-host-in-anoth…

问题原文

原帖链接 · Masood Lapeh · CC BY-SA 4.0

What is the iptables equivalent to the following?

socat TCP-LISTEN:8080 TCP:some-random-host-in-another-network.com:80

Now multiple clients can connect to port 8080 of this middle host to actually access some-random-host-in-another-network.com:80. I'm asking to see whether it improves the latency and throughput.

已采纳解答

原帖链接 · Nikita Kipriyanov · CC BY-SA 4.0

Something like the following:

iptables -t nat -A PREROUTING -p tcp --dport 8080 -j DNAT --to-destination some-random-host-in-another-network.com:80
iptables -t nat -A POSTROUTING -d some-random-host-in-another-network.com -p tcp --dport 80 -j MASQUERADE

(this is bare minimum, likely you'd want to add permitting rules into filter FORWARD and so on)

This would translate both addresses, source and destination. The "some-random-host-in-another-network.com" will see connections as coming from this host and hide the original source.

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

资料来源与适用范围

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

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

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