How do i make any application use my eth0:0 interface?

5,309

Solution 1

It sounds like what you really want is an application that can download a file in parts from different interfaces and join them together at the end. Eg, if you knew your file was 100MB, and you wanted to grab chunks of roughly 10MB, you'd want to do:

1. start a download of bytes 0..10000000 on eth0, saving to filename.part1
2. start a download of bytes 10000001..20000000 on eth0:0, saving to `filename.part2
3. start a download of bytes 20000001..30000000 on eth0:1, saving to filename.part3
...
N-1. wait for all downloads to complete
N. join all filename.part* together to get filename.complete

I know wget can resume a partially-downloaded file. I'm pretty sure that works by reading to the end of the existing file and then requesting the file, starting from the next byte, from the server.

It looks like curl supports partial downloads like this using the --range <byterange> option. So you could script the above steps like so:

1. curl --interface eth0 --range 0,10000000 http://some.server.com/bigfile -o bigfile.part1
2. curl --interface eth0:0 --range 10000001,20000000 http://some.server.com/bigfile -o bigfile.part2
... 
N. cat bigfile.part* > bigfile

Caveats: this doesn't always work; if the HTTP/1.1 server doesn't have the partial-download feature enabled, you'll get the whole file on each call. See man curl for details on the --range option.

Edit: fixed byte ranges in examples

Solution 2

Here is a blog post about splitting a download with curl. I tried in Windows, but couldn't get it to work, but you might have success with Linux.

Share:
5,309

Related videos on Youtube

Abhijeet Rastogi
Author by

Abhijeet Rastogi

Linux Geek, Foodie, Biker!

Updated on September 17, 2022

Comments

  • Abhijeet Rastogi
    Abhijeet Rastogi over 1 year

    Like in curL, we have a bind address option, we can download using a certain interface..

    For ex, to download from eth0:0 we use $curl --interface eth0:0 http://www.google.com

    This way, my aim is to download files but since curL doesnt support segmented downloading, i dont want to use it. We have a speed restriction on every IP. To overcome this restriction, I can start many interfaces like this, and download some part of the file from each interface.

    How do i make any other download manager like AXEL to bind to a particular address? I am asking for some idea like changing variables in BASH shell, so that the whole shell binds to a particular interface, lets say eth0:1...

  • Abhijeet Rastogi
    Abhijeet Rastogi over 14 years
    I want to use all the interfaces simultaneously. Like in one terminal, i use eth0:0 and in the other i use eth0:1 .. Now, are u getting it what i actually intend to do.
  • kmarsh
    kmarsh over 14 years
    You have different terminals but only one kernel. The kernel uses one set of rules for routing, no matter what application the traffic comes from. If you set up static routes to different subnets or individiual hosts, the kernel can route the traffic through different ports to get there. Or you can set up Xen which will give you a whole new IP, port range, and routing table.