Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adb command for getting ip address assigned by operator

I need to fetch the IPaddress assigned by the operator after a successful 3G or LTE data call.

$adb shell netcfg >> doesnt have the assigned IP address.

I tried adb shell dumpsys and grep ip address, but in vain. Any help/pointers?

like image 513
user1787049 Avatar asked Nov 01 '12 00:11

user1787049


People also ask

How do I find the IP address of a device using adb?

How to get ip address of your device using adb? Run the command adb shell ip addr show wlan0 to show the IP address of your device.

What is the command to assign an IP address?

Use the set network command to configure an IP address from the command line. The set network command includes the following parameters: ip=device ip: The IP address for the device. gateway=gateway: The network gateway IP address.


2 Answers

Try this command, it will help you to get ipaddress

adb shell ifconfig tiwlan0 

tiwlan0 is the name of the wi-fi network interface on the device. This is generic command for getting ipaddress,

 adb shell netcfg 

It will output like this

usb0     DOWN  0.0.0.0         0.0.0.0         0×00001002 sit0     DOWN  0.0.0.0         0.0.0.0         0×00000080 ip6tnl0  DOWN  0.0.0.0         0.0.0.0         0×00000080 gannet0  DOWN  0.0.0.0         0.0.0.0         0×00001082 rmnet0   UP    112.79.87.220   255.0.0.0       0x000000c1 rmnet1   DOWN  0.0.0.0         0.0.0.0         0×00000080 rmnet2   DOWN  0.0.0.0         0.0.0.0         0×00000080 
like image 51
RajeshVijayakumar Avatar answered Sep 30 '22 06:09

RajeshVijayakumar


Try:

adb shell ip addr show rmnet0

It will return something like that:

3: rmnet0: <UP,LOWER_UP> mtu 1500 qdisc htb state UNKNOWN qlen 1000
    link/[530]
    inet 172.22.1.100/29 scope global rmnet0
    inet6 fc01:abab:cdcd:efe0:8099:af3f:2af2:8bc/64 scope global dynamic
       valid_lft forever preferred_lft forever
    inet6 fe80::8099:af3f:2af2:8bc/64 scope link
       valid_lft forever preferred_lft forever 

This part is your IPV4 assigned by the operator

inet 172.22.1.100

This part is your IPV6 assigned by the operator

inet6 fc01:abab:cdcd:efe0:8099:af3f:2af2:8bc

like image 20
Rene Barbosa Avatar answered Sep 30 '22 05:09

Rene Barbosa