UDP communication between PC and Android via ethernet 1. I am testing with a rooted nexus 5 operating on lollipop 5.1.

2. This is all with no wifi connection.

I am trying to send UDP packets between a PC and an android device with an otg cable and ethernet dongle. When connected the PC thinks the android is an unidentified network(No internet access) and the android recognizes the device as eth0 with an IP of 0.0.0.0. 

eth0   UP   0.0.0.0


I add an IP to the eth0 by running the following unix script:

#!/bin/sh
netcfg eth0 up
ifconfig eth0 192.168.1.200 netmask 255.255.255.0
route add default gw 192.168.1.1 dev eth0
ping -c 1 192.168.1.1


After running the script eth0 appears in the command line as:

eth0   UP   192.168.1.200


I am using wireshark to track packets and when I try to open an interface between the PC and android I get an error as follows:

(Error opening adapter: The system cannot find the device specified. (20)).

Also, when I try to PING the PC from the android I get 100% packet lost.

So it seems like I don't have a connection between PC and android.
Any input on the topic would be very helpful.
I think reverse tethering would solve your problem. 

Android reverse tethering steps:

Note: Works only in a rooted Android phone.


Connect Android device via USB. 
Enable USB tethering. To do so, go to Settings &rarr; More... &rarr; Tethering &amp; mobile hotspot &rarr; Usb tethering.
On host machine, type: 

$ ifconfig usb0 10.42.0.1 netmask 255.255.255.0 
$ echo 1 &gt; /proc/sys/net/ipv4/ip_forward 


Command for sudo will be: 

$ sudo 'echo 1 &gt; /proc/sys/net/ipv4/ip_forward' 

On Android device (for this step you must install ADB on host PC), type:

$ adb shell 
$ su 
$ netcfg rndis0 dhcp


If it does'nt get the IP address then assign it manually: 

$ netcfg rndis0 10.42.0.2 netmask 255.255.255.0 
$ route add default gw 10.42.0.1 dev rndis0 



Now internet would be working in the Android phone. 

To check , try the command ping www.google.com.

It works for me.