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

I need to know how to set my own remote_addr when requesting pages from the web.
I seem to be out of answers on how to do this.
When the page I request sends out its $ENV_ variables :"SO I MAY CHECK IT OUT" it says the "REMOTE_ADDR" is one of my WEB SERVER IP'S, not me or what I set. I don't want this I want it to either be mine or set my own preferably.
Ohh, and when I set my own it adds a "environment var" called HTTP_REMOTE_ADDR. "still not what i want."
Sample:
#!/usr/bin/perl use LWP::UserAgent; use HTTP::Headers; my $theurl = "http://www.foo.com"; $h = new HTTP::Headers( Content_Type=>'text/html, text/plain, image/*', Accept=>'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, applicat +ion/vnd.hp-hpf, */*', Accept_encoding=>"gzip, deflate", Accept_language=>"en-us", Connection=>"Keep-Alive", remote_addr=>'123.456', ); $ua = LWP::UserAgent->new; $request = HTTP::Request->new(GET => $theurl, $h); $ua->agent("Mozilla/4.0 (compatible; MSIE 6.0; Windows 98; Win 9x 4.90 +)"); $response = $ua->request($request); if ($response->is_success) { print "Content-Type: text/html\n\n"; print $response->content; } else { print "Error: " . $response->status_line . "\n"; } );

I've tried adding/deleting some of the following:
$request->header('Accept'=> 'text/html','Type' => 'text/html','remote_ +addr'=>'123.456'); print $q->header(-Type=>'text/html',-Accept=>'text/html',-remote_addr= +>'123.456.789');#under $q use CGI of course tried remote_addr, Addr, and REMOTE_ADDR on above

Does anyone have a way a accomplishing this?

Thanks,
iamsteve

Replies are listed 'Best First'.
Re: setting remote_addr in header so my server IP isn't the address
by mortis (Pilgrim) on Dec 15, 2001 at 02:30 UTC
    If you're referring to what the remote web server sees as your REMOTE_ADDR, then I'm pretty sure you can't do what you want. AFAIK REMOTE_ADDR is set up on the server to be the IP address of the remote connection - as determined by the tcp/ip stack - not by any data sent by the remote system.

    If the remote system (from the web server's point of view) could set REMOTE_HOST, they'd be able to spoof who they were.

    If that's what you're trying to do, stop it.

    :^)

Re: setting remote_addr in header so my server IP isn't the address
by Anonymous Monk on Dec 15, 2001 at 03:28 UTC
    Assuming that you have more than one IP address assigned to the machine you are on, you could modify some of the LWP modules so that the IO::Socket::INET->new() call in LWP/Protocol/http.pm used the LocalAddr of your choice.
Re: setting remote_addr in header so my server IP isn't the address
by iamsteve (Initiate) on Dec 15, 2001 at 04:10 UTC
    No, I'm not trying to hack or lie here. I'm basically wanting my "REAL" IP or an ip i could set to show up on the page I request VIA above "http::LWP::ETC..." instead of my SERVERS IP. Any more people might know please post I'll check back later.
Re: setting remote_addr in header so my server IP isn't the address
by Anonymous Monk on Dec 18, 2002 at 05:49 UTC
    Er.. if you're requesting a CGI, and the remote address that the CGI sees isn't your machine's, then you're using a proxy to get to that server. Whether that is due to your browser settings, or a transparent proxy between you and the server is something you'll have to figure out.