ping  fails, but ping -I eth5  works in Android shell I am trying to enable Ethernet on my Android-7.1.2. Now, it can acquire ip address from DHCP server. ifconfig shows that the Ethernet port can receive lots of packets, but just sends a few out, as below:

  eth5      Link encap:Ethernet  HWaddr 00:04:9f:04:4d:51

  inet addr:10.193.20.83  Bcast:10.193.20.255  Mask:255.255.255.0

  inet6 addr: fe80::204:9fff:fe04:4d51/64 Scope: Link

  UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

  RX packets:10513 errors:0 dropped:0 overruns:0 frame:0

  TX packets:22 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:1000

  RX bytes:926773 TX bytes:2204

  Memory:1aea000-1aeafff


And ping -I eth5 10.193.20.64 can work:

layerscape:/ # ping -I eth5 10.193.20.64

PING 10.193.20.64 (10.193.20.64) from 10.193.20.83 eth5: 56(84) bytes of data.

64 bytes from 10.193.20.64: icmp_seq=1 ttl=64 time=0.345 ms

64 bytes from 10.193.20.64: icmp_seq=2 ttl=64 time=0.354 ms


However, ping 10.193.20.64 fails with:

layerscape:/ # ping 10.193.20.64

connect: Network is unreachable


And here is my route:

layerscape:/ # route -n


Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

10.193.20.0     0.0.0.0         255.255.255.0   U     0      0        0 eth5


What am I losing?
Finally found the solution for this issue:

layerscape:/ # ip rule add from all lookup main pref 0