Linux 如何使用iptables重定向ip地址
我有5台计算机的小型局域网。我的提供商给了我真实的ip地址(194.187…),但网络中的计算机无法看到它。所以我必须在我的路由器上进行重定向(使用linux系统),这将把真实的ip地址(194.187…)重定向到提供商网络中的ip地址(10.12.205.26)Linux 如何使用iptables重定向ip地址,linux,redirect,iptables,Linux,Redirect,Iptables,我有5台计算机的小型局域网。我的提供商给了我真实的ip地址(194.187…),但网络中的计算机无法看到它。所以我必须在我的路由器上进行重定向(使用linux系统),这将把真实的ip地址(194.187…)重定向到提供商网络中的ip地址(10.12.205.26) 如何在路由器上使用iptables执行此操作。谢谢。我希望这对您有用: Add (prerouting,postrouting) rules in you NAT table using iptables -t nat -A
如何在路由器上使用iptables执行此操作。谢谢。我希望这对您有用:
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...
让我更好地理解。您希望指向您的公共(静态)ip地址的所有流量将重定向到您的专用LAN中的一个ip地址吗?10.12.205.26是5台计算机之一的IP吗?No 10.12.205.26是提供商网络中我的路由器的IP谢谢你的回答,但我需要重定向到194.187的所有连接。。。使用不同的端口连接到我的地址10.12.205.26,而不仅仅是8080端口谢谢,这非常好用。