移植DHCP-4.3.6

交叉编译工具链:arm-none-linux-gnueabi-gcc

目标板:iTOP4412精英版

主机:Ubuntu16.04

下载DHCP-4.3.6源码:http://www.linuxfromscratch.org/blfs/view/svn/basicnet/dhcp.html


一、交叉编译DHCP-4.3.6

1、解压缩

2、在源码目录下写配置脚本

添加可执行权限,并运行脚本

在bind目录下会自动生成Makefile,需要修改这个Makefile

3、进入到bind目录,修改bindconfig变量

修改BUILD_CC=gcc

添加CC=/usr/local/arm/arm-2014.05/bin/arm-none-linux-gnueabi-gcc

sudo make && make install

4、将安装后的etc目录下的两个文件拷到开发板上,重新命名

sudo cp dhclient.conf.example dhclient.conf

sudo cp dhcpd.conf.example dhcpd.conf

将bin、sbin、lib目录下文件拷贝到开发板对应的目录下


二、开发板上运行dhcp相关命令

1、执行dhclient命令,出现错误:

Internet Systems Consortium DHCP Server 4.3.6
Copyright 2004-2017 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcpd.conf
Database file: /var/db/dhcpd.leases
PID file: /var/run/dhcpd.pid
Can't open lease database /var/db/dhcpd.leases: No such file or directory --
  check for failed database rewrite attempt!
Please read the dhcpd.leases manual page if you
don't know what to do about this.

If you think you have received this message due to a bug rather
than a configuration issue please read the section on submitting
bugs on either our web page at www.isc.org or in the README file
before submitting a bug.  These pages explain the proper
process and the information we find helpful for debugging.
根据提示,在开发板/etc/init.d/rcS脚本中添加两条命令:

#创建DHCP服务器租约文件
mkdir -p /var/db/
touch /var/db/dhcpd.leases
2、重新执行dhclient命令,出现错误:
Internet Systems Consortium DHCP Server 4.3.6
Copyright 2004-2017 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcpd.conf
Database file: /var/db/dhcpd.leases
PID file: /var/run/dhcpd.pid
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.

No subnet declaration for eth0 (125.217.48.230).
** Ignoring requests on eth0.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface eth0 is attached. **


Not configured to listen on any interfaces!
我在开发板上设置的IP地址是125.217.48.230,此处提示的意思是:eth0设置的IP地址不属于/etc/dhcpd.conf脚本下配置的IP网段,所以需要将板子上的IP网段添加到/etc/dhcpd.conf脚本中,根据这个脚本之前的语法即可,DHCP服务配置文件/etc/dhcpd.conf加入:

subnet 125.217.48.0 netmask 255.255.254.0 {
  range 125.217.48.101 125.217.48.250;  				#设置地址池
  option domain-name-servers ns1.internal.example.org; 	#设置DNS服务器地址
  option domain-name "internal.example.org";    		#设置DNS域
  option routers 125.217.48.1;     						#设置路由
  option broadcast-address 125.217.48.255;  			#设置广播地址
  default-lease-time 600;          						#设置默认租期,单位为秒
  max-lease-time 7200;              					#设置最大租期
}
3、重新执行dhclient命令,无错误提示:

Internet Systems Consortium DHCP Server 4.3.6
Copyright 2004-2017 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Config file: /etc/dhcpd.conf
Database file: /var/db/dhcpd.leases
PID file: /var/run/dhcpd.pid
Wrote 0 class decls to leases file.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 0 leases to leases file.
Listening on LPF/eth0/00:00:ff:ff:00:00/125.217.48.0/23
Sending on   LPF/eth0/00:00:ff:ff:00:00/125.217.48.0/23
Sending on   Socket/fallback/fallback-net







你可能感兴趣的:(ARM,+,Linux)