Android 命令设置获取、IP地址、网关、dns

来源:互联网 发布:spss怎么将数据分组 编辑:程序博客网 时间:2024/05/20 18:00

通过shell命令设置(获取)IP、网关、dns信息,需要获取root权限

查看所有网络信息

C:\>adb shellroot@android:/ # netcfgnetcfgip6tnl0  DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00gre0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00eth0     UP                               192.168.0.180/24  0x00001043 00:00:00:ec:0a:00sit0     DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00lo       UP                                   127.0.0.1/8   0x00000049 00:00:00:00:00:00tunl0    DOWN                                   0.0.0.0/0   0x00000080 00:00:00:00:00:00

查看eth0

root@android:/ # ifconfig eth0ifconfig eth0eth0: ip 192.168.0.180 mask 255.255.255.0 flags [up broadcast running multicast]

查看dns

root@android:/ # getprop net.eth0.dns1getprop net.eth0.dns18.8.8.8root@android:/ # getprop net.eth0.dns2getprop net.eth0.dns28.8.4.4

设置ip

root@android:/ # ifconfig eth0 192.168.0.173 netmask 255.255.255.0ifconfig eth0 192.168.0.173 netmask 255.255.255.0root@android:/ # ifconfig eth0ifconfig eth0eth0: ip 192.168.0.173 mask 255.255.255.0 flags [up broadcast running multicast]

设置网关Gateway

root@android:/ # route add default gw 192.168.0.1 dev eth0route add default gw 192.168.0.1 dev eth0

添加dns

root@android:/ # setprop net.eth0.dns1 8.8.8.8setprop net.eth0.dns1 8.8.8.8root@android:/ # setprop net.eth0.dns2 8.8.4.4setprop net.eth0.dns2 8.8.4.4

查看eth配置信息

root@android:/ # getprop | grep eth0getprop | grep eth0[dhcp.eth0.dns1]: [192.168.0.1][dhcp.eth0.dns2]: [][dhcp.eth0.dns3]: [][dhcp.eth0.dns4]: [][dhcp.eth0.gateway]: [192.168.0.1][dhcp.eth0.ipaddress]: [192.168.0.180][dhcp.eth0.leasetime]: [3600][dhcp.eth0.mask]: [255.255.255.0][dhcp.eth0.pid]: [13800][dhcp.eth0.reason]: [PREINIT][dhcp.eth0.result]: [failed][dhcp.eth0.server]: [192.168.0.1][dhcp.eth0.vendorInfo]: [][net.change]: [net.eth0.dns2][net.eth0.dns1]: [8.8.8.8][net.eth0.dns2]: [8.8.4.4]
阅读全文
0 0
原创粉丝点击