I'm using bonjour (with java) to try to get IP addresses for devices on a network. I've looked at this question: Get Device IP with Bonjour and am using the InetAdress getByName method (with a resolved host) to get an IP address.
The problem is that this IP address I get doesn't match anything I know about the device! what I really want is the local router assigned IP ad开发者_C百科dress of the device. (in this case it's 192.168.1.146) what I'm getting instead (consistently, every time) is 208.68.xxx.xx
the latter address doesn't seem to be my WAN IP, and I have no idea what it really is... I get that address consistently for every device I connect to... any help would be appreciated! (maybe I need to translate the IP address somehow?)
Use InetAddress.getAllByName(hostName)
instead of InetAddress.getByName(hostName)
-
The device(s) hostname resolves to more than one IP address. The above address returned was actually the search page for my ISP- which obviously is not useful.
精彩评论