一、下載源碼:
在http://gd.tuwien.ac.at/infosys/servers/isc/dhcp/ ,選中 dhcp-3.1-ESV-R3.tar.gz。
二、配置、編譯
(1)解壓 tar -zxvf dhcp-3.1-ESV-R3.tar.gz,然後進入./dhcp-3.1-ESV-R3/,
home/dhcp/dhcp-3.1-ESV-R3$
運行配置./configure
home/dhcp/dhcp-3.1-ESV-R3$./configure
之後生成work.linux-2.2文件夾,進入work.linux-2.2/目錄
home/dhcp/dhcp-3.1-ESV-R3/work.linux-2.2$
輸入make "CC=arm-linux-gnu-gcc -static" (在此靜態編譯,以免發生命令找不到。當然可以動態編譯,只要和你的文件系統用的庫一致)
home/dhcp/dhcp-3.1-ESV-R3/work.linux-2.2$make "CC=arm-linux-gnu-gcc -static"
將在dhcp-3.1-ESV-R3/work.linux-2.2/client目錄下編譯生成dhclient。
三、移植到開發板
(1)拷貝生成的dhclient到FS2410開發板上,為方便使用,可以放在/usr/bin/或/sbin目錄下;
dhcp-3.1-ESV-R3/work.linux-2.2/client$cp dhclient /rootfs/filesystem/sbin
拷貝另外兩個配置文件到開發板,分別是/dhcp-3.1-ESV-R3/client/dhclient.conf
/dhcp-3.1-ESV-R3/client/scripts/linux
到開發板的/sbin/目錄下。並改名後一個文件為dhclient-script
home/dhcp/dhcp-3.1-ESV-R3/client$cp dhclient.conf /rootfs/filesystem/sbin
home/dhcp/dhcp-3.1-ESV-R3/client/scripts$cp linux /rootfs/filesystem/sbin/dhclient-script
(2)並修改dhclient-script該文件的第一行#!/bin/bash 為#!/bin/sh,
(3)保存後修改權限 rootfs/filesystem$sudo chmod +x /sbin/dhclient*
四、測試
為eth0 或者wlan0配置dhcp服務,輸入dhclient eth0 或者dhclient wlan0 即可,得到如下類似信息:
eth0:
Listening on LPF/eth0/08:90:90:90:90:90
Sending on LPF/eth0/08:90:90:90:90:90
Sending on Socket/fallback
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPNAK from 192.168.1.1
eth0: link down
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
receive_packet failed on eth0: Network is down
eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.1.1
DHCPACK from 192.168.1.1
bound to 192.168.1.108 -- renewal in 40380 seconds.
wlan0:
Internet Systems Consortium DHCP Client V3.1.3
Copyright 2004-2009 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/00:60:b3:01:92:dc
Sending on LPF/wlan0/00:60:b3:01:92:dc
Sending on Socket/fallback
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.106 -- renewal in 41564 seconds.