最近在做项目的时候卡在了dhcp处,当没有网络的时候,板子一直发送dhcp请求,导致程序不往下执行,解决的办法是把它切换到后台运行,可是如何切换到后台呢,有办法,它自带参数可以实现该功能。如下:

udhcpc -b -i eth0 -p /var/run/udhcpc.pid -R

解释一下,-b就是切换到后台指令,-i是指定使用哪个网络接口,双网卡的时候一定要使用它来指定eth0  or  eth1。

【最近新添加 -R】

对于 -R参数,其实也很重要,在关闭udhcpc时,可以向dhcpserver发送release取消租约。

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 beimmediately negotiated.
-i, --interface=INTERFACE       Interface to use (default: eth0)
-n, --now                       Exit with failure if lease cannot beimmediately 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 versionIf 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, andwhen a leases is lost. The script should put the interface in anup, but deconfigured state, ie: ifconfig $interface 0.0.0.0.bound: This argument is used when udhcpc moves from anunbound, to a bound state. All of the paramaters are set inenviromental 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 ofthe paramaters are set in enviromental variables. This argument isused when the interface is already configured, so the IP address,will not change, however, the other DHCP paramaters, such as thedefault 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 directlyafterwards, so no changes to the network interface are neccessary.This hook is provided for purely informational purposes (themessage 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 performinterface - The interface this was obtained onip  - The obtained IPsiaddr  - The bootp next server optionsname  - The bootp server name optionboot_file - The bootp boot file optionsubnet  - The assigend subnet masktimezone - Offset in seconds from UTCrouter  - A list of routerstimesvr  - A list of time serversnamesvr  - A list of IEN 116 name serversdns  - A list of DNS serverlogsvr  - A list of MIT-LCS UDP log serverscookiesvr - A list of RFC 865 cookie serverslprsvr  - A list of LPR servershostname - The assigned hostnamebootsize - The length in 512 octect blocks of the bootfiledomain  - The domain name of the networkswapsvr  - The IP address of the client's swap serverrootpath - The path name of the client's root diskipttl  - The TTL to use for this networkmtu  - The MTU to use for this networkbroadcast - The broadcast address for this networkntpsrv  - A list of NTP serverswins  - A list of WINS serverslease  - The lease time, in secondsdhcptype - DHCP message type (safely ignored)serverid - The IP of the servermessage  - Reason for a DHCPNAKtftp  - The TFTP server namebootfile - The bootfile nameadditional 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/urandomin 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 scriptsflags: The type of option, as well as if it will be requestedby the client (OPTION_REQ)code: The DHCP code for this option

udhcpc 后台运行的方法相关推荐

  1. udhcpc 后台运行的方法【总结】

    最近在做项目的时候卡在了dhcp处,当没有网络的时候,板子一直发送dhcp请求,导致程序不往下执行,解决的办法是把它切换到后台运行,可是如何切换到后台呢,有办法,它自带参数可以实现该功能.如下: ud ...

  2. Win11怎么禁止软件后台运行?Win11系统禁止应用在后台运行的方法

    Win11怎么禁止软件后台运行?有一些用户不希望某些软件在后台偷偷运行,所以想要知道如何禁止软件后台运行,今天系给朋友们介绍Win11系统禁止应用在后台运行的方法,这个方法只能设置已安装应用的后台运行 ...

  3. 华为怎么关Android,华为手机怎么关闭后台运行程序 华为手机关闭后台运行程序方法...

    初次使用华为手机的朋友注意了,华为手机关闭程序时,容易忘记从后台关闭.这样就会导致手机后台运行程序越来越多,手机使用变得越来越慢.那么怎么操作才能从后台上关闭程序呢? 华为手机关闭后台运行程序方法 这 ...

  4. Linux 后台运行程序方法总结

      在用服务器跑数据的时候经常会遇到数据量大,速度慢的情况,动不动需要用好几天甚至上十天,但电脑总不能好几天不关终端,且保证不断网吧.所以这时候我们就需要将程序放到后台运行,不依赖于终端.关于原理,我 ...

  5. Linux后台运行Jar方法

    在linux服务器上运行Jar文件时通常的方法是: $ java -jar test.jar 这种方式特点是ssh窗口关闭时,程序中止运行.或者是运行时没法切出去执行其他任务,有没有办法让Jar在后台 ...

  6. android app锁定后台运行的方法

    想直接看图操作,可以android 下一个 小米穿戴 然后 我->开启后台运行权限 ->点击当前手机后面的 里面有 小米MIUI,华为EMUI,OPPO ColorOS ,Vivo Fun ...

  7. matlab 后台运行,MATLAB在后台运行的方法

    EDA365欢迎您登录! 您需要 登录 才可以下载或查看,没有帐号?注册 x 有时我们需要远端服务器上运行MATLAB(当然,也包括其它程序,这里将MATLAB作为一个例子).但不希望被其它人无意之间 ...

  8. MongoDB服务重启及后台运行解决方法

    1 在MongoDB 安装目录下 新建一个test文件夹 mkdir /test 2 切换到MongoDB的安装目录(可通过 find -name 'mongod'命令查找安装目录)下 执行: bin ...

  9. 在linux将一些程序放到后台运行的方法(nohup/screen/daemonize)

    方法一:nohup # nohup sh xkahn.sh & 方法二:screen 1.先安装screen程序 yum install -y screen 2.运行screen程序 (注释: ...

  10. golang 程序后台运行的方法 linux windows

    方法1: windows 只需要在编译的时候使用一下go build - ldflags="-H windows" Linux  在运行程序的尾部加入&,或者nohup . ...

最新文章

  1. 支持向量回归_量化投资学习笔记22——回归分析:支持向量机
  2. 为了帮粉丝完成毕业设计,我发现了一款私活神器
  3. 3.eclipse对mysql云数据库编程增删改查
  4. bzoj 4447 小凸解密码
  5. Ubuntu 安装 CLI 并运行 ASP.NET Core 1.0
  6. 世界各国国家货币代码大全[收藏]
  7. java调用存储过程 sql server,Sql Server的存储过程与Java代码相连接调用(二)
  8. ^_^Hostname openapi.alipaydev.com not verified:
  9. I2C协议---I2C时序图解析
  10. 帆软通过js删除数据库表中的数据
  11. Windows下搭配AirSim环境
  12. 求小于或等于lim的所有素数,将其存放在aa数组中,并返回所求的素数个数
  13. 极客时间专栏:透视HTTP
  14. 上班迟到,单位能按员工手册罚款吗?
  15. 机器学习技法 之 梯度提升决策树(Gradient Boosted Decision Tree)
  16. 安装weblogic并部署jpress项目(fmw_14.1.1.0.0_wls_lite_quick_Disk1_1of1.zip)
  17. SPOJ 7258 SUBLEX 后缀数组_二分答案_前缀和
  18. 直流电路中升降压(Buck-Boost)变换电路的设计、参数选取及Matlab/Simulik仿真
  19. 软考A计划-真题-分类精讲汇总-第十五章(数据库设计)
  20. 有源晶振与无源晶振的区别

热门文章

  1. forge是用java装吗_我的世界forge怎么安装 forge使用方法
  2. 设计模式-行为型软件设计模式(六)
  3. 如何测试硬盘软件,win10系统怎么用硬盘检测工具HDTune【图文】
  4. Python用pyecharts绘制中国各地级市gdp分布点图
  5. 社区之星任玉刚:Android开发者的职场规划
  6. [吐槽]今天单纯吐槽一下VS2017社区版
  7. 直升机的扭力与反扭力
  8. 使用IDEA搭建SSM项目
  9. 西门子plc语句表是c语言吗,分享精心整理的西门子PLC指令表
  10. 迅捷会员管理系统v1.7免费版正式发布了-为创业而生