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

Possible Duplicate:
Can I bind a (large) block of addresses to an interface?

I have a /48 IPv6 block. I'd like to be able to do this:

$ wget --bind-address=<1st-ipv6> http://www.some-url.com
$ wget --bind-address=<2nd-ipv6> http://www.some-url.com
$ wget --bind-address=<3rd-ipv6> http://www.some-url.com
etc...

for any of the 2^80 available IPs in my /48 block.

According to my tests, assigning lots of IPs to an interface makes things slow (in terms of HTTP requests per second). And obviously, I can't assign billions of IPs to one interface. Is there a way to tell Linux to accept any IP that belong to my /48 block, or to modify wget so that it can be done?


Jan 17 2013 EDIT: I found out how to do it. Your kernel version must be at least 3.3, because from this version, this patch is applied: http://lists.openwall.net/netdev/2011/11/08/8

Then you have to run as root (as said by David Schwartz):

# ip -6 route add local your_ipv6_block/48 dev lo

You have to assign this route to the lo interface, even if it won't be the outgoing interface to reach the Internet.

Then you have to modify wget's sources. In src/connect.c, inside the function connect_to_ip(), after the socket is created, add this:

setsockopt(sock, SOL_IP, IP_FREEBIND, &v, sizeof(v));

Then compile wget (the compiler may complain about IP_FREEBIND not being defined, how to solve this is out of scope here) and install it.

Then you can successfully do:

$ wget --bind-address=<any_ipv6_in_your_block> http://www.some-url.com
share|improve this question

marked as duplicate by Michael Hampton, Tom O'Connor, MadHatter, Ward, mdpc Jan 11 '13 at 0:03

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
The answer is here. Basically ip route add local ... dev lo. –  David Schwartz Jan 10 '13 at 18:05
    
I tried "ip route add local xxxx/48 dev lo". It does not return any error, but when I try "wget --bind-address=..... whatismyv6.com/";, wget says "Cannot assign requested address". Same thing with "ip route add local xxxx/48 dev eth0". –  raco Jan 10 '13 at 20:01
    
Such a patch should be submitted upstream to the software maintainer, so that everyone will (eventually) get it. –  Michael Hampton Jan 17 '13 at 22:09

1 Answer 1

Assuming you doing this to load test your web server you could have a look at curl loader

This will make requests to a web server and use a different client IP for each request, it can also request different pages on the same connection simulating a user, for example going to a login page and logging in then logging off, etc

It will work with IPv4 and IPv6 and sets up the IP address's for you so all you need to do is give it an IP range, a url and maximum number of connections and concurrent connections, then run the command.

share|improve this answer

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