How to "talk" to a "parent" IP in a subnet?
1
vote
1
answer
590
views
I have access to just *nix systems. Either NetBSD and/or bare Linux-based OS.
So my question comes from the fact that
ADB
is not widely available on all platforms, if so is very hard to install or obtain (having access to internet, get super user access, etc).
Anyways, RNDIS
functionality is already offered by almost all Android devices. Allowing the phone to become a "router" will give me the option to use netcat because I can just set up a "server" and get/receive files bidirectionally, without the need of getting ADB
involved.
Like this:
NetBSD
dhcpcd -n urndis0
Linux
udhcpd -i usb0
That will give me an IP within a subnet set up by Android. Something like: 192.168.32.225/24
So, essentially the phone acts as a router, giving my *nix computer an IP belonging to a subnet set up by the phone itself. I would like to just open a port on my localhost 127.0.0.1
with netcat
and just transfer files.
Something like this:
On Android device:
busybox nc -v -w3 -l -p 3838
On *nix system (Linux in the example below):
nc -v -w3 **(upper higher loopdevice outside subnetted network) 127.0.0.24** 3838
And be able to access the "higher" network/loopdevice already existing within Android's own local network.
Let's assume the Android phone is another host sharing it's connection and assigning a subnet IP to my computer for that matter so my \*nix box can access the internet:
**My question is then: Can I use the the IP (which is within a subnet) provided by the RNDIS interface of the Android phone to access the local network of the phone itself with just standard tools in \*nix?**
**Solution**
@Frédéric Loyer Thank you very much!
Wonderful, with this method there is no need for me to get adb
on each computer I'm on, most of the time what I got is busybox nc
and or ssh
. This is perfect, with this I can even ssh into my Android without even needing an active connection on the phone itself, isn't amazing!?
Here is what I did.
# This makes my computer to request an IP to my phone.
$sudo udhcpc -i usb0
# Since I got access to busybox-only most of the time, this gives me the IP from the "router" which is the phone.
$route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.42.129 0.0.0.0 UG 0 0 0 usb0
127.0.0.1 * 255.255.255.255 UH 0 0 0 lo
192.168.42.0 * 255.255.255.0 U 0 0 0 usb0
# ifconfig output shows me the new IP assigned to usb0 on my computer.
After this is just a matter of ssh'ing onto my phone or open ports with Termux. Amazing! :)
Asked by abacox
(143 rep)
Oct 28, 2021, 12:17 AM
Last activity: Oct 29, 2021, 03:05 AM
Last activity: Oct 29, 2021, 03:05 AM