You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ftpserver-users@mina.apache.org by Koichi Tsunoda <ic...@hotmail.com> on 2009/02/17 02:13:45 UTC

Question about getting client's address

Hey all,

It seems like if I do ftpSession.getClientAddress().toString() in an  
Ftplet methods (onLogin, etc.), it won't get the actual user's address  
for me. I'm wondering if that is because of NATs/Firewalls/etc., or if  
it's a bug? It seems to get the last address the "hop" came from,  
rather than the original origin.

On the side note, if I do ftpSessoin.getHostAddress().toString(),  
it'll get the internal IP, rather than the external IP address that  
the user used to ftp to that machine. Is that also behaving the way  
it's supposed to work?

Thanks!
Koichi




Re: Question about getting client's address

Posted by Ashish <pa...@gmail.com>.
On Tue, Feb 17, 2009 at 6:10 PM, Sai Pullabhotla
<sa...@jmethods.com> wrote:
> Normally, most PCs have just one network card and one address (private
> network address). If the PC connects through a router (e.g. a PC at a work
> places or a PC in a home network), to a system outside of your internal
> network, the peer on the other end sees your router's external/public
> address (this is the static/dynamic address given by your Internet Service
> Provider). I'm not sure if it is same as "public IP of the client".

Effectively, before the packet moves out NAT or NAPT (static or
dynamic) is applied.
I think we are on same page, just words are different :-)

thanks

Re: Question about getting client's address

Posted by Sai Pullabhotla <sa...@jmethods.com>.
Normally, most PCs have just one network card and one address (private
network address). If the PC connects through a router (e.g. a PC at a work
places or a PC in a home network), to a system outside of your internal
network, the peer on the other end sees your router's external/public
address (this is the static/dynamic address given by your Internet Service
Provider). I'm not sure if it is same as "public IP of the client".

PS: you should be able to go to www.whatismyipaddress.com to find the IP
address seen by systems on the Internet.

Sai Pullabhotla
Phone: (402) 408-5753
Fax: (402) 408-6861
www.jMethods.com



On Tue, Feb 17, 2009 at 6:18 AM, Ashish <pa...@gmail.com> wrote:

> On Tue, Feb 17, 2009 at 5:39 PM, Sai Pullabhotla
> <sa...@jmethods.com> wrote:
> > The getClientAddress returns the IP Address of the client that
> > connected/logged into the server. If the client used a Router to connect
> to
> > the server over the Interner, the router's IP address is what the server
> > will see as the connected client.
>
> I hope, you mean, the public IP used by the client?
>
> >
> > I'm not sure on your second question as I do not see a getHostAddress()
> > method in the FTPSession. Please clarify further.
> >
> > Thanks.
> >
> > Sai Pullabhotla
> > Phone: (402) 408-5753
> > Fax: (402) 408-6861
> > www.jMethods.com
> >
> >
> >
> > On Mon, Feb 16, 2009 at 7:13 PM, Koichi Tsunoda <ichikoo315@hotmail.com
> >wrote:
> >
> >> Hey all,
> >>
> >> It seems like if I do ftpSession.getClientAddress().toString() in an
> Ftplet
> >> methods (onLogin, etc.), it won't get the actual user's address for me.
> I'm
> >> wondering if that is because of NATs/Firewalls/etc., or if it's a bug?
> It
> >> seems to get the last address the "hop" came from, rather than the
> original
> >> origin.
> >>
> >> On the side note, if I do ftpSessoin.getHostAddress().toString(), it'll
> get
> >> the internal IP, rather than the external IP address that the user used
> to
> >> ftp to that machine. Is that also behaving the way it's supposed to
> work?
> >>
> >> Thanks!
> >> Koichi
> >>
> >>
> >>
> >>
> >
>
>
>
> --
> thanks
> ashish
>
> Blog: http://www.ashishpaliwal.com/blog
>
> My Photo Galleries: http://www.pbase.com/ashishpaliwal
>

Re: Question about getting client's address

Posted by Ashish <pa...@gmail.com>.
On Tue, Feb 17, 2009 at 5:39 PM, Sai Pullabhotla
<sa...@jmethods.com> wrote:
> The getClientAddress returns the IP Address of the client that
> connected/logged into the server. If the client used a Router to connect to
> the server over the Interner, the router's IP address is what the server
> will see as the connected client.

I hope, you mean, the public IP used by the client?

>
> I'm not sure on your second question as I do not see a getHostAddress()
> method in the FTPSession. Please clarify further.
>
> Thanks.
>
> Sai Pullabhotla
> Phone: (402) 408-5753
> Fax: (402) 408-6861
> www.jMethods.com
>
>
>
> On Mon, Feb 16, 2009 at 7:13 PM, Koichi Tsunoda <ic...@hotmail.com>wrote:
>
>> Hey all,
>>
>> It seems like if I do ftpSession.getClientAddress().toString() in an Ftplet
>> methods (onLogin, etc.), it won't get the actual user's address for me. I'm
>> wondering if that is because of NATs/Firewalls/etc., or if it's a bug? It
>> seems to get the last address the "hop" came from, rather than the original
>> origin.
>>
>> On the side note, if I do ftpSessoin.getHostAddress().toString(), it'll get
>> the internal IP, rather than the external IP address that the user used to
>> ftp to that machine. Is that also behaving the way it's supposed to work?
>>
>> Thanks!
>> Koichi
>>
>>
>>
>>
>



-- 
thanks
ashish

Blog: http://www.ashishpaliwal.com/blog

My Photo Galleries: http://www.pbase.com/ashishpaliwal

Re: Question about getting client's address

Posted by Ashish <pa...@gmail.com>.
On Wed, Feb 18, 2009 at 12:58 AM, Koichi Tsunoda <ic...@hotmail.com> wrote:
> Hey there,
>
> On Feb 17, 2009, at 4:09 AM, Sai Pullabhotla wrote:
>
>> The getClientAddress returns the IP Address of the client that
>> connected/logged into the server. If the client used a Router to connect
>> to
>> the server over the Interner, the router's IP address is what the server
>> will see as the connected client.
>>
>> I'm not sure on your second question as I do not see a getHostAddress()
>> method in the FTPSession. Please clarify further.
>
> Oops, I meant FTPSession.getServerAddress.
>
> Here's the behavior that I see for each, using this basic flow (please
> correct me if I have over simplified things and that I'm wrong in describing
> it this way):
>
> Server's Local IP (1.1.1.1) <-NAT-> Server's External IP (2.2.2.2) <-->
> User's router/public IP (3.3.3.3) <-NAT-> User's local IP (4.4.4.4)
>
> FTPSession.getClientAddress: Server's External IP (2.2.2.2)
> FTPSession:getServerAddress: Server's Local IP (1.1.1.1)

Well, the behavior is correct. For NATed IP's, typically we use proxy servers.
External IP is confusing, public IP would be a more appropriate term.

In simple words, if you loose source IP, you can't return back a response.
Router's don't act as proxy servers. So your proxy server did a NAT, maintained
information, to whom it has allocated the IP (and optionally port),
and once the response
is returned back from Server, it consults the table to find out the owner.

Hope it simplifies things.

>
> I would've expected FTPSession.getClientAddress to return User's
> router/public IP of 3.3.3.3. I suppose it returns 2.2.2.2 instead because
> the server is behind a NAT/firewall, and the last IP that it knows that it's
> coming from is the one immediately behind the NAT. Is that correct?
>
> Thanks!
> Koichi
>

Re: Question about getting client's address

Posted by Koichi Tsunoda <ic...@hotmail.com>.
Hey there,

On Feb 17, 2009, at 4:09 AM, Sai Pullabhotla wrote:

> The getClientAddress returns the IP Address of the client that
> connected/logged into the server. If the client used a Router to  
> connect to
> the server over the Interner, the router's IP address is what the  
> server
> will see as the connected client.
>
> I'm not sure on your second question as I do not see a  
> getHostAddress()
> method in the FTPSession. Please clarify further.

Oops, I meant FTPSession.getServerAddress.

Here's the behavior that I see for each, using this basic flow (please  
correct me if I have over simplified things and that I'm wrong in  
describing it this way):

Server's Local IP (1.1.1.1) <-NAT-> Server's External IP (2.2.2.2) <-- 
 > User's router/public IP (3.3.3.3) <-NAT-> User's local IP (4.4.4.4)

FTPSession.getClientAddress: Server's External IP (2.2.2.2)
FTPSession:getServerAddress: Server's Local IP (1.1.1.1)

I would've expected FTPSession.getClientAddress to return User's  
router/public IP of 3.3.3.3. I suppose it returns 2.2.2.2 instead  
because the server is behind a NAT/firewall, and the last IP that it  
knows that it's coming from is the one immediately behind the NAT. Is  
that correct?

Thanks!
Koichi

> Thanks.
>
> Sai Pullabhotla
> Phone: (402) 408-5753
> Fax: (402) 408-6861
> www.jMethods.com
>
>
>
> On Mon, Feb 16, 2009 at 7:13 PM, Koichi Tsunoda <ichikoo315@hotmail.com 
> >wrote:
>
>> Hey all,
>>
>> It seems like if I do ftpSession.getClientAddress().toString() in  
>> an Ftplet
>> methods (onLogin, etc.), it won't get the actual user's address for  
>> me. I'm
>> wondering if that is because of NATs/Firewalls/etc., or if it's a  
>> bug? It
>> seems to get the last address the "hop" came from, rather than the  
>> original
>> origin.
>>
>> On the side note, if I do ftpSessoin.getHostAddress().toString(),  
>> it'll get
>> the internal IP, rather than the external IP address that the user  
>> used to
>> ftp to that machine. Is that also behaving the way it's supposed to  
>> work?
>>
>> Thanks!
>> Koichi
>>
>>
>>
>>




Re: Question about getting client's address

Posted by Sai Pullabhotla <sa...@jmethods.com>.
The getClientAddress returns the IP Address of the client that
connected/logged into the server. If the client used a Router to connect to
the server over the Interner, the router's IP address is what the server
will see as the connected client.

I'm not sure on your second question as I do not see a getHostAddress()
method in the FTPSession. Please clarify further.

Thanks.

Sai Pullabhotla
Phone: (402) 408-5753
Fax: (402) 408-6861
www.jMethods.com



On Mon, Feb 16, 2009 at 7:13 PM, Koichi Tsunoda <ic...@hotmail.com>wrote:

> Hey all,
>
> It seems like if I do ftpSession.getClientAddress().toString() in an Ftplet
> methods (onLogin, etc.), it won't get the actual user's address for me. I'm
> wondering if that is because of NATs/Firewalls/etc., or if it's a bug? It
> seems to get the last address the "hop" came from, rather than the original
> origin.
>
> On the side note, if I do ftpSessoin.getHostAddress().toString(), it'll get
> the internal IP, rather than the external IP address that the user used to
> ftp to that machine. Is that also behaving the way it's supposed to work?
>
> Thanks!
> Koichi
>
>
>
>