iptables 将所有请求重定向到本地主机
我想将对特定 IP 发出的所有请求重定向到本地主机 (127.0.0.1)。我需要它,因为我有服务器的本地副本,并且想要测试一些东西,
我如何编写 iptables 规则来做到这一点?
谢谢
I want to redirect all requests made to a particular ip to localhost (127.0.0.1). I need it because I have a local replica of a server and want to test some things
How can I write a iptables rule to do that?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的意思是“我希望从机器 A 向机器 B 发出的所有请求都重定向到机器 A”吗?如果是这样,我相信您正在寻找的命令是
Did you mean "I want all requests made from machine A to machine B, to be redirected to machine A"? If so, I believe the command you are looking for is
引用联机帮助页:此目标仅在 PREROUTING 链中的 mangle 表中有效
以及仅从此链调用的用户定义链。它重新
将数据包调整到本地套接字而不更改数据包标头
以任何方式。
Quoting manpage: This target is only valid in the mangle table, in the PREROUTING chain
and user-defined chains which are only called from this chain. It redi-
rects the packet to a local socket without changing the packet header
in any way.
我知道这是一个很旧的线程......但仍然没有答案。所需的主要更改是附加 OUTPUT 规则而不是 PREROUTING 规则。
从手册页:
所以,这可能是所需的命令:
I know this is a pretty old thread... But still without an answer. The main change required will be to append an OUTPUT rule rather than PREROUTING rule.
From the man page:
So, this might be the command required: