# help porting ld preload bind ip address



## antolap (Dec 4, 2017)

Could you help me compiling this file on FreeBSD?
http://www.ryde.net/code/bind.c.txt

I need it to bind an application to a specific virtual ip address
example:

```
BIND_ADDR="192.168.13.40" LD_PRELOAD=./bind.so MYPROGRAM destination-ip
BIND_ADDR="192.168.13.41" LD_PRELOAD=./bind.so MYPROGRAM destination-ip
BIND_ADDR="192.168.13.42" LD_PRELOAD=./bind.so MYPROGRAM destination-ip
```
anyone who can help me compiling this file on FreeBSD 11?
Thanks


----------



## tobik@ (Dec 4, 2017)

On Linux the command to compile it is: `gcc -nostartfiles -fpic -shared bind.c -o bind.so -ldl -D_GNU_SOURCE`

On FreeBSD this translates to: `cc -nostartfiles -fpic -shared bind.c -o bind.so`


----------



## SirDice (Dec 4, 2017)

antolap said:


> I need it to bind an application to a specific virtual ip address


What application? There might be easier ways to accomplish this.


----------



## antolap (Dec 4, 2017)

It seems to work
THANKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!


----------

