Rewriting UDP packets on Linux

rewriteudp

I would like to rewrite the contents/payload of UDP packets as they are received by a machine, on selected reports – before they are passed to the listening application.

For example, I would like to change the headers of a UDP-based protocol by using grep-like regular expressions (to add, remove or change parts of each message received).

Is this possible with a software firewall or similar tool?

Thanks all!

Best Answer

If this isn't for production, but rather just learning. I recommend Scapy, you can craft and replay packets on a object oriented interface that relates to the OSI model. It acts like an interactive python console. You can also sniff with it, lots of fun ;-)