Matthias has asked for the wisdom of the Perl Monks concerning the following question:

I did a small web spider (LWP based) and want to use different IP's for my requests. Is it possible to use different virtual interfaces for requests?

Replies are listed 'Best First'.
RE: LWP and virtual interfaces
by lhoward (Vicar) on Apr 11, 2000 at 17:54 UTC
    Normally it is the responsibility of the operating system to route packets out the apropriate interface. If you have root level access to the system you are running this script on you may be able to get the OS to route the packets out another (virtual) interface by messing with the routing table (on UNIX this would probably be done with system calls to the route command). Alternatively, you might be able to do something with ifconfig by changing the IP address on the port itself. The IO::Socket::INET module does take a LocalHost argument that may do the trick for you (of course, at that point you'd be dumping LWP and have to write all that functionality yourself).
    Les Howard
    www.lesandchris.com
    Author of Net::Syslog and Number::Spell
Re: LWP and virtual interfaces
by IndyZ (Friar) on Apr 12, 2000 at 00:36 UTC
    I don't think that LWP will let you bind to different IP addresses. However, a low level solution like IO::Socket or just plain 'ole Socket should let you do it.

    Indyz
Re: LWP and virtual interfaces
by turnstep (Parson) on Apr 11, 2000 at 19:28 UTC

    Perhaps if you describe exactly what you are trying to accomplish, another way may be found. Changing your IP address (falsely) is generally seen as a very anti-social [1] thing to do. If you need some way to distinguish requests, almost any other variable (e.g. User-agent, query_info) would be a better choice to change.

    [1] If you are browsing your own sites, of course, you can be as anti-social as you like :)