I needed to force a generic server application to only bind to a specified IP address on my computer, so I got nusse to find me this code:


You can compile it with gcc -D_GNU_SOURCE -nostartfiles -fpic -shared bind.c -o bind.so -ldl

Then start the program like this:

BIND_ADDR="" LD_PRELOAD=bind.so java -Djava.net.preferIPv4Stack=true -jar db4oServer.jar 8875

A similar tool seems to exist in the linux-vserver suite called chbind