Programmatically find the IP address of the desktop over USB tethering

左心房为你撑大大i 提交于 2019-12-08 03:43:27

问题


Is there a way to find the IP address of the desktop machine connected the android phone after USB tethering is turned on?

Does android assign a fixed IP address to the desktop? Or does it assign a dynamic address (dhcp)? Is there a PPP connection created between the phone and machine?


回答1:


With USB tethering it seems that all android devices use the same static addresses, the android device using tcpdump is 192.168.42.129

The attached device will get a DHCP provided address in the same address range.

I listen to a port on my android app and have a udev rule to push the dhclient address back to that port on my app.




回答2:


AFAIK, in usb tethering mode the phone is acting as the computer's modem, so the PC's IP would be the phone's IP.



来源:https://stackoverflow.com/questions/3612069/programmatically-find-the-ip-address-of-the-desktop-over-usb-tethering

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!