This simple wrapper library allows you to set the source address of outgoing TCP and UDP traffic.
Download the libsis-0.1.1.tar.gz tarball. If you want, you can look at the sis.c source right now.
If you're on a multi homed host with more than one IP address the kernel usually select one source address based on varios parameters for you if your application does not ask for a particular address itself.
There are applications which let you set the local address of all outgoing connections. A prominent example are all sorts of IRC clients.
Most application however don't support this and unless you care for your source ip it doesn't matter.
In some setups however it is important which source address the application has. Like when you use source based routing, i.e. decide of a packets route not only based on destination but also on source address. This makes sense for instance if you have more than one connectio to the internet.
This library wraps around the libc functions connect() and sendto().
It then bind()s the socket to the local address specified by the
SIS_SOURCE environment variable. If the application has already called
bind() itself another call of bind() should not change anything - not
that I've tested this.
Change to the libsis directory and run make. You should find a file
named libsis.so.
Set the environment variable LD_PRELOAD to
/path/to/libisis/directory/libsis.so:
export LD_PRELOAD=/path..../libsis.soor if you're using a csh type shell
setenv LD_PRELOAD /path..../libsis.sothen set the environment variable
SIS_SOURCE:
export SIS_SOURCE=10.151.2.130or again in a csh type shell
setenv SIS_SOURCE 10.151.2.130
Note: Only IP Addresses are allowed, no hostnames.
Now call your program and it should have its source address set to
$SIS_SOURCE in outgoing connections.
You may want to copy the libsis.so* files to a convinient directory.
Works for me; does everything I want.
LD_PRELOAD does not work with suid binaries.LD_PRELOAD only works with dynamically linked binaries.
0.1.1 - 2002-05-23
Initial Release