Android平台网络常用命令

2019-07-12 23:46发布

Android平台网络常用命令

工作中经常用到的一些命令,整理一下,方便以后进行参考 1.IP设置  ifconfig eth0 128.224.156.81 up  //一般的嵌入式linux中设置IP。
ifconfig eth0 128.224.156.81 netmask 255.255.255.0 up
netcfg eth0 up dhcp   //通过dhcp 自动获取ip,网关,掩码等。

2. gateway

route add default gw 128.224.156.1  //一般的嵌入式linux会用这个命令添加网关,但是android中不用。直接“netcfg eth0 up dhcp” 自动分配IP等。

3. dns:
echo "nameserver 128.224.160.11" > resolv.conf  //一般嵌入式linux中设置dns的方法
nameserver 128.224.160.11

setprop net.dns1 128.224.160.11   //android中设置DNS的命令。
setprop net.dns2 147.11.100.30 4、自动获取IP # ./dhcpcd -U eth1
broadcast_address='192.168.100.255'
dhcp_lease_time='30'
dhcp_message_type='5'
dhcp_server_identifier='192.168.100.1'
ip_address='192.168.100.10'
network_number='192.168.100.0'
routers='192.168.100.1'
subnet_cidr='24'
subnet_mask='255.255.255.0'   5、自动获取IP的详细调用过程 # ./dhcpcd -h eth1 -d
dhcpcd[1534]: version 5.6.8 starting
dhcpcd[1534]: eth0: using hwaddr a2:47:2c:1e:af:3b
dhcpcd[1534]: eth0: executing `/home/xxx/work/Android_Net/install/libexec/dhcpcd-run-hooks', reason PREINIT
dhcpcd[1534]: eth0: executing `/home/xxx/work/Android_Net/install/libexec/dhcpcd-run-hooks', reason CARRIER
dhcpcd[1534]: eth1: using hwaddr a2:47:2c:1e:af:3b
dhcpcd[1534]: eth1: executing `/home/xxx/work/Android_Net/install/libexec/dhcpcd-run-hooks', reason PREINIT
dhcpcd[1534]: eth1: executing `/home/xxx/work/Android_Net/install/libexec/dhcpcd-run-hooks', reason CARRIER
dhcpcd[1534]: eth0: sending IPv6 Router Solicitation
dhcpcd[1534]: eth0: reading lease `/var/db/dhcpcd-eth0.lease'
dhcpcd[1534]: eth0: rebinding lease of 192.168.20.14
dhcpcd[1534]: eth0: sending REQUEST (xid 0x425e5b0e), next in 3.62 seconds
dhcpcd[1534]: eth1: sending IPv6 Router Solicitation
dhcpcd[1534]: eth1: reading lease `/var/db/dhcpcd-eth1.lease'
dhcpcd[1534]: eth1: rebinding lease of 192.168.100.10
dhcpcd[1534]: eth1: sending REQUEST (xid 0x18442cad), next in 3.15 seconds
dhcpcd[1534]: eth0: acknowledged 192.168.20.14 from 192.168.3.185
dhcpcd[1534]: eth0: checking for 192.168.20.14
dhcpcd[1534]: eth0: sending ARP probe (1 of 3), next in 1.22 seconds
dhcpcd[1534]: eth1: acknowledged 192.168.100.10 from 192.168.100.1
dhcpcd[1534]: eth1: checking for 192.168.100.10
dhcpcd[1534]: eth1: sending ARP probe (1 of 3), next in 1.88 seconds
dhcpcd[1534]: eth0: sending ARP probe (2 of 3), next in 1.88 seconds
dhcpcd[1534]: eth1: sending ARP probe (2 of 3), next in 1.95 seconds
dhcpcd[1534]: eth0: sending ARP probe (3 of 3), next in 2.00 seconds
dhcpcd[1534]: eth0: sending IPv6 Router Solicitation
dhcpcd[1534]: eth1: sending IPv6 Router Solicitation
dhcpcd[1534]: eth1: sending ARP probe (3 of 3), next in 2.00 seconds
dhcpcd[1534]: eth0: leased 192.168.20.14 for 172800 seconds
dhcpcd[1534]: eth0: renew in 86400 seconds, rebind in 86400 seconds
dhcpcd[1534]: eth0: adding IP address 192.168.20.14/24
dhcpcd[1534]: eth0: router 192.168.3.254 requires a host route
dhcpcd[1534]: eth0: adding route to 192.168.20.0/24
dhcpcd[1534]: eth0: adding host route to 192.168.3.254
dhcpcd[1534]: eth0: adding default route via 192.168.3.254
dhcpcd[1534]: eth0: writing lease `/var/db/dhcpcd-eth0.lease'
dhcpcd[1534]: eth0: executing `/home/xxx/work/Android_Net/install/libexec/dhcpcd-run-hooks', reason BOUND
dhcpcd[1534]: forking to background
dhcpcd[1534]: forked to background, child pid 1575