0

I'm trying to bind a java process to a specific virtual interface having IP address <myIFaddr> as follows:

export BIND_ADDR=<myIFaddr> LD_PRELOAD=./bind.so
exec java -jar ppp.jar

The program ppp.jar simply makes a request on an HTTP server, which replies sending back the IP address of the client, printing this address to stdout.
As a result, the java program prints the IP address of the "physical interface" (non the virtual one, having a different IP address).

Is there a way to solve this problem, applying a correct/different binding?

Thanks

1
  • The reason it is doing this depends on a lot of things. For instance, does the virtual interface have its own path to the server, or is it going through another interface and being NATted? May 23, 2013 at 9:07

1 Answer 1

3

If you are using Java socket in your application you can use the bind function as follows:

mysocket=new Socket();
mysocket.bind(new InetSocketAddress(<myIFaddr>, port));

naturally you have to modify the code to take in input in your Java application.

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