Multiple source IP addresses from one server

I need to query a service that's rate-limited by IP address. I have 10 addresses assigned to my box, and I'd like to grab the data 10x as fast, but (naturally) only the first IP address shows up as the source when making connections to remote servers.

Is there a way to change which address is seen as the source without restarting networking, maybe per process or something? I assume this would involve changing the source address at the TCP level. The return traffic would be fine, as the server is set up to listen on all of the addresses. (I think my reasoning is correct here.)

Is there any way to do this?

4 Replies

Some applications (like irssi) let you bind to a certain source address. Others are hard coded to always use the default interface (which is usually the interface closest to the exit point in the routing table (if your default gateway is an address on the same network as eth0, the default would be to bind to eth0)).

wget(1) has a –bind-address option, that I think does what you're saying.

Yup, exactly what I need. I just discovered netcat's -s option, which I think should work wonders.

Edit: also, seems PHP's socket_bind() should work and not require running an external program.

if you're using curl to query something: (in php at least)

curlsetopt($ch, CURLOPTINTERFACE, $ip);

Thanks, Esoterik, that'll be even easier not to have to deal with raw sockets. Good thing I've been lazy and haven't started coding this yet. :)

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct