How to see the routing table and dns in adb shell

44,572 views
Skip to first unread message

Joe Petruchi

unread,
May 26, 2009, 2:09:33 AM5/26/09
to android-...@googlegroups.com
Hi All
 
Does anybody knows how we can see the routing table and dns servers in adb shell.
 
Any help in this regard will be great ..
 
Thanks
Joe
 
 
 

Brian Liu

unread,
May 26, 2009, 3:13:56 AM5/26/09
to android-platform
For route table:
$ cat /proc/net/route

For DNS:
$ getprop net.dns1

MIYOKAWA, Nobuyoshi

unread,
May 26, 2009, 10:47:12 AM5/26/09
to android-...@googlegroups.com
Hi Joe,

For checking DNS server addresses, you can use getprop, such
as:

| # getprop net.dns1
| 192.168.32.18

or, if you'd like to know the values which dhcp server
offers:

| # getprop dhcp.tiwlan0.dns1
| 192.168.32.18

You also can see dhcp supply default gateway value:

| # getprop dhcp.tiwlan0.gateway
| 192.168.32.1

You might see all property values if you exec 'getprop'
without arguments.

If you'd like to see live routing table, the easiest(but
complicated to understand) way is to see /proc/net/route.

| # cat /proc/net/route
| Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT
| tiwlan0 0020A8C0 00000000 0001 0 0 0 00FFFFFF 0 0 0
| tiwlan0 00000000 0120A8C0 0003 0 0 0 00000000 0 0 0

The Destination '00000000' means, of course, default route
and Gateway value '0120A8C0' means '1.32.168.192' in
decimal('192.168.32.1' in reverse), so you can know what is
default gateway address is.

Best Regards,
--
MIYOKAWA, Nobuyoshi

Joe Petruchi

unread,
May 30, 2009, 8:30:04 AM5/30/09
to android-...@googlegroups.com
Thanks a lot
 
Regards
Joe

Roman

unread,
Jun 6, 2009, 4:24:48 PM6/6/09
to android-platform
Hi,

netstat -nr is another way to get the routing table.

--
Roman Baumgaertner
Sr. SW Engineer-OSDC
·T· · ·Mobile· stick together
The views, opinions and statements in this email are those of the
author solely in their individual capacity, and do not necessarily
represent those of T-Mobile USA, Inc.

simon

unread,
Jun 7, 2009, 6:04:45 AM6/7/09
to android-platform


On Jun 6, 10:24 pm, Roman <roman.baumgaert...@t-mobile.com> wrote:
> Hi,
>
> netstat -nr is another way to get the routing table.

Normally yes, except it doesn't work with the "netstat" command on
Android.
netstat -nr just does the same as netstat, namely it lists the open
TCP connections.

# netstat -nr
Proto Recv-Q Send-Q Local Address Foreign Address
State
tcp 0 0 127.0.0.1:5037 0.0.0.0:*
LISTEN
tcp 0 1 192.168.10.178:55549 74.125.77.106:80
CLOSE_WAIT
tcp 0 0 192.168.10.178:44604 209.85.229.188:5228
ESTABLISHED
udp 0 0 0.0.0.0:43030 0.0.0.0:*
udp 0 0 0.0.0.0:9000 0.0.0.0:*
# netstat
Proto Recv-Q Send-Q Local Address Foreign Address
State
tcp 0 0 127.0.0.1:5037 0.0.0.0:*
LISTEN
tcp 0 1 192.168.10.178:55549 74.125.77.106:80
CLOSE_WAIT
tcp 0 0 192.168.10.178:44604 209.85.229.188:5228
ESTABLISHED
udp 0 0 0.0.0.0:43030 0.0.0.0:*
udp 0 0 0.0.0.0:9000 0.0.0.0:*

(On an ADP1 using 1.5r2 firware from the HTC support page.)
--
Simon.

simon

unread,
Jun 7, 2009, 6:09:16 AM6/7/09
to android-platform
> netstat -nr just does the same as netstat, namely it lists the open
> TCP connections.

Sorry, correcting myself, it seems to list all open (IPv4?) sockets,
including UDP sockets and unconnected TCP sockets.
--
Simon.

Andreas Kostyrka

unread,
Jun 7, 2009, 10:10:00 AM6/7/09
to android-...@googlegroups.com

Routes: cat /proc/net/route
Dns: cat /system/etc/resolv.conf

-- Simon. --~--~---------~--~----~------------~-------~--~----~ You received this message because yo...

bcr000k

unread,
Oct 22, 2013, 2:02:06 AM10/22/13
to android-...@googlegroups.com
Hi,
is there any guarantee that /proc/net/route works across Android platforms and phones?  I mean, sometimes companies like Motorola decide to apply extra security measures to prohibit developers from accessing useful platform functionalities, like routing tables. 
Does anybody have knowledge about this?

BC

biAji

unread,
Oct 25, 2013, 12:11:08 PM10/25/13
to android-...@googlegroups.com
Why not have busybox installed, then you can use busybox route  to get the ip route.


--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/groups/opt_out.



--

biAji
Reply all
Reply to author
Forward
0 new messages