I want to use Perl www::mechanize to connect to the webserver and request a resource. E.g. http://www.my.domain/test.html. But I want to specify the IP address independently from the hostname in the URL.
For example: www.my.domain resolves to 1.1.1.1, but I want to connect to 2.2.2.2.
I want to do this to test multiple web servers behind a load balancer.
use LWP::UserAgent::DNS::Hosts;
It works fine with WWW::Mechanize.
use LWP::UserAgent::DNS::Hosts;
use WWW::Mechanize;
LWP::UserAgent::DNS::Hosts->register_host('www.my.domain' => '2.2.2.2');
LWP::UserAgent::DNS::Hosts->enable_override;
my $mech = WWW::Mechanize->new;
$mech->get('http://www.my.domain/test.html'); # connects to 2.2.2.2