问题
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