unable to configure DNS/resolver on USB0

2,360 views
Skip to first unread message

Allen Curtis

unread,
Jul 16, 2014, 2:05:39 AM7/16/14
to android...@googlegroups.com

Hello,

I am porting Android 4.3 to a device that does not have WiFi or a traditional Ethernet interface. We are using a Gadget CDC USB ethernet interface.

Getting general IP communications working was easy enough. I can ping using an IP address. It even works correctly with a gateway.

The current problem is getting named to resolve over the usb interface. Nothing seems to make a difference. Here is what has been tried:

  • - configuration of static IP using ifconfig
  • - configuration of default gateway with 'busybox route'
  • - setprop dhcp.usb0.dns1,dns2,ipaddress,gateway,….
  • - ndc resolver flushif usb0, ndc resolver flushdefaultif, ndc resolver setifdns usb0 <dnsip>, ndc resolver setdefaultif usb0
  • - cleared all the rules from iptables

It seems to be impossible to get named to use this interface. We even renamed tried renaming usb0 to eth0 in the kernel sources.

Help!?

Thanks

Allen

Robert Greenwalt

unread,
Jul 16, 2014, 12:47:59 PM7/16/14
to ajcu...@ac2enterprises.com, android-porting
the ndc commands are required.  static/dynamic ip doesn't really affect this and the setprop stuff is ignored.

Are you able to ping the dns servers from the device?  I believe the google 8.8.8.8 servers are pingable, so you could use them for this test.  Once you find you can reach the servers, set them using ndc.  Note that the format for setifdns is:
setifdns <iface> <domains> <dns1> <dns2> ..."
If you don't have a search domain use two spaces between <iface> and <dns1>.  This could be the crux of your issue.

R


--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Allen Curtis

unread,
Jul 16, 2014, 1:48:54 PM7/16/14
to Robert Greenwalt, android-porting
Hello Robert,

I can ping the DNS server but nslookup fails. This is what I get. (Note: eth0 is actually usb0)

root@sabresd_6dq:/ # ndc resolver setifdns eth0 192.168.10.40 192.168.10.45
200 0 Resolver command succeeded
root@sabresd_6dq:/ # busybox nslookup yahoo.com
Server: 0.0.0.0
Address 1: 0.0.0.0

nslookup: can't resolve 'yahoo.com'
1|root@sabresd_6dq:/ # ifconfig
root@sabresd_6dq:/ # ifconfig eth0
eth0: ip 192.168.1.2 mask 255.255.255.0 flags [up broadcast running multicast]
root@sabresd_6dq:/ # ping 192.168.10.40
PING 192.168.10.40 (192.168.10.40) 56(84) bytes of data.
64 bytes from 192.168.10.40: icmp_seq=1 ttl=126 time=12.4 ms
64 bytes from 192.168.10.40: icmp_seq=2 ttl=126 time=1.61 ms
^C
--- 192.168.10.40 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.618/7.044/12.470/5.426 ms
root@sabresd_6dq:/ # ping 192.168.10.45
PING 192.168.10.45 (192.168.10.45) 56(84) bytes of data.
64 bytes from 192.168.10.45: icmp_seq=1 ttl=126 time=10.5 ms
64 bytes from 192.168.10.45: icmp_seq=2 ttl=126 time=9.54 ms


Robert Greenwalt

unread,
Jul 16, 2014, 1:56:40 PM7/16/14
to Allen Curtis, android-porting
you also need to set eth0 as your default for dns via
resolver setdefaultif <iface>

Allen Curtis

unread,
Jul 16, 2014, 3:03:14 PM7/16/14
to Robert Greenwalt, android-porting
Interesting…

1. ping yahoo.com - WORKS!

2. busybox nslookup yahoo.com - does not work, same results as before

Is there another utility for testing DNS resolution?

Thanks!

Robert Greenwalt

unread,
Jul 16, 2014, 5:04:35 PM7/16/14
to Allen Curtis, android-porting
Java's InetAddress.getByName()?

I'll file a bug to investigate nslookup in busybox.

Allen Curtis

unread,
Jul 16, 2014, 5:30:35 PM7/16/14
to Robert Greenwalt, android-porting
Robert,

Actually it appears that anything in busybox that uses DNS is broken. "busybox ping" does not work either.

Thanks for the help! We are moving again.

Allen


Robert Greenwalt

unread,
Jul 16, 2014, 6:14:05 PM7/16/14
to Allen Curtis, android-porting
It's almost certainly using linux conventions (resolv.conf) that android has moved away from and can't find out the dns servers.

Allen Curtis

unread,
Aug 12, 2014, 4:05:48 PM8/12/14
to Robert Greenwalt, android-porting
Hello Robert,

Yesterday I started going down the dhcpcd.conf route.

Created a dhcpcd.conf
interface usb0
static ip_address=192.168.1.2/24
static routers=192.168.1.254
static domain_name_servers=10.10.17.117 10.10.19.117

I noticed from logcat that init was looking for a dhcpcd_usb service. I am not sure what all the options mean to dhcpcd. They are not descibed when you ask for help.

Possible init.rc change based on other device examples.
a. service dhcpcd_usb0 /system/bin/dhcpcd -ABKL
class late_start
disabled
oneshot

b. service dhcpcd_usb0 /system/bin/dhcpcd -AL
class late_start
disabled
oneshot

I am not sure these will work though since they specify the "disable" option. Although init is looking for "service dhcpcd_usb0" it doesn't appear to be starting it explicitly. Do I also need to implement a hook?

Can you point me to an example of configuring the interface as described using LinkProperties and ConnectivityService?

Best Regards,
Allen Curtis

On Aug 12, 2014, at 12:24 PM, Robert Greenwalt <rgree...@google.com> wrote:

> Alot of stuff is continuing to get locked down via selinux security policies. I wouldn't be surprised if ndc is whitelisted but your app is not.
>
> The normal way of configuring dns is having whatever android transport communicate it's ip config to ConnectivityService via a LinkProperties instance. Android != Linux and various traditional scripts/tools may not be supported. The NDC tool is a way to hack stuff during device bringup and is not intended for production use.
>
> R
>
>
> On Mon, Aug 11, 2014 at 10:51 AM, Allen Curtis <ajcu...@ac2enterprises.com> wrote:
> Robert,
>
> If the setprop stuff is ignored, what is the proper way of configuring the DNS?
>
> A weird problem I ran into is that calling the "ndc resolver" methods using popen() in a C program crashes. Typing the exact same commands on the command line works. Should I do this in a shell script as a service from init?
>
> Best Regards,
> Allen Curtis
>
> email: ajcu...@ac2enterprises.com
> phone: (949) 874-5566
> KeyID: 224003C35935A9EC

dandi...@gmail.com

unread,
Nov 27, 2014, 12:24:54 PM11/27/14
to android...@googlegroups.com, ajcu...@ac2enterprises.com
HI, Robert

But for Android 5.0, the command for resolver is changed.

 
1. set dns: "resolver setnetdns <netId> <domains> <dns1> <dns2> ..."
2. but setdefaultif has been deleted, how could we set the default interface in Android 5.0


with setting the IP to usb0 and set dns "resolver setnetdns <netId> <domains> <dns1> <dns2> ..."
  I could ping yahoo.com, but the Browser could not surf the Internet, error info:
  net:: ERR_ADDRESS_UNREACHABLE.

What should we do to let the Browser/Apps to serf the Internet

dandi...@gmail.com

unread,
Nov 27, 2014, 12:43:45 PM11/27/14
to android...@googlegroups.com
HI, Robert

resolver setdefaultif <iface> has been removed on Android 5.0, how could we make it now.

with seting the IP for USB0 and "resolver setnetdns <netId> <domains> <dns1> <dns2> ..."
I could ping yahoo.com in shell, but could not surf the internet in Broswer/Apps, 
I also tried "network default set usb0", but not work too.
Anything I missed?

On Thursday, July 17, 2014 1:56:40 AM UTC+8, Robert Greenwalt wrote:

Allen Curtis

unread,
Nov 30, 2014, 12:03:40 AM11/30/14
to android...@googlegroups.com
Are you building your own AOSP? Try listing "usb" as a wired ethernet device name.

Checkout the file:  ./frameworks/base/core/res/res/values/config.xml

around line 221
    <!-- Regex of wired ethernet ifaces -->
    <!-- <string translatable="false" name="config_ethernet_iface_regex">eth\\d</string> -->
    <string translatable="false" name="config_ethernet_iface_regex">usb\\d</string>

Allen Curtis

unread,
Nov 30, 2014, 12:06:21 AM11/30/14
to android...@googlegroups.com
I forgot to mention, the information provided was for JB. LP probably has similar configuration files.


On Thursday, November 27, 2014 9:43:45 AM UTC-8, dandi...@gmail.com wrote:

dandi...@gmail.com

unread,
Dec 1, 2014, 3:56:02 AM12/1/14
to android...@googlegroups.com
HI, Allen

I have tried on Android 4.4 device, don't need to update the Regex, it work.
And on Andorid 5.0, seems the problem is that framework didn't use the usb0 as default interface, and it think it didn't connect to network.
but ping yahoo.com is work in shell.

So I think we should set the default interface as usb0, but "resolver setdefaultif" didn't support in 5.0. I don't know how to set the default interface now.

mpquser mpquser

unread,
Jan 14, 2015, 8:00:01 PM1/14/15
to android...@googlegroups.com
I am facing a similar problem with Android 5.0
With KitKat, I used the following command for DNS:
ndc resolver setifdns eth0 localhost IP1 IP2
This command does not work with Android 5.0
I was not able to find out the solution online. Can someone please help me with this?

Regards,
gi

mpquser

unread,
Jan 15, 2015, 6:44:11 PM1/15/15
to android...@googlegroups.com
never mind, got it to work using below cmd
ndc resolver setnetdns eth0 localhost IP1 IP2

Di Fi

unread,
Jan 13, 2017, 4:49:07 PM1/13/17
to android-porting
ip route add default via USB_GATEWAY table 10
ip rule add from all table 10

I tested on 6 and 7.1 version

пятница, 16 января 2015 г., 2:44:11 UTC+3 пользователь mpquser написал:
Reply all
Reply to author
Forward
0 new messages