5

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
raco
  • 51
  • 1
  • 3
  • 1
    The answer is [here](http://serverfault.com/a/262334/91987). 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=..... http://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 Answers1

0

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.

Epaphus
  • 1,011
  • 6
  • 8