/************************************************************************ * 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