On Wed, Feb 18, 2009 at 12:58 AM, Koichi Tsunoda <[email protected]> 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
>

Reply via email to