简体   繁体   中英

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? Example:

Incoming Syslog on port 514 UDP --> Forward to new destination on port 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. 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. Check your linux distribution and see how to check the status or start iptables service in that distribution.

If you are using windows then you might need to see this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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