2013-02-05 60 views
3

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

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

+0

让我更好地理解。您希望所有指向您的公共(静态)IP地址的流量都将重定向到您的专用局域网中的一个IP? 5台计算机之一的IP是10.12.205.26吗? –

+0

没有10.12.205.26是我的路由器在提供商的网络的IP – andreyd

回答

2

我希望这对你的作品:

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... 
+0

感谢您的回答,但我需要重定向所有连接到194.187 ...使用不同的端口到我的地址10.12.205.26,而不仅仅是8080端口 – andreyd

+0

谢谢,这工作完美。 – andreyd

相关问题