设置android板子ip

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

查看所有网络信息

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

查看eth0

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

查看dns

root@android:/ # getprop net.eth0.dns1
getprop net.eth0.dns1
8.8.8.8

root@android:/ # getprop net.eth0.dns2
getprop net.eth0.dns2
8.8.4.4

设置ip

root@android:/ # ifconfig eth0 192.168.0.173 netmask 255.255.255.0
ifconfig eth0 192.168.0.173 netmask 255.255.255.0

root@android:/ # ifconfig eth0
ifconfig eth0
eth0: 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 eth0
route add default gw 192.168.0.1 dev eth0

添加dns

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

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

查看eth配置信息

root@android:/ # getprop | grep eth0
getprop | 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]
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值