Android Networking

Revision as of 15:29, 16 July 2010 by Tim Bird (talk | contribs) (add to category:android)
Jump to: navigation, search

Here are some tips for getting networking working on your Android device.

Setting the DNS server

In my experience, some times the device fails to get it's DNS server correctly from DHCP. The DNS server address is retrieved from system properties.

You can set this manually by typing (on the target):

$ setprop net.eth0.dns1 xx.yy.zz.aa

(replacing with the correct numeric values for your DNS server address)

I have also set the following:

$ setprop net.nds1 xx.yy.zz.aa

This needs to be set each time the system boots. I'm sure there's a way to have 'init' set this, or to put it into persistent properties, but I haven't done that yet.

Configuring a web proxy

The browser looks at system settings stored in a provider database for the http proxy.

The value for http_proxy is set in the following sqlite database: /data/data/

the setting goes in the 'system' table in this database, with a key of 99, a name of 'http_proxy' and a value that is a string containing your proxy server and port. I don't know if you can use a server name rather than just an IP address. I haven't done that.

To set this, on target, do the following:

 # cd /data/data/
 # sqlite3 settings.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite> insert into system values(99,'http_proxy','');

Replace '' with the appropriate address and port for your network configuration.

Since it's only a single line, you can also do this from the command line. You can check that the value is stored properly by typing the following:

# sqlite3 settings.db "select * from system;"

This should show output similar to the following (first part omitted):


This change is persistent, and you should only have to make it once.