Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

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"

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.