HiKey Android - Configure Ethernet - Set Static IP

Hi all,

I am wondering if anyone can give some guidance on how to properly configure Ethernet (using a USB dongle, of course) to use a Static IP / netmask / gateway please? There does not seem to be any built-in Ethernet or Networking configuration items in the Settings area within Android, as I have seen on other devices. Here are the details and steps I have tried thus far…

First and foremost, Android recognizes the eth0 device and DHCP works, and I can browse the internet with Chrome while Wireless is off.

So, without any GUI for manipulating Ethernet (that I have found, anyways), I assume it needs to be done via command line. Using Terminal Emulator on Android does not work, as there are no Root permissions onboard. ADB Shell does offer Root access, but ADB over micro-USB port of course disables the full size USB ports, and eth0 thus disappears from the system at that point. However, ADB via TCPIP over Wi-Fi does work, so I can connect to ADB Shell, run ‘su’, and run:

ifconfig eth0 [IP] netmask [NETMASK]
route add default gw [GATEWAY] dev eth0
setprop net.eth0.dns1 8.8.8.8
setprop net.eth0.dns2 4.4.4.4

At this point, ‘ifconfig -a’ shows the correct settings for eth0. My thought is that disabling Wi-Fi at this point would then turn over networking to the Ethernet device (and of course subsequently kill my ADB session, but that’s fine).

However, I cannot browse the internet with Chrome or Browser at this point. Any hints as to what might be going on here? Any advice on getting Ethernet configured properly if I am not doing correctly?

Thanks for the assistance.

I was able to get online using your instructions above.
If you have access to the serial console, you can use that instead of ADB over TCPIP to setup your ip address so you don’t have to worry about getting your ADB session killed.
Can you ping the gateway or something further out from the board?
Does the same setup work from a PC? If not, this might point to a router configuration issue. Try disabling all security features (DMZ, SPI, filters, etc) first and re-enable them back one by one to see which one is causing the issue.

Well, that is odd. Would you mind posting the output of the ‘route’ command so I can take a look at how you have your addressing configured?

I am thinking that may be my issue.

And, thanks!

You’re welcome. Below is the output of ‘ip route’, but for some reason I could get online by ip only this morning, which seems to indicate some sort of dns issue, but the same setup works fine from my pc.


shell@hikey:/ # ip route
default via 192.168.36.1 dev eth0
192.168.36.0/24 dev eth0  proto kernel  scope link  src 192.168.36.199

Is reserving an ip on your router an option?

Thanks for that, I appreciate it greatly.

Mine is currently showing:

root@hikey:/ # ip route
0.0.0.0/24 via 192.168.1.1 dev eth0
192.168.0.0/24 dev wlan0  proto kernel  scope link  src 192.168.0.109
192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.151

The wlan0 can be ignored, because as I mentioned I turn off Wi-Fi when I am ready to test Ethernet connectivity. (Which btw, today I ordered a UART adapter like you mentioned, because yes this ADB over Wi-Fi is annoying!)

So, I will begin researching how to modify that first line which currently contains 0.0.0.0, as that seems to be the culprit (I think). Or, do you happen to know off the top of your head how to modify / alter it? Otherwise, I shall start my Googling!

Thanks again!

0.0.0.0 looks ok as it can be used to denote ‘default’. Not sure about the ‘/24’ part, but don’t believe that’s the problem though.

What version/month’s release of Android are you using?

I am using the 15.12 Reference Build (so, Marshmallow).

Well, still no luck on this.

One thing I notice that is different when connecting with Ethernet on DHCP versus a static IP is something called “metric” appears to get appended with DHCP. Not sure where it is coming from, or, how to set it manually. Here is my ‘ip route’ output on DHCP:

192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.107 metric 205

Here is what I get after attempting manual ethernet configuration:

192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.151

Alternatively, if I wanted to add back in the native Ethernet Configuration settings utility that I have seen on other devices, does anyone have an idea / suggestion on how to do that? I suspect components cannot be added after it has already been built, so, would I be looking at downloading the source, “enabling” it somewhere, and building from source?

If anyone can provide advice on how to go about this task (or advice on how to just get it running from ADB shell, which seems easier!) would be greatly appreciated.

I went real deep on a search to resolve this and figured out why my own ethernet connection wasn’t working for the browser or other apps.

It has to do with the routing table setup for Android. There’s a rule that causes the main routing table only be used for root (uid 0). As a result the non-root user that the phone applications are running under don’t see the routes that had been added and return with some form of “Network unreachable”.

I’m looking into it more, but this line got, entered via a root shell by way of adb, got most of it resolved:

ip rule add from all lookup main pref 99

Awesome work, thanks Ryan.

The alternatively part where the user are not having the process where it will be going to configure the ethernet where the android will getting the particular process you have the downloading process where it is going to set the static ip from the help of netgear technical support where yioyu will be having the best procedure to vlaudate teh process.