【问题标题】:IPTables 1:1 NAT on a single port [closed]单个端口上的 IPTables 1:1 NAT [关闭]
【发布时间】:2014-04-03 13:48:44
【问题描述】:

我试图弄清楚如何使用 IPTables 添加 1:1 NAT,但仅在单个端口上,我知道如何转发所有流量,但似乎在单个端口上找不到任何东西,例如

192.168.1.1:21 -> 172.16.1.1:21   
192.168.1.2:21 -> 172.16.1.2:21   
192.168.1.3:21 -> 172.16.1.3:21   
192.168.1.4:21 -> 172.16.1.4:21   

我不能说只允许一个端口来做到这一点,因为还有其他应用程序也在其他端口上进行流量重定向。

到目前为止,我所拥有的都是这样的,但它没有将它最初登陆的 IP 指定为参数。

sysctl net.ipv4.ip_forward=1   
iptables -t nat -A PREROUTING -p tcp --dport port -j DNAT --to-destination ip:port   
iptables -t nat -A POSTROUTING -j MASQUERADE   

【问题讨论】:

    标签: linux networking firewall iptables nat


    【解决方案1】:

    使用 -d 标志指定原始目标。

    iptables -t nat -A PREROUTING -d <external-ip> -p tcp --dport port -j DNAT --to-destination <internal-ip>:port
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-30
      • 1970-01-01
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-30
      • 1970-01-01
      相关资源
      最近更新 更多