How to use different network interfaces for different processes?

I have two network interfaces on a Linux PC, and I need to manually set the interface that a given process will use.

The program (Twinkle softphone) does not have a similar option, so I believe that it must be set externally.

How can I do it?

Edit: I’m not trying to make a server process bind to a specific interface, but rather to make a client program contact a server using a specific interface.


you can replace code at runtime by the use of LD_PRELOAD (@windows you can use a similar technique called detours, quite fancy). what this does is to inform the dynamic linker to first load all libs into the process you want to run and then add some more ontop of it. you normally use it like this:

% LD_PRELOAD=./ ls

and by that you change what ls does.

for your problem i would try, which you can use like:

% BIND_ADDR="ip_of_ethX" LD_PRELOAD=./ twinkle

here is how you build it:

% wget -O bind.c
% gcc -nostartfiles -fpic -shared bind.c -o -ldl -D_GNU_SOURCE

a longer howto is

similar hacks and tools:

Source : Link , Question Author : Andrea Spadaccini , Answer Author : akira

Leave a Comment