![重定向来自本地主机上特定 IP 的 Curl 调用](https://linux22.com/image/159040/%E9%87%8D%E5%AE%9A%E5%90%91%E6%9D%A5%E8%87%AA%E6%9C%AC%E5%9C%B0%E4%B8%BB%E6%9C%BA%E4%B8%8A%E7%89%B9%E5%AE%9A%20IP%20%E7%9A%84%20Curl%20%E8%B0%83%E7%94%A8.png)
我有一个为 提供服务的节点服务器localhost:90
,我们需要将所有来自机器内部的curl 调用定向168.92.168.92
到localhost:90
。
如何才能实现这一目标?这会使用 iptables 吗?
我尝试了 OUTPUT 和 PREROUTING 但请求无法连接。
Chain PREROUTING (policy ACCEPT 3339 packets, 200K bytes)
num pkts bytes target prot opt in out source destination
1 0 0 DNAT tcp -- 168.92.168.92 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 to:127.0.0.1:90
Chain INPUT (policy ACCEPT 3339 packets, 200K bytes)
num pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 6220 packets, 652K bytes)
num pkts bytes target prot opt in out source destination
1 0 0 DOCKER all -- * * 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL
2 0 0 DNAT tcp -- * * 168.92.168.92 0.0.0.0/0 tcp dpt:80 to:127.0.0.1:90
输出:
# curl -v http://168.92.168.92/hello
* About to connect() to 168.92.168.92 80 (#0)
* Trying 168.92.168.92... Connection refused
* couldn't connect to host
* Closing connection #0
curl: (7) couldn't connect to host
Curl directly to the server on localhost:90 works, but curl on 168.92.168.92 does not.
我缺少什么?