Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure a new network interface in Android

I am trying to configure a new network interface on Android tablet (v3.2). From terminal application I can "ifconfig eth0 192.168.11.14 netmask 255.255.255.0 up" and everything works fine (ethernet cable is connected trough USB-Ethernet dongle)

I want to make this configuration persistent, but it looks like there is no 'interfaces' file in Android. Where is network configuration file located? Do I need to create new one? Where?

Thanks,

like image 940
lmm Avatar asked Nov 04 '22 12:11

lmm


1 Answers

yet another late answer... scoured the internet and couldn't find any decent answer until I checked out /etc/init.sh ...

I'm using an Android Oreo vmware image for testing purposes and here are the steps that I used to add static IP to Android on boot:

  1. Open Terminal Emulator (if not present install from Play Store)
  2. type su
  3. type vi /etc/init.sh
  4. type i
  5. look for function do_init()
  6. before the closing curly brace (}), type post_init_network
  7. create new line after the closing curly brace (}), type

    function post_init_network() { ifconfig 192.168.63.122/24 up
    }

    change the ip and subnet as needed...

  8. press :wq! to save and exit vi

  9. power of and power on Android.
  10. To check Static IP: open Terminal Emulator again after power on, type su, then type ifconfig

NOTE: I encounter this issue where I can't get an IP from NAT network using 2 interfaces where the first interface is set to static IP and the other DHCP, just power on and power off Android until you can get an internet connection.

like image 190
Mhyk Gyver Avatar answered Dec 01 '22 09:12

Mhyk Gyver