Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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 -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=./ /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 – 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.