adb command for getting ip address assigned by ope

2019-01-30 11:42发布

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?

9条回答
Evening l夕情丶
2楼-- · 2019-01-30 11:56

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
查看更多
家丑人穷心不美
3楼-- · 2019-01-30 11:58

According to comments: netcfg was removed in Android 6

Try

adb shell netcfg

Or

adb shell <device here or leave out if one device>
shell@android:/ $netcfg
查看更多
我欲成王,谁敢阻挡
4楼-- · 2019-01-30 11:58

adb shell ip addr > ippdetails.txt This will get all list of ip's assigned to devices.

查看更多
欢心
5楼-- · 2019-01-30 12:00

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

查看更多
姐就是有狂的资本
6楼-- · 2019-01-30 12:01

Try:

adb shell ip addr show rmnet0  | grep 'inet ' | cut -d' ' -f6|cut -d/ -f1

It will return your IPV4 assigned by the operator

172.22.1.215

查看更多
【Aperson】
7楼-- · 2019-01-30 12:02

Try this command for Version <= Marshmallow,

adb devices

List of devices attached 38ccdc87 device

adb tcpip 5555

restarting in TCP mode port: 5555

adb shell ip addr show wlan0

24: wlan0: mtu 1500 qdisc mq state UP qlen 1000 link/ether ac:c1:ee:6b:22:f1 brd ff:ff:ff:ff:ff:ff inet 192.168.0.18/24 brd 192.168.0.255 scope global wlan0 valid_lft forever preferred_lft forever inet6 fd01::1d45:6b7a:a3b:5f4d/64 scope global temporary dynamic valid_lft 287sec preferred_lft 287sec inet6 fd01::aec1:eeff:fe6b:22f1/64 scope global dynamic valid_lft 287sec preferred_lft 287sec inet6 fe80::aec1:eeff:fe6b:22f1/64 scope link valid_lft forever preferred_lft forever

To connect to your device run this

adb connect 192.168.0.18

connected to 192.168.0.18:5555

Make sure you have adb inside this location android-sdk\platform-tools

查看更多
登录 后发表回答