NETWORK IS UNREACHABLE LINUX SSH ANDROID
This probably won't integrate well with the Android system which might shuffle rules around when applications are installed or started and one can't tell what's left with iptables/ nftables (or even along SELinux, tc etc.) about blocking access. Or if you don't care that any user so any application can use usb0 simply: ip rule add pref 998 lookup main If you want to allow root to use first the main routing table thus avoiding the unreachable fate, among multiple possible choices: ip rule add pref 998 uidrange 0-0 lookup main I guess there are specific Android APIs to register such rules when an application is installed. Many rules receive a firewall mark probably set by equivalent complex iptables rules to select specific routing rules per application (and its specific UID too).
In particular routing rule 10500 allows (only) root to use outgoing interface ccmni1, but oif isn't about allowing a packet to be selected to this interface, it's about allowing a packet from a socket bound to this interface (using SO_BINDTODEVICE) to be selected ( oif isn't a direct equivalent of iif which is used for routed packets, and iif lo is also a special case for non-routed packets). It's a bit frail to do something manually over this mechanism. Local 192.168.100.86 dev usb0 proto kernel scope host src 192.168.100.86īroadcast 192.168.100.255 dev usb0 proto kernel scope link src 192.168.100.86Īndroid uses a lot of routing rules and tables, probably one per application.Īs can be seen, without such rule added and probably its corresponding fwmark, a packet will hit routing rule 32000: unreachable. What other obscure (to me) linux feature could be blocking me here?ĩ99: from all fwmark 0xa/0xffff lookup 2454ġ0000: from all fwmark 0xc0000/0xd0000 lookup 99ġ0500: from all iif lo oif ccmni1 uidrange 0-0 lookup 1003ġ3000: from all fwmark 0x10063/0x1ffff iif lo lookup 97ġ3000: from all fwmark 0xd006c/0xdffff iif lo lookup 1003ġ4000: from all fwmark 0xc0000/0xc0000 iif lo oif ccmni1 lookup 1003ġ5000: from all fwmark 0x0/0x10000 lookup 99ġ6000: from all fwmark 0x0/0x10000 lookup 98ġ7000: from all fwmark 0x0/0x10000 lookup 97īroadcast 127.0.0.0 dev lo proto kernel scope link src 127.0.0.1 There's also SElinux, but I thought that was just a filesystem thing.
for per-uid data usage tracking) but I didn't think that would affect the routing table (and flushing them all doesn't seem to help). I know that android has some funky iptables rules (e.g. When I do the same steps on a different, non-android host, it works fine. But if I try to ping it or ssh to it, I get 'Network is unreachable'. I downed all the other host interfaces to be sure they weren't stealing the route. The gadget assigned me 192.168.100.86/24 and advertised itself over mDNS as 192.168.100.2, so I know the link is working. The usb0 interface appeared I raised it and ran udhcpc on it. I have plugged in my usb gadget (a Mendel linux device). This is on my host device, running Android atop a Linux 4.4 kernel.
RTNETLINK answers: Network is unreachable
What could cause this? $ sudo ip route showĨ5: usb0: mtu 1500 qdisc pfifo_fast state