【问题标题】:IP forwarding, (packet redirect)IP 转发,(数据包重定向)
【发布时间】:2014-02-20 12:01:47
【问题描述】:

我正在寻找一种方法将所有来自 192.151.155.3:25550 的数据包转发到 192.151.155.2:25570

iptables -t nat -A PREROUTING -p tcp -d 192.151.155.3 --dport 25550 -j DNAT --to-destination 192.151.155.2:25570

我尝试使用上面的命令,但没有成功。还有另一种方法吗?还是我正在使用该命令?

另外,我如何让来自 192.151.155.2:25570 的所有传出数据包通过 192.151.155.3:25550

提前致谢!

【问题讨论】:

    标签: linux networking ubuntu command ip


    【解决方案1】:

    您可以使用rinetd 将 TCP 连接从一个 IP 地址和端口重定向到另一个。

    1. 安装rinetd

      sudo apt-get install rinetd

    2. 编辑 /etc/rinetd.conf 并包含以下行。这是rinetd的配置文件。

      192.151.155 25550 192.151.155.2 25570

    3. 重新启动 rinetd 以应用新的配置更改

      sudo /etc/init.d/rinetd restat

    试试这个 iptable 命令:

    iptables -t nat -I PREROUTING --src 192.151.155.3 --dst 192.168.1.5 -p tcp --dport 25550 -j REDIRECT --to-ports 25570
    

    【讨论】:

      【解决方案2】:

      您可以使用rein 将 TCP 连接从一个 IP 地址和端口重定向到另一个。非常直观,使用简单。

      https://github.com/firstboot/rein

      Linux:

      cd ~
      wget http://note.youdao.com/yws/public/resource/b1e1ad270ba1b1af97ebdf3e2c8b7403/xmlnote/82E2CC3FF2744238B6AF36346298E5E5/27082 -O rein.zip
      unzip rein.zip
      mv rein-*-linux rein
      chmod +x rein
      ./rein -e > rein.json
      # modify rein.json for you
      ./rein -c rein.json
      

      窗口:

      # unzip package, and rename
      ren rein-1.0.3-amd64-win.exe rein.exe
      
      # generate default conf 'rein.json'
      # windows cmd 
      ./rein.exe -e > rein.json
      
      # windows powershell
      ./rein.exe -e | out-file -encoding ascii rein.json
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-01-20
        • 1970-01-01
        • 1970-01-01
        • 2014-12-11
        • 2016-12-24
        • 2013-02-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多