udhcpc命令

udhcpc是一个面向嵌入式系统的非常小的DHCP客户端,字母的缩写微- DHCP -客户端(μDHCPc)。

相关指令选项如下:

 # udhcpc --help

  BusyBox v1.14.1 (2010-01-22 10:35:16 CST) multi-call binary

  Usage: udhcpc [-Cfbnqtvo] [-c CID] [-V VCLS] [-H HOSTNAME] [-i INTERFACE]

  [-p pidfile] [-r IP] [-s script] [-O dhcp-option]... [-P N]

  -V CLASSID      Vendor class identifier

  -i INTERFACE    Interface to use (default: eth0)

  -H,-h HOSTNAME  Client hostname

  -c CLIENTID     Client identifier

  -C              Suppress default client identifier

  -p file         Create pidfile

  -r IP           IP address to request

  -s file         Run file at DHCP events (default /usr/share/udhcpc/default.script)

  -t N            Send up to N request packets

  -T N            Try to get a lease for N seconds (default 3)

  -A N            Wait N seconds (default 20) after failure

  -O OPT          Request DHCP option OPT (cumulative)

  -o              Do not request any options (unless -O is also given)

  -f              Run in foreground

  -b              Background if lease is not immediately obtained

  -S              Log to syslog too

  -n              Exit with failure if lease is not immediately obtained

  -q              Quit after obtaining lease

  -R              Release IP on quit

  -P N            Use port N instead of default 68

  -a              Use arping to validate offered address

  #

举个例子:

udhcpc -i usb0 -n

-n:如果不立即获得租赁,退出失败,避免出现无法获得IP租赁的情况下,程序一直提示“Sending discover...”

默认情况下是获取3次,可通过选项-T修改获取次数

-i usb0 : 使用usb0网络接口,默认情况下是使用eth0接口


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