How to determine whether client and server are on the same host

Chris Angelico rosuav at
Tue Nov 26 13:26:26 CET 2013

On Tue, Nov 26, 2013 at 11:13 PM, Malte Forkel <malte.forkel at> wrote:
> That is a clever idea. While I can't modify the server, I could look at
> the files on the host running the application and try to determine if
> they fit to information from the server about its files. If both match,
> I could then conclude that application host and server host probably are
> the same. But, I still couldn't be sure.

If you deliberately create a file with a random name, the chances of
one existing with the same name on the client are infinitesimal unless
someone's deliberately trying to confuse things... in which case I
wouldn't worry about it.

> Isn't there anything in telnetlib that can differentiate between a local
> connection and a remote connection?

No, because there's no such thing as a "local connection". For
instance, I have two internet connections at my house, and I can
telnet out on one of them and back in on the other - but both
connections are NATted, so the machine itself doesn't have an IP that
matches what I'm talking about here. I could have a socket connection
from w.x.y.z port 12345 to a.b.c.d port 80, and there's no way
telnetlib would recognize that as coming back to the same computer,
because this computer's IP addresses are all RFC 1918 ones (,,

> Or may be some unique property of
> each host that I could use?

That's what I was intending the file to be. You could also look for
some kind of signature, like the MAC address of the first network
interface, but that's going to be no more reliable and potentially a
lot harder to recognize.


More information about the Python-list mailing list