`
fp_moon
  • 浏览: 980377 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

udhcpc 的配置记录

    博客分类:
  • DHCP
阅读更多

udhcpc scripts
Here's some debian scripts I wrote for
udhcpc
0.9.6.  I wanted to make
it easy to run local scripts for DHCP changes so I created
/etc/udhcpc.d.  All the /usr/share/udhcpc/default.* scripts
have been merged into /etc/udhcpc.d/S50default.  S99local
is an example script that patches resolv.conf and calls
a DNS update script.
   
/etc/init.d/
udhcpc
/etc/
udhcpc.script
/etc/udhcpc.d/
S50default
/etc/udhcpc.d/
S99local
   
Last modified: Mon Feb  4 10:23:49 PST 2002
单调的分割线
http://udhcp.busybox.net/README.udhcpc
udhcp client (udhcpc)
--------------------
The udhcp client negotiates a lease with the DHCP server and notifies
a set of scripts when a leases is obtained or lost.
command line options
-------------------
The command line options for the udhcp client are:
-c, --clientid=CLIENTID         Client identifier
-H, --hostname=HOSTNAME         Client hostname
-h,                                Alias for -H
-f, --foreground                Do not fork after getting lease
-b, --background                Fork to background if lease cannot be
                                immediately negotiated.
-i, --interface=INTERFACE       Interface to use (default: eth0)
-n, --now                       Exit with failure if lease cannot be
                                immediately negotiated.
-p, --pidfile=file              Store process ID of daemon in file
-q, --quit                      Quit after obtaining lease
-r, --request=IP                IP address to request (default: none)
-s, --script=file               Run file at dhcp events (default:
                                /usr/share/udhcpc/default.script)
-v, --version                   Display version
If the requested IP address cannot be obtained, the client accepts the
address that the server offers.
udhcp client scripts
-------------------
When an event occurs, udhcpc calls the action script. The script by
default is /usr/share/udhcpc/default.script but this can be changed via
the command line arguments. The three possible arguments to the script
are:
        deconfig: This argument is used when udhcpc starts, and
        when a leases is lost. The script should put the interface in an
        up, but deconfigured state, ie: ifconfig $interface 0.0.0.0.
       
        bound: This argument is used when udhcpc moves from an
        unbound, to a bound state. All of the paramaters are set in
        enviromental variables, The script should configure the interface,
        and set any other relavent parameters (default gateway, dns server,
        etc).
       
        renew: This argument is used when a DHCP lease is renewed. All of
        the paramaters are set in enviromental variables. This argument is
        used when the interface is already configured, so the IP address,
        will not change, however, the other DHCP paramaters, such as the
        default gateway, subnet mask, and dns server may change.
        nak: This argument is used with udhcpc receives a NAK message.
        The script with the deconfig argument will be called directly
        afterwards, so no changes to the network interface are neccessary.
        This hook is provided for purely informational purposes (the
        message option may contain a reason for the NAK).
The paramaters for enviromental variables are as follows:
        $HOME                - The set $HOME env or "/"
        $PATH                - the set $PATH env or "/bin:/usr/bin:/sbin:/usr/sbin"
        $1                - What action the script should perform
        interface        - The interface this was obtained on
        ip                - The obtained IP
        siaddr                - The bootp next server option
        sname                - The bootp server name option
        boot_file        - The bootp boot file option
        subnet                - The assigend subnet mask
        timezone        - Offset in seconds from UTC
        router                - A list of routers
        timesvr                - A list of time servers
        namesvr                - A list of IEN 116 name servers
        dns                - A list of DNS server
        logsvr                - A list of MIT-LCS UDP log servers
        cookiesvr        - A list of RFC 865 cookie servers
        lprsvr                - A list of LPR servers
        hostname        - The assigned hostname
        bootsize        - The length in 512 octect blocks of the bootfile
        domain                - The domain name of the network
        swapsvr                - The IP address of the client's swap server
        rootpath        - The path name of the client's root disk
        ipttl                - The TTL to use for this network
        mtu                - The MTU to use for this network
        broadcast        - The broadcast address for this network
        ntpsrv                - A list of NTP servers
        wins                - A list of WINS servers
        lease                - The lease time, in seconds
        dhcptype        - DHCP message type (safely ignored)
        serverid        - The IP of the server
        message                - Reason for a DHCPNAK
        tftp                - The TFTP server name
        bootfile        - The bootfile name
additional options are easily added in options.c.
note on udhcpc's random seed
---------------------------
udhcpc will seed its random number generator (used for generating xid's)
by reading /dev/urandom. If you have a lot of embedded systems on the same
network, with no entropy, you can either seed /dev/urandom by a method of
your own, or doing the following on startup:
ifconfig eth0 > /dev/urandom
in order to seed /dev/urandom with some data (mac address) unique to your
system. If reading /dev/urandom fails, udhcpc will fall back to its old
behavior of seeding with time(0).
signals accepted by udhcpc
-------------------------
udhcpc also responds to SIGUSR1 and SIGUSR2. SIGUSR1 will force a renew state,
and SIGUSR2 will force a release of the current lease, and cause udhcpc to
go into an inactive state (until it is killed, or receives a SIGUSR1). You do
not need to sleep between sending signals, as signals received are processed
sequencially in the order they are received.
compile time options
-------------------
options.c contains a set of dhcp options for the client:
        name[10]: The name of the option as it will appear in scripts
       
        flags: The type of option, as well as if it will be requested
        by the client (OPTION_REQ)
        code: The DHCP code for this option


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/17258/showart_1090833.html

分享到:
评论

相关推荐

    udhcpc配置文件default.script

    文件系统使用udhcpc获取IP,可是ifconfig查看网卡信息时,IP地址没有改变。

    udhcpc源码

    udhcp客户端主要通过发送DHCP请求报文,并接收服务器的响应来完成网络配置。源码中的关键组件包括选项解析器、报文构造器、网络通信模块等,这些都是实现DHCP协议必不可少的部分。 在编译udhcp源码时,通常遵循以下...

    udhcpc_1.27.2-2ubuntu3_armhf软件包

    它依赖于相近版本的busybox,如果需要下载busybox,请移步https://download.csdn.net/download/hannibaychty/85593276

    udhcp源码详解 udhcp源码详解

    DHCP (Dynamic Host Configuration Protocol) 是一种网络协议,用于自动分配IP地址和其他网络配置信息给网络上的设备。udhcp是一个轻量级的DHCP服务器实现,通常用于嵌入式系统和小型网络环境中。本篇文章将深入探讨...

    default.script

    拷贝到开发板/usr/share/udhcpc/目录下,执行udhcpc -i eth0,实现动态获取IP地址

    mount_nfs.sh

    #udhcpc #config ip netmask gw #ifconfig eth0 172.20.223.123 netmask 255.255.255.0 #route add default gw 172.20.223.254 serverip=$1 serverpath=$2 localpath=$3 echo "usage:./mount_nfs serverip server...

    linux操作系统DHCP服务器配置.ppt

    3. 管理DHCP服务器,包括监控服务器状态、日志记录、故障排除等。 DHCP的部署: 1. 在服务器上安装和配置DHCP服务器软件。 2. 在客户机上安装DHCP客户端软件,例如dhcpcd或udhcpc。 3. 配置客户机的网络接口,包括...

    自动获得IP

    自动获得IP地址

    udhcp_0.9.8cvs20050303.orig.tar.gz

    2. 编译环境配置:设置交叉编译工具链,以便在目标平台以外的系统上构建UDHCPC。 3. 修改配置文件:根据目标系统的特性调整源代码中的宏定义和配置选项。 4. 编译和链接:使用适当的编译器和链接器命令构建UDHCPC可...

    udhcp-0.9.8

    udhcp-0.9.8 是一个轻量级的动态主机配置协议(DHCP)服务器软件,它为网络管理员提供了一种简单、高效的方式来自动分配IP地址和其他网络配置信息给网络上的设备。udhcp项目由William P. Johnson开发,其设计目标是...

    解决无法自动获取IP的问题

    "解决无法自动获取IP的问题" 在计算机网络中,自动获取 IP 地址是指计算机在连接网络时,可以从 DHCP 服务器自动获取 IP 地址,而不需要手动设置 IP 地址。但是,有时计算机可能无法自动获取 IP 地址,导致无法上网...

    linux下atheros8328初始化及配置过程.pdf

    使用`udhcpc`服务获取动态IP地址,并通过iptables规则实现NAT(网络地址转换),使内部网络能够访问外部网络。 ### PPPOE方式配置 通过向特定的系统文件写入值,配置PPPoE服务器和客户端的参数,如IP地址、MAC地址...

    嵌入式Linux设置静态或动态或动态IP的方法

    在嵌入式Linux下修改文件进行设置开机启动时静态IP或者动态IP

    基于C语言的udhcp协议实现

    DHCP(Dynamic Host Configuration Protocol)是一种网络协议,用于自动分配或动态配置IP地址、子网掩码、默认网关等网络参数。在本项目中,我们关注的是一个基于C语言实现的轻量级DHCP客户端和服务端软件——udhcp...

    TQ335x学习笔记——Nand&&网卡驱动移植

    例如,`gpmc_ad0.gpmc_ad0`表示地址线AD0的配置,`gpmc_wpn.gpio0_30`表示写保护信号WPN的配置。这里的配置符合TQ335x开发板的实际硬件连接情况,无需额外修改。 **1.2 开启BCH纠错功能** 尽管Nand Flash已经被...

    Atheros _AR8328 NAT_HELP单VLAN移植测试报告.pdf

    在文档中,通过配置WAN口的PC1通过DHCP获取IP地址,同时在路由器上进行了相应的网络设置,例如启动udhcpc服务、配置iptables进行NAT以及开启IP转发功能,以实现内网PC2与外网的通信。 4. PPPoE(点对点协议)上网...

    Linux中Shell截取某行某列信息

    背景:执行shell命令,抓取shell返回信息中的所需信息,已udhcpc为例获取DNS的地址。 暂不作处理,执行udhcpc。 使用grep过滤掉无用信息,执行 udhcpc | grep “DNS” 使用sed抓取第二行,-n ‘2p’代表第二行,-n...

    linux下精简版dhcp

    编译成功后,udhcpd和udhcpc二进制文件会被安装到系统路径中,如`/usr/local/bin`,接着可以按照上述介绍配置和使用udhcp服务。 总结,Linux下的精简版DHCP——udhcp,是一个轻量级且实用的解决方案,尤其适用于...

    TQ2440DHCPMn linux下自动获取ip分配

    - 在 BusyBox 配置选项中选择 **Networking Utilities** 下的 **[*] udhcpclient (udhcpc)**。 2. **复制脚本文件**: - 将 `examples/udhcp/simple.script` 文件复制到 `/usr/share/udhcpc/` 并重命名为 `default....

Global site tag (gtag.js) - Google Analytics