user5275692 user5275692 - 1 year ago 110
Python Question

How do I determine what ip range a device is using?

This is kind of a weird problem, basically I have a computer connected to a machine via ethernet cable. There is no other network or internet access. The machine sets up a network which allows you to telnet into it.

I need the simplest way possible to determine the ip range the device is using. This would be turned into a python script. It is not just the obvious 192.168.x.x

I'm looking at the 'arp' command, but also a library called 'netifaces'. I'm not sure if there's something simpler I could use. It has to work for Linux, OSX and Windows. The machine is running an android OS

Basically, I just need to be able to determine what ip ranges the device is currently using in the simplest possible way.

The command 'arp -a' seems to be the most promising right now.

Answer Source

The IPv4 Link-Local range of is used by APIPA for hosts to assign IP addresses when an interface has no other way to obtain an address. There are some rules about this range, e.g. you cannot subnet the range, it can't be routed, etc. See RFC 3927, Dynamic Configuration of IPv4 Link-Local Addresses for more information.

You really need to determine if the equipment on the other end of your link is using this range. If it is a specialized device, it probably does not, and it will have a fixed address which was manually assigned. If this is the case, you will not be able contact it with your Link-Local address.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download