简体   繁体   English

接收数据包并将其转发到其他端口

[英]receive packets and forward them on different port

Is there some kind of tool (best would be in Java) that is capable of receiving packets on specific ports, and forward them on another one? 是否有某种工具(最好在Java中)能够在特定端口上接收数据包,并在另一个端口上转发它们? Example: 例:

Incoming Syslog on port 514 UDP --> Forward to new destination on port 1514 UDP. 端口514 UDP上的传入Syslog->转发到端口1514 UDP上的新目标。

Traffic is no video stream or anything, just some syslog data. 流量不是视频流,而是任何系统日志数据。

Thanks 谢谢

It is not advisable to do it in user-space application (if you are not interested in that data). 不建议在用户空间应用程序中执行此操作(如果您对该数据不感兴趣的话)。 In linux you can use iptables for that purpose. 在Linux中,您可以为此目的使用iptables。 Run this command. 运行此命令。

sudo iptables -t nat -A PREROUTING -i eth0 -p udp --dport $srcPortNumber -j REDIRECT --to-port $dstPortNumber

You might need to start the iptables service if it is not running already. 如果尚未运行iptables服务,则可能需要启动它。 Check your linux distribution and see how to check the status or start iptables service in that distribution. 检查您的linux发行版,并查看如何检查状态或启动该发行版中的iptables服务。

If you are using windows then you might need to see this . 如果您使用的是Windows,则可能需要查看此信息

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

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