【问题标题】:How to redirect ip address using iptables [closed]如何使用iptables重定向IP地址[关闭]
【发布时间】:2013-02-05 19:17:09
【问题描述】:

我有 5 台计算机的小型本地网络。我的提供商给了我真实的 IP 地址(194.187...),但网络中的计算机看不到它。所以我必须在我的路由器(使用 linux 系统)上进行重定向,这会将真实 IP 地址(194.187...)重定向到我在提供商网络中的 IP 地址(10.12.205.26)。

如何在路由器上使用 iptables 执行此操作。谢谢。

【问题讨论】:

  • 让我更好地理解。您希望所有指向您的公共(静态)IP 地址的流量都被重定向到您的专用 LAN 中的 IP 之一吗? 10.12.205.26是5台电脑其中一台的IP?
  • 没有 10.12.205.26 是我的路由器在提供商网络中的 IP

标签: linux redirect iptables


【解决方案1】:

我希望这对你有用:

   Add (prerouting,postrouting) rules in you NAT table using

iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to-source ip_address
iptables -t nat -A PREROUTING -i eth0 -j DNAT --to-destination ip_address

    and then use :

    iptables -t nat -A PREROUTING -d 194.187... -j DNAT --to-destination 10.12.205.26

    iptables -t nat -A POSTROUTING -s 10.12.205.26 -j SNAT --to-source 194.187...

【讨论】:

  • 感谢您的回答,但我需要将所有连接到 194.187... 使用不同的端口重定向到我的地址 10.12.205.26,而不仅仅是 8080 端口
  • 谢谢,这很完美。
猜你喜欢
  • 1970-01-01
  • 2013-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-04-02
  • 1970-01-01
  • 2019-07-20
  • 1970-01-01
相关资源
最近更新 更多