//----------------------------------------------------
//AUTHOR: lanyang123456
//DATE: 2012-3-19
//----------------------------------------------------
dhcp版本: 3.1.3
ARM 开发板:OK6410
Linux内核2.6.28 或3.0.1
1 下载源码:http://download.csdn.net/detail/lanyang123456/4147066 或者http://gd.tuwien.ac.at/infosys/servers/isc/dhcp/ 或者https://www.isc.org/software/dhcp/
2 解压并编译
tar -zxvf dhcp-3.1.3.tar.gz,然后进入dhcp-3.1.3。目录,运行配置./configure,成功之后生成work.linux-2.2文件夹, 进入work.linux-2.2/client目录,
输入make "CC=/usr/local/arm/4.2.2-eabi/arm-linux-gcc -static",编译生成dhclient。
其中CC=/usr/local/arm/4.2.2-eabi/arm-linux-gcc 为交叉编译器的路径
3 移植到开发板。
拷贝生成的dhclient到OK6410开发板上,为方便使用,可以放在/usr/bin/下.
拷贝配置文件dhcp-3.1.3/client/dhclient.conf和/dhcp-3.1.3/client/scripts/linux 到开发板的/sbin/目录下,并将后一个文件重命名为dhclient-script,并修改该文件的第一行#! /bin/bash 为#! /bin/sh,保存后,修改权限 chmod +x /sbin/dhclient-script。
运行命令
#dhclient 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/
can't create /var/state/dhcp/dhclient.leases: No such file or directory
socket: Address family not supported by protocol - make sure
CONFIG_PACKET (Packet socket) and CONFIG_FILTER
(Socket Filtering) are enabled in your kernel
configuration!
If you did not get this software from ftp.isc.org, please
get the latest from ftp.isc.org and install that before
requesting help.
If you did get this software from ftp.isc.org and have not
yet read the README, please read it before requesting help.
If you intend to request help from the [email protected]
mailing list, please read the section on the README about
submitting bug reports and requests for help.
Please do not under any circumstances send requests for
help directly to the authors of this software - please
send them to the appropriate mailing list as described in
the README file.
exiting
针对问题
在/var目录下创建state目录,再在state目录下创建dhcp目录
#mkdir /var/state
#mkdir /var/state/dhcp
再次运行dhclient
#dhclient
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/
socket: Address family not supported by protocol - make sure
CONFIG_PACKET (Packet socket) and CONFIG_FILTER
(Socket Filtering) are enabled in your kernel
configuration!
If you did not get this software from ftp.isc.org, please
get the latest from ftp.isc.org and install that before
requesting help.
If you did get this software from ftp.isc.org and have not
yet read the README, please read it before requesting help.
If you intend to request help from the [email protected]
mailing list, please read the section on the README about
submitting bug reports and requests for help.
Please do not under any circumstances send requests for
help directly to the authors of this software - please
send them to the appropriate mailing list as described in
the README file.
exiting.
提示需要内核支持Packet socket 和socket filter
重新配置内核
添加Packet socket支持
[*] Networking support --->
Networking options --->
<*> Packet socket
[*] Packet socket: mmapped IO
添加 socket filter支持
[*] Networking support --->
Networking options --->
[*] Network packet filtering framework (Netfilter) --->
--- Network packet filtering framework (Netfilter)
[ ] Network packet filtering debugging (NEW)
[*] Advanced netfilter configuration (NEW)
Core Netfilter Configuration --->
< > IP virtual server support (NEW) --->
IP: Netfilter Configuration --->
重新编译,烧录。
重新配置,再次运行命令
[root@FORLINX6410]# dhclient 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/11:22:33:44:55:66
Sending on LPF/wlan0/11:22:33:44:55:66
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
DHCPOFFER from 192.168.1.254
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.254
bound to 192.168.1.235 -- renewal in 801 seconds.
[root@FORLINX6410]#
[root@FORLINX6410]# ifconfig wlan0
wlan0 Link encap:Ethernet HWaddr 11:22:33:44:55:66
inet addr:192.168.1.235 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2585 errors:0 dropped:0 overruns:0 frame:0
TX packets:7 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:155606 (151.9 KiB) TX bytes:1666 (1.6 KiB)
参考
dhcp移植 百度空间
http://hi.baidu.com/xieliweilove/blog/item/fb5fee8ff6619fddfc1f1053.html
成功移植DHCP客户端到mini2440
http://blog.csdn.net/guoyin/article/details/6422956