Automatically setup network config ifcfg-eth0?
I thing this will work:

In /init.rc add

service ethernet /eth0.sh


and create /eth0.sh

#!/system/bin/sh

netcfg eth0 up 192.168.0.2


Still got problems chainging the ramdisk but that should work.

See http://elinux.org/Android_Networking



I was not able to change the ramdisk so I made a simple app the does run the netcfg command after boot and after USB device is attached.

Here are the key points for this:

&lt;manifest ...
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /&gt;
  &lt;uses-feature android:name="android.hardware.usb.host" /&gt;
  &lt;uses-permission android:name="android.permission.USB_PERMISSION" /&gt;
  &lt;application ... &gt;
    &lt;receiver
        android:name=".MyBroadcastReceiver"
        android:enabled="true"
        android:exported="true" &gt;
        &lt;intent-filter&gt;
            &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
            &lt;action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" /&gt;
        &lt;/intent-filter&gt;
    &lt;/receiver&gt;
...


and the sudo function in the receiver:

public static void sudo(String...strings) {
    try{
        Process su = Runtime.getRuntime().exec("su");
        DataOutputStream outputStream = new DataOutputStream(su.getOutputStream());

        for (String s : strings) {
            outputStream.writeBytes(s+"\n");
            outputStream.flush();
        }

        outputStream.writeBytes("exit\n");
        outputStream.flush();
        try {
            su.waitFor();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        outputStream.close();
    }catch(IOException e){
        e.printStackTrace();
    }
}