Skip to content

Instantly share code, notes, and snippets.

@draobrehtom
Last active Sep 21, 2019
Embed
What would you like to do?
TCP and UDP ports redirection

UDP redirection:

https://unix.stackexchange.com/questions/205959/how-can-i-redirect-all-udp-traffic-from-one-port-to-another-on-bsd-os-x/207595#207595?newreg=fed9c03544f84687a9299f26752b21e2

TCP redirection:

https://serverfault.com/questions/238563/can-i-use-ufw-to-setup-a-port-forward

@draobrehtom
Copy link
Author

draobrehtom commented Sep 21, 2019

Download a very small c program source file called: udp_redirect (click here to download it)
Compile it with gcc -w udp_redirect.c -o udp_redirect
Run it in background sudo ./udp_redirect 127.0.0.1 20 127.0.0.1 29 &
Set up a listener on port 29 to test it sudo nc -ul 29
On a second terminal, test it with echo “this is a test” | sudo nc -4u -w1 localhost 20

@draobrehtom
Copy link
Author

draobrehtom commented Sep 21, 2019

tcpdump -i lo udp port 8125 -w data.pcap
echo -n "blah:36|c" | nc -w 1 -u -4 localhost 8125

@draobrehtom
Copy link
Author

draobrehtom commented Sep 21, 2019

Replaying:
tcpreplay -i lo -K --mbps 10000 data.pcap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment