dhcpcd移植

【目的】

移植dhcpcd的目是在AM335X开发板上使用dhcp功能,获取WAN口设备的IP,并且可以通过参数指定其matric,matric值越小,其优先级越高。如设备可以以太网,WIFI,4G上网时,可定制外网功能,以太网优先级最高,WIFI次之,4G优先级最低。

【环境】

1、  Ubuntu 16.04发行版

2、  MC183平台

3、  交叉编译器arm-linux-gnueabihf-gcc-4.7.3

【步骤】

1、下载dhcpcd-6.7.1.tar.gz源码。

2.  交叉编译dhcpcd-6.7.1.tar.gz。

解压dhcpcd-6.7.1.tar.gz

tar zvxf  dhcpcd-6.7.1.tar.gz

cd dhcpcd-6.7.1

配置:

./configure --libexecdir=/lib/dhcpcd --dbdir=/var/lib/dhcpcd

编译:

make CC=arm-linux-gnueabihf-gcc

报如下错误:

arm-linux-gnueabihf-gcc  -o dhcpcd common.o control.o dhcpcd.o duid.o eloop.o if.o if-options.o script.o dhcp-common.o dhcpcd-embedded.o if-linux.o arp.o dhcp.o ipv4.o ipv4ll.o ipv6.o ipv6nd.o dhcp6.o if-linux-wext.o auth.o compat/arc4random.o compat/arc4random_uniform.o compat/closefrom.o compat/strlcpy.o crypt/hmac_md5.o crypt/md5.o crypt/sha256.o

common.o: In function `get_monotonic':

common.c:(.text+0x6a): undefined reference to `clock_gettime'

auth.o: In function `get_next_rdm_monotonic':

auth.c:(.text+0x12): undefined reference to `clock_gettime'

collect2: error: ld returned 1 exit status

Makefile:99: recipe for target 'dhcpcd' failed

make: *** [dhcpcd] Error 1

解决方法:在config.mk当中添加如下语句,重新make,即可编译通过。

LDADD+=-lrt

交叉编译之后,所需要的文件:

dhcpcd可执行文件

dhcpcd-run-hooks  需要给其赋可执行权限

hdcpcd-hooks  dhcpcd运行行,会通过dhcpcd-run-hook,调用dhcpcd-hooks下面的脚本,如生成/etc/resolv.conf等。

如下所示为集成到系统当中的位置。其中resolv.conf.head, resolv.conf.tail为dns服务器的配置:

# cat dynamic-configure-network/etc/resolv.conf.head

nameserver 114.114.114.114

# cat dynamic-configure-network/etc/resolv.conf.tail

nameserver 8.8.8.8

├── bin

│   ├── dhcpcd

├── etc

│   ├── dhcpcd.conf

│   ├── resolv.conf.head

│   ├── resolv.conf.tail

├── lib

│   └── dhcpcd

│       ├── dhcpcd-hooks

│       │   ├── 01-test

│       │   ├── 02-dump

│       │   ├── 10-mtu

│       │   ├── 10-wpa_supplicant

│       │   ├── 15-timezone

│       │   ├── 20-resolv.conf

│       │   ├── 29-lookup-hostname

│       │   ├── 30-hostname

│       │   ├── 50-dhcpcd-compat

│       │   ├── 50-ntp.conf

│       │   ├── 50-ypbind.in

│       │   └── 50-yp.conf

│       └── dhcpcd-run-hooks

3.  测试:

获取以太网口IP地址:

dhcpcd eth0

指定默认路由的metric值

dhcpcd –m 1 eth0

如果网线没有插的话,运行dhcpcd 时,会退出,

通过指定参数-t  0,保证以网未插入时,dhcpcd服务不退出,

这样的支持以太网线的插拔时

dhcpcd –m 1 –t 0 eth0

am335x system upgrade rootfs for dhcpcd cross compile(十三)的更多相关文章

  1. am335x system upgrade rootfs for bridge-utils cross compile (十四)

    bridge-utils移植 [目的] 移植bridge-utils的目是在AM335X开发板上使用bridge功能. [环境] 1.  Ubuntu 16.04发行版 2.  MC183平台 3.  ...

  2. am335x system upgrade rootfs using yocto make rootfs(十二)

    1      Scope of Document This document describes how to make am335x arago rootfs using ycoto project ...

  3. am335x system upgrade rootfs custom service using systemd script(十七)

    1      Scope of Document systemd 是一个 Linux 系统基础组件的集合,提供了一个系统和服务管理器,运行为 PID 1 并负责启动其它程序.功能包括:支持并行化任务: ...

  4. am335x system upgrade set/get current cpufreq(二十一)

    1      Scope of Document This document describes am335x cpufreq technology insider. 2      Requireme ...

  5. am335x system upgrade kernel tf(五)

    1      Scope of Document This document describes TF hardware design 2      Requiremen 2.1     Functi ...

  6. am335x system upgrade uboot nand boot(三)

    在uboot 下初始化nand,一般需要做如下工作: 第一: 配置默认从NAND boot Index: include/configs/am335x_evm.h=================== ...

  7. am335x system upgrade uboot ethernet(二)

    系统可以通过SD卡引道之后,为了之后了调试方便 通过查看网卡的硬件设计 正常来说需要注意的有如下几点: 1) 网口 的接线方式: RMII 2) 网口的PHY地址两张网口,这里我们只需先初始化一张网卡 ...

  8. am335x system upgrade kernel ethernet(四)

    1      Scope of Document This document describes ethernet hardware design and porting KZS8081 to ubo ...

  9. am335x system upgrade kernel ec20 simcom7600ce(十一)

    1      Scope of Document This document describes 4G hardware design, support quectel ec20 4G module/ ...

随机推荐

  1. kubernetes 实践三:使用kubeadm安装k8s1.16.0

    环境版本说明: 三台vmware虚拟机,系统版本CentOS7.6. Kubernetes 1.16.0,当前最新版. flannel v0.11 docker 18.09 使用kubeadm可以简单 ...

  2. SpringBoot打成jar包后无法读取resources资源文件

    在项目中做了一个支付功能, 需要引入第三方渠道的配置文件config.xml用来初始化文件证书, 将配置文件 config.xml 放到 resources 资源目录下. 本地开发环境下能正常读取该文 ...

  3. Linux 用户管理命令笔记

    1.新增用户 useradd user1 用户创建流程 1.系统先将用户信息记录在/etc/passwd中,一般会在/etc/passwd和/etc/shadow末尾,同时分配该用户UID. 2.创建 ...

  4. asp.net mvc 使用bootstrap的模态框插件modal

    编译器:vs2012 jquery版本:jquery-1.10.2.js bootstrap:bootstrap.js v3.0.0,包含modal插件 我们要实现一个使用模态框展示从服务器获取的数据 ...

  5. NEST analyze与mapping

    /// <summary> /// POST /_analyze?pretty=true /// POST /employee/_analyze /// </summary> ...

  6. python-django中的APPEND_SLASH实现

    关于django中的APPEND_SLASH APPEND_SLASH 它是啥? 看变量名大概能知道做什么,就是添加斜线,用路由系统那里. 路由文件,只写了路由关系代码 ...... urlpatte ...

  7. HTML Marquee跑马灯

    Marquee是html的标签,所有的主流浏览器都能兼容,用于创建文字滚动. 来介绍下标签的属性 滚动方向 direction <!--滚动方向 direction 4个值 up down le ...

  8. Android目前流行三方数据库ORM分析及对比

    Android 平台上的数据库框架非常多,但是有一个共同特点就是基于对象关系映射(ORM)模型的.实现的目标也都是不需要写SQL语句,通过对对象的操作保存和操作数据.要是从语法的简洁性来说都有自己的特 ...

  9. js 字节操作

    获取byte的高4位bit和低4位bit function getHeight4(ata){//获取高四位 int height; height = ((data & 0xf0) >&g ...

  10. Redis主从同步之主库挂死解决方案

    Redis实现了主从同步,但是主库挂死了,如何处理 方案:切换主库的身份 # 连接从库 [root@localhost redis-]# redis-cli -p # 取消从库身份 > slav ...