You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by manikandan mvk <mm...@gmail.com> on 2006/04/06 18:35:48 UTC

Problem with httpservletrequest.getRemoteAddr() returns wrong IPaddress in multihomed machine

Hi ,

I have a machine with multihomed interface . basically , I am making call
where both the server and client are same machine . Here , I am trying to
validate the IPaddress  from the request with InetAddress.getLocalHost () .
Since ,both the client and server are same machine . I expects
httpservletrequest.getRemoteAddr() should be equals
  InetAddress.getLocalHost().getHostAddress();But Its not the case ..

i.e ;
In my multihomed machine : IPaddress of interface hme0  is : x.x.x.17  and
IPaddress of interface hme0:1 is :x.x.x.18
Hostname of the machine is mapped to x.x.x.18 .

Here , request.getRemoteAddr() returns x.x.x.17 ,whereas
netAddress.getLocalHost().getHostAddress() returns x.x.x.18 .

I feels request.getRemoteAddr() should also return x.x.x.18 .

Can someone helps me out , whats the problem here ?? , Is machine problem /
Tomcat problem ?? . I am having Tomcat version 4.1.31

Also , I have similar configuration on other machine ,but there it is
working fine .

Thanks in Advance .
Mani

Re: Problem with httpservletrequest.getRemoteAddr() returns wrong IPaddress in multihomed machine

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
manikandan mvk wrote:
> Basically I have a question ,If the request is made from multihomed machine
> ,which IPaddress will be taken as clients's IPaddress?.

That is exactly what I did ask you.

> Does it is 
> configurable  or how it decides that ?

I know nothing about your machine  and nothing about your client, so I can't 
tell.
Use a tool that shows open TCP connections or that allows to see network 
traffic like netstat, tcpdump, ethereal or whatever is available on your 
machine to find out what's happening between your client and Tomcat.

Regards
  mks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Problem with httpservletrequest.getRemoteAddr() returns wrong IPaddress in multihomed machine

Posted by manikandan mvk <mm...@gmail.com>.
Basically I have a question ,If the request is made from multihomed machine
,which IPaddress will be taken as clients's IPaddress?. Does it is
configurable  or how it decides that ?

Its becoz , I have multihomed machine with 2 IPaddr x.x.x.17 and x.x.x.18 .

Since InetAddress.getLocalHost returns  x.x.x.18 . I expects client
originated from same machine and it's request.getRemoteAddr should also
return x.x.x.18 .Where as it returns value as x.x.x.17

Can someone tell me how can I get resolve this .

~Mani

On 4/6/06, Markus Schönhaber <ma...@schoenhaber.de> wrote:
>
> manikandan mvk wrote:
> > I have a machine with multihomed interface . basically , I am making
> call
> > where both the server and client are same machine . Here , I am trying
> to
> > validate the IPaddress  from the request with InetAddress.getLocalHost() .
> > Since ,both the client and server are same machine . I expects
> > httpservletrequest.getRemoteAddr() should be equals
> >   InetAddress.getLocalHost().getHostAddress();But Its not the case ..
> >
> > i.e ;
> > In my multihomed machine : IPaddress of interface hme0  is : x.x.x.17
>   and
> > IPaddress of interface hme0:1 is :x.x.x.18
> > Hostname of the machine is mapped to x.x.x.18 .
> >
> > Here , request.getRemoteAddr() returns x.x.x.17 ,whereas
> > netAddress.getLocalHost().getHostAddress() returns x.x.x.18 .
> >
> > I feels request.getRemoteAddr() should also return x.x.x.18 .
>
> request#getRemotesAddr() should return the address the request was made
> from.
> Which address does your client use to send the request from?
>
> Regards
>   mks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Problem with httpservletrequest.getRemoteAddr() returns wrong IPaddress in multihomed machine

Posted by Markus Schönhaber <ma...@schoenhaber.de>.
manikandan mvk wrote:
> I have a machine with multihomed interface . basically , I am making call
> where both the server and client are same machine . Here , I am trying to
> validate the IPaddress  from the request with InetAddress.getLocalHost () .
> Since ,both the client and server are same machine . I expects
> httpservletrequest.getRemoteAddr() should be equals
>   InetAddress.getLocalHost().getHostAddress();But Its not the case ..
>
> i.e ;
> In my multihomed machine : IPaddress of interface hme0  is : x.x.x.17  and
> IPaddress of interface hme0:1 is :x.x.x.18
> Hostname of the machine is mapped to x.x.x.18 .
>
> Here , request.getRemoteAddr() returns x.x.x.17 ,whereas
> netAddress.getLocalHost().getHostAddress() returns x.x.x.18 .
>
> I feels request.getRemoteAddr() should also return x.x.x.18 .

request#getRemotesAddr() should return the address the request was made from. 
Which address does your client use to send the request from?

Regards
  mks

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org