且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

busybox filesystem udhcpc 原理

更新时间:2022-08-12 20:37:30

/********************************************************************
 *               busybox filesystem udhcpc 原理
 * 声明:
 *     本文主要是记录busybox中的如何运用udhcpc获取IP,参考文章里写的
 * 很详细,不再累赘。
 *
 *                                 2016-1-23 深圳 南山平山村 曾剑锋
 *******************************************************************/

一、参考文章:
    BusyBox 應用 – udhcpc
        http://felix-lin.com/linux/busybox-%E6%87%89%E7%94%A8-udhcpc/

二、应用:
    1. 拷贝udhcpc脚本:
        cp busybox-1.24.1/examples/udhcp/simple.script <filesystem root>/usr/share/udhcpc/default.script
    2. 运行:
        udhcpc -b -S -p /var/run/udhcpc.pid

三、效果如下:
    udevd version 126 started
    zengjf login: root
    login[1423]: root login on 'ttymxc0'
    udhcpc (v1.24.1) started
    Setting IP address 0.0.0.0 on eth0
    eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=1:01, irq=-1)
    Sending discover...
    Unable to load library icui18n "Cannot load library icui18n: (icui18n: cannot open shared object file: No such file or directory)" 
    zengjf check QWSDisplay::requestRegion directServerConnection position.
    
    PHY: 1:01 - Link is Up - 100/Full
    Sending discover...
    Sending select for 10.0.1.52...
    Lease of 10.0.1.52 obtained, lease time 7200
    Setting IP address 10.0.1.52 on eth0
    Deleting routers
    route: SIOCDELRT: No such process
    Adding router 10.0.1.254
    Recreating /etc/resolv.conf
     Adding DNS server 8.8.8.8
     Adding DNS server 202.96.128.166
    [zengjf@root ~]#