繁体   English   中英

IP转发(数据包重定向)

[英]IP forwarding, (packet redirect)

我正在寻找一种将所有发送到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

提前致谢!

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

  1. 安装rinetd

    须藤apt-get install rinetd

  2. 编辑/etc/rinetd.conf并在下一行添加。 这是rinetd配置文件。

    192.151.155 25550 192.151.155.2 25570

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

    须藤/etc/init.d/rinetd恢复

试试这个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

您可以使用rein将TCP连接从一个IP地址和端口重定向到另一个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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM