I have a black box program which listens on a particular UDP port. I'd like it to listen to a UDP port of my choosing.

Is there a way to trick the executable into listening on a differen port. I might imagine there exists a library which could be injected with LD_PRELOAD that might incercept the system calls and facilitate this.

A virtual machine of course is the heavy handed option, but that's not an option for me.

1 Answer 1


If you can tell the black-box program to listen only on a specific IP address, you could bind it to an arbitrary loopback address, like, and then use netcat, AKA, nc, to pipe between the port on and whatever you like on the outside IP.

There's an article on Netcat in wikipedia with a section about proxying. You'll want to understand that and to know that the -u option lets you use UDP instead of the default, TCP.

In this example, is the outside IP, 12345 is the port you want the black box to listen on. is the IP you told the blackbox to use and 987 is the port the box rudely insists upon using.

mkfifo backpipe
chmod {something sane backpipe}
nc -l -u 12345 0<backpipe | nc 987 1>backpipe

If you don't have mkfifo on your system, google "mknod pipe"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .