dhcpcd 移植
/************************************************************************ * dhcpcd移植 * dhcpcd是DHCP client的实现,可以作为后台守护进程运行。 * 本文介绍移植过程,其中的配置文件并没有深究。 * 参考链接: * http://www.cnblogs.com/zengjfgit/p/5435126.html * https://wiki.archlinux.org/index.php/Dhcpcd#Running * http://www.linuxfromscratch.org/blfs/view/svn/basicnet/dhcpcd.html * * Tony, 2016-5-4,Shenzhen ***********************************************************************/ 1.下载 ftp://roy.marples.name/pub/dhcpcd 我下载的版本是:dhcpcd-6.9.4.tar.xz 2.编译 解压压缩包 ./configure --libexecdir=/lib/dhcpcd --dbdir=/var/lib/dhcpcd make CC=arm-linux-gnueabihf-gcc 3.移植 1. 编译生成的dhcpcd添加到板中 2. dhcpcd.conf添加到/etc目录 3. 将dhcpcd-run-hooks脚本添加到开发板/lib/dhcpcd/中。 dhcpcd-hooks目录及其内容移动到放到开发板/lib/dhcpcd/目录. dhcpcd-run-hooks脚本运行时会调用dhcpcd-hooks中的脚本。 4.运行 dhcpcd 会保持在后台运行。重新插上网线,就能够获取ip。 5.存在问题 5.1 电脑网卡和板子直连,运行dhcpcd也会配置ip 电脑网卡ip:192.168.2.110 root@tony:# dhcpcd control_open: Connection refused all: IPv6 kernel autoconf disabled eth0: IPv6 kernel autoconf disabled eth0: adding address fe80::6eec:ebff:fef9:1731 if_addaddress6: Operation not supported script_runreason: /lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 127 script_runreason: /lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 127 DUID 00:01:00:01:1c:62:04:1e:6c:ec:eb:f9:17:31 eth0: IAID eb:f9:17:31 eth0: soliciting a DHCP lease eth0: probing for an IPv4LL address eth0: using IPv4LL address 169.254.144.185 eth0: adding route to 169.254.0.0/16 eth0: adding default route script_runreason: /lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 127 forked to background, child pid 1922 root@tony:# ifconfig eth0 Link encap:Ethernet HWaddr 6C:EC:EB:F9:17:31 inet addr:169.254.144.185 Bcast:169.254.255.255 Mask:255.255.0.0 UP BROADCAST RUNNING ALLMULTI MULTICAST MTU:1500 Metric:1 RX packets:1142 errors:0 dropped:0 overruns:0 frame:0 TX packets:578 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:310397 (303.1 KiB) TX bytes:70897 (69.2 KiB) lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:32421 errors:0 dropped:0 overruns:0 frame:0 TX packets:32421 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:549649752 (524.1 MiB) TX bytes:549649752 (524.1 MiB) 5.2 dhcpcd eth0 这样启动的时候,如果没有连接网线,会导致dhcpcd配置超时,启动失败,程序退出。 root@tony:# dhcpcd eth0 control_open: Connection refused all: IPv6 kernel autoconf disabled eth0: IPv6 kernel autoconf disabled eth0: adding address fe80::6eec:ebff:fef9:1731 if_addaddress6: Operation not supported script_runreason: /lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 127 script_runreason: /lib/dhcpcd/dhcpcd-run-hooks: WEXITSTATUS 127 eth0: waiting for carrier timed out dhcpcd exited