Home > Perl > Perl. HTTP-request from specified IP

Perl. HTTP-request from specified IP

October 2nd, 2009

For libwww-perl-5.834.

Use the method local_address of LWP::UserAgent object

my $ua = LWP::UserAgent->new( );
$ua->local_address( '192.168.0.1' )

For older versions.

Before creating an LWP::UserAgent object you should add following code:

push(@LWP::Protocol::http::EXTRA_SOCK_OPTS,
LocalHost => '192.168.0.1'
);

there 192.168.0.1 is the required interface IP address.

Categories: Perl Tags: ,
  1. Aleks
    May 5th, 2010 at 04:23 | #1

    Can LWP UserAgent us an IP on a different subnet?

  2. alex
    May 5th, 2010 at 22:09 | #2

    If you have the network interface in another subnet, of course you can use it

Comments are closed.