How can we identify distinct computers/devices on an intranet? This is possible using cookies but that is not foolproof. I am expecting something on the lines of finding local ip address. It would be great if you mention some tools(libraries) required to integrate it with an intranet application. The application is designed in Python(Django).
-
3Maybe MAC addresses? See http://comments.gmane.org/gmane.comp.python.django.user/136648. – Frédéric Hamidi Feb 22 '12 at 15:04
-
1If you run your own DNS and (either DHCP or everyone has static IPs) and can trust the security that no machines will be tampered with or spoofed, then a simple IP -> host look-up should suffice. – platinummonkey Feb 22 '12 at 15:08
-
@FrédéricHamidi MAC address can only be useful if the server and the client are on the same network segment. – tMC Feb 22 '12 at 16:01
2 Answers
You can get the client (computer connecting to your web server) IP address from the HttpRequest object. If your Django view is def MyView(request):
you can get the IP from request.META.get('REMOTE_ADDR')
. Is that what you're looking for?

- 8,106
- 4
- 46
- 54
You could take a look at the HttpRequest documentation on Django: https://docs.djangoproject.com/en/dev/ref/request-response/
There you'll find that you can know the remote IP address of the user with the request object on your view or middleware using request.META["REMOTE_ADDR"]
I use this in a multihomed server where the requests for the internal LAN come to a local IP Address and the public requests goes to a public IP Address, there comparing the REMOTE_ADDR to the beginning of my internal LAN address i can know if it is an internal request or not.

- 1,754
- 1
- 10
- 9
-
The issue with using IP address alone is they are more then likely going to change on a dhcp based network. As a user, of a dhcp network, i can force a change to my ip address by changing my NICs mac address. – tMC Feb 22 '12 at 17:34
-
You are right, my answer was focused on identifying if the user was in the intranet or not. Not on the fact that he needed to identify each of them uniquely. MAC Address is more reliable for that, but there are methods to change MACs also, and users from Laptops for example can sometimes be connected on wireless and after some time on wire. I guess it depends on the level of error probability the user can accept. – Xbito Feb 22 '12 at 18:18