工作中经常用到的一些命令,整理一下,方便以后进行参考

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

最新文章

  1. Python GIL 多线程机制 (C source code)
  2. JDBC步骤
  3. hibernate(六) cascade(级联)和inverse关系详解
  4. DB2 日期相减
  5. ftp服务器远程拷贝命令
  6. 去除GHOST版系统自带的2345流氓软件
  7. 数据库调优过程(一):SqlServer批量复制(bcp)[C#SqlBulkCopy]性能极低问题
  8. 爬虫再探实战(三)———爬取动态加载页面——selenium
  9. CreateProcessW记录
  10. locale 详解
  11. Windows Phone开发(32):路径之PathGeometry
  12. 500. Keyboard Row
  13. Window下使用ftp命令往Linux中发送文件
  14. Java开发笔记(八十一)如何使用系统自带的注解
  15. GCC后端移植杂记
  16. 739. Daily Temperatures && 单调栈 && Python collections deque
  17. luogu1072 [NOIp2009]Hankson的趣味题 (数学+STL::set)
  18. UITableView滑动性能优化扩展
  19. whu 643 Soul Artist(二维BIT 区间更新,单点查询)
  20. C++:运算符重载

热门文章

  1. 《Effective Java》第2章 创建和销毁对象
  2. python 爬虫之requests+日志+配置文件读取+mysql入库
  3. java.io.FileNotFoundException: res/drawable/title_bar_shadow.9.png
  4. BIO与NIO的方式实现文件拷贝
  5. Mysql 5.6主从搭建
  6. slice()、substring()、substr()的区别用法
  7. loj #2026. 「JLOI / SHOI2016」成绩比较
  8. 洛谷 P3586 [POI2015]LOG
  9. Linux的重要子目录
  10. LB 负载均衡的层次结构(转)