Using "ndc" commands in Android 5

11,757 views
Skip to first unread message

Peter Mackenthun

unread,
Apr 24, 2015, 10:14:43 AM4/24/15
to android...@googlegroups.com

Hello,

 

I am trying to port a RIL driver from Android 4.4 (Kitkat) to Android 5 (Lollipop) and got stuck with establishing a data connection using a LTE radio.

Under Android 4.4 the procedure was going like this:

Android calls the RIL with RIL_REQUEST_SETUP_DATA_CALL. The RIL will do the following steps:

The RIL configures the radio to start a data connection. The data connection will become available as an Ethernet card (“eth0”) to the system.

The RIL calls “netcfg dhcp eth0” to get the IP addresse, DNS, etc.

The RIL calls “ndc resolver setdefaultif eth0” to make the radios data connection the default connection.

The RIL calls “ndc resolver setifdns eth0 x.x.x.x y.y.y.y” to the set the DNS.

This works very well in Android 4.4, the internet connection is available on the Android browser and on the Linux command shell.

 

In Android 5 I have got the problem that the two “ndc resolver” commands no longer exist. While browsing through the Android source code (CommandListener.cpp) I noticed that there is a new command “ndc resolver setnetdns”. This command looks like it is a replacemend for the “setifdns”, but this command wants a numeric “netID” instead of the interface name and I don’t know where I could get that netID or how it maps to my “eth0” device. For the “setdefaultif” command I didn’t find any kind of replacement.

As a result the data connection is active in the radio, “netcfg” shows a valid IP-address, “getprop” shows, that the IP-Address and DNS server are known to Android, but the data connection is still not usable. Neither the Android Browser gets an internet connection nor is the internet available on the shell. Commands like “ping www.google.com” or “ping 173.194.113.19” (valid IP address) on the Linux shell always fail.

 

How can I get my internet connection working? How do I use the new “ndc resolver” commands?

I would appreciate any help I could get.

 

Thanks,

Peter

Peter Mackenthun

unread,
May 8, 2015, 10:16:46 AM5/8/15
to android...@googlegroups.com
If someone is interested, I solved my problem with the following command sequence:
ndc network create 100
ndc network interface add 100 eth0
ndc network route add 100 eth0 <GATEWAY>/24
ndc network route add 100 eth0 0.0.0.0/0 <DNS1> <DNS2>
ndc resolver setnetdns 100 localdomain <DNS1> <DNS2>
ndc network default set 100

regards,
Peter

Gohil Bhagirath

unread,
Jun 23, 2015, 11:29:38 PM6/23/15
to android...@googlegroups.com
Hi Peter,

I have similar use case where on my Android 5.0 based custom hardware, I have Wi-Fi and Ethernet interface. Both of them work fine with Android 4.4 release through command line and browser.
Wi-Fi works well in Android 5.0 through command line and browser. However, I want to enable Ethernet connectivity through browser which is not working and I get ERR_NOT_REACHABLE error from browser.

Here are the settings I tried and the strange thing is, I am able to ping www.google.com from my hardware using command line on Ethernet interface. If I tried to do so from browser, it gives above error.

Settings


netcfg eth0 down
ndc network destroy 100
ndc interface clearaddrs eth0

ifconfig eth0 10.99.4.11 netmask 255.255.252.0
route add default gw 10.99.5.1 dev eth0
ndc resolver setnetdns eth0  8.8.8.8 8.8.4.4
ping www.google.com (### this works well from command line but with this, browser doesn't work: ERR_NOT_REACHABLE)

Then I followed your steps as below:

ndc network create 100
ndc network interface add 100 eth0
ndc network route add 100 eth0 10.99.4.0/22 (This is taken from the output of ip route show, so I presume my gateway is 10.99.4.0)
ndc resolver setnetdns 100 localdomain 192.168.6.55 192.168.6.56 (My DNS addresses are 192,168.6.55 and 192.168.6.56)
ndc network default set 100 (Untill this command, the status is: ping works fine from command line for google, but after I enter this command, command line based ping stops and I am unable to get browser working as was the previous case).

Can you please help me get the right set of commands for getting Ethernet connectivity working from browser?

Regards,
Bhagirath

Plamen Dimitrov

unread,
Jul 31, 2016, 11:08:28 AM7/31/16
to android-porting
Here is what worked for me:

I also have multiple network adapters on an Android device, let's say one is static and one DHCP. I configure the static with

ifconfig eth0 192.168.10.1 netmask 255.255.255.0

The DHCP one depends on the Android version:

# KitKat, Lollipop
netcfg eth1 up
netcfg eth1 dhcp

# Marshmallow
ifconfig eth1 up
dhcpcd eth1

The DNS needs a separate configuration:

# KitKat
ndc resolver setdefaultif eth1
ndc resolver setifdns eth1 "" 10.10.0.254

# Lollipop, Marshmallow
ndc network create 100
ndc network interface add 100 eth1
ndc network route add 100 eth1 0.0.0.0/0 10.11.0.254
ndc network create 10
ndc network interface add 10 eth0
ndc network route add 10 eth0 0.0.0.0/0 192.168.11.254
ndc resolver setnetdns 100 "" 10.11.0.254

ndc network default set 100

If I don't set the extra network for eth0 with the extra 0.0.0./0 route, the pinging of 192.168.11.1 from outside will fail for Lollipop\Marshmallow (the reverse direction goes through) even though DNS lookups from the device will work.
Reply all
Reply to author
Forward
0 new messages