【问题标题】:Forward a host network traffic to another host with the exception of the ssh service [closed]将主机网络流量转发到除 ssh 服务之外的另一台主机[关闭]
【发布时间】:2014-04-08 08:43:33
【问题描述】:

我正在尝试将旧主机中收到的所有网络流量重定向到不同的新主机。为此,我在旧主机的 iptables 上创建了两条新规则:

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A PREROUTING -d old_machine_ip -j DNAT --to-destination new_machine_IP
iptables -t nat -A POSTROUTING -s new_machine_ip -j SNAT --to-source old_machine_ip
/etc/init.d/iptables save
/etc/init.d/iptables restart

一切正常,但是我无法再访问旧主机 ssh,因为它重定向到新主机,所以我想知道是否可以创建一个忽略 ssh 服务预路由的规则。

最好的问候,

【问题讨论】:

    标签: networking iptables centos6 selinux


    【解决方案1】:
    iptables -t nat -A PREROUTING -m tcp -p tcp --dport 22 -j RETURN
    

    它必须出现在您的 DNAT 规则之前。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-11
      • 1970-01-01
      • 2023-04-09
      • 2016-11-22
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      相关资源
      最近更新 更多