Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

My server has several ip interfaces. I want to execute a script that fetches a webpage content and i was wondering if its possible to use another ip interface besides the default one. The script does not have an interface argument like curl.

Thank you

share|improve this question

2 Answers 2

up vote 2 down vote accepted

This is possible.. But it's dirty.


1) Compile it to a shared object:

cc -nostartfiles -fpic -shared bind.c -o bind.so -ldl -D_GNU_SOURCE

2) Set the BIND_ADDR variable, and the LD_PRELOAD path and execute your application, as follows. BIND_ADDR="" LD_PRELOAD=./bind.so /path/to/your/application

3) Your application now has the interface as the default.

share|improve this answer
will this change the default server interface? I mean the change will be isolated in the program right? –  keepwalking Nov 12 '12 at 10:34
Yes, the change is isolated to the program run in the environment where LD_PRELOAD was set to bind.so –  Tom O'Connor Nov 12 '12 at 10:48

w/o touching your script, you would need to change the default interface for the whole system - which is most likely not a good idea!

I suggest you to update the script and make it to use the interface you want... it can be done eg. by specifying --bind-address if you're using wget

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.