//
you're reading...
Tips & Tricks

Show Android IP, DNS and Routing Configuration

When you connected to network with DHCP enabled, Android does not provide enough info about your detailed network configuration. Commonly, it will show the IP Address only. So how to know about the IP Address you are using, the refered DNS and the routing / gateway configuration ?

There might be some apps out there which can give you the information above, but, here, we will show it by using linux commands. However, there are several prerequisites you have to complete before you can do these commands.

Prerequisites:

  • Rooted, your device has to be routed
  • Terminal Emulator or ADB Shell, Terminal emulator must be installed or you can use ADB Shell from computer connected to the android device
  • Superuser, you must use superuser mode to execute the commands

Steps:

  • To show the IP address and the routing table, type this:
  • cat /proc/net/route

    or

    ip route show

  • To show DNS
  • getprop net.dns1
    getprop net.dns2

    net.dns1 for Primary DNS and net.dns2 for Secondary DNS

  • In case you want to change the DNS:
  • setprop net.dns1 123.123.123.123
    setprop net.dns2 123.123.123.123

    Where 123.123.123.123 is your DNS ip address.

  • In case you want to change the gateway:
  • route add default gw 123.123.123.1231 dev wifi

    where 123.123.123.123 is the new gateway IP address and wifi is the connection you are using, it can be wlan0, wifi, eth0, etc.

ip and getprop commands

Discussion

No comments yet.

Leave a comment