如何使用Linux命令dhclient
如何使用Linux命令 dhclient
The Internet Systems Consortium DHCP Client, dhclient, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Protocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.
linux dhclient 的语法
dhclient [ -p port ] [ -d ] [ -e VAR=value ] [ -q ] [ -1 ] [ -r ] [ -lf lease-file ] [ -pf pid-file ] [ -cf config-file ] [ -sf script-file ] [ -e ENVVAR=value ] [ -s server ] [ -g relay ] [ -n ] [ -nw ] [ -w ] [ if0 [ ...ifN ] ]
-p port | If the DHCP client should listen and transmit on a port other than the standard (port 68), the -p flag may used. It should be followed by the udp port number that dhclient should use. This is mostly useful for debugging purposes. If a different port is specified for the client to listen on and transmit on, the client will also use a different destination port - one greater than the specified destination port. |
-s | The DHCP client normally transmits any protocol messages it sends before acquiring an IP address to, 255.255.255.255, the IP limited broadcast address. For debugging purposes, it may be useful to have the server transmit these messages to some other address. This can be specified with the -s flag, followed by the IP address or domain name of the destination. |
-g | For testing purposes, the giaddr field of all packets that the client sends can be set using the -g flag, followed by the IP address to send. This is only useful for testing, and should not be expected to work in any consistent or useful way. |
-d | The DHCP client will normally run in the foreground until it has configured an interface, and then will revert to running in the background. To run force dhclient to always run as a foreground process, the -d flag should be specified. This is useful when running the client under a debugger, or when running it out of inittab on System V systems. |
-e | The dhclient daemon creates its own environment when executing the dhclient-script to do the grunt work of interface configuration. To define extra environment variables and their values, use the -e flag, followed by the environment variable name and value assignment, just as one would assign a variable in a shell. Eg: -e IF_METRIC=1 |
-r | The client normally doesn't release the current lease as it is not required by the DHCP protocol. Some cable ISPs require their clients to notify the server if they wish to release an assigned IP address. The -r flag explicitly releases the current lease, and once the lease has been released, the client exits. |
-1 | The -1 flag cause dhclient to try once to get a lease. If it fails, dhclient exits with exit code two. |
-cf, -lf, -pf, and -sf | The DHCP client normally gets its configuration information from /etc/dhcp3/dhclient.conf, its lease database from /var/lib/dhcp3/dhclient.leases, stores its process ID in a file called /var/run/dhclient.pid, and configures the network interface using /sbin/dhclient-script To specify different names and/or locations for these files, use the -cf, -lf, -pf and -sf flags, respectively, followed by the name of the file. This can be particularly useful if, for example, /var/lib/dhcp3 or /var/run has not yet been mounted when the DHCP client is started. |
-w | The DHCP client normally exits if it isn't able to identify any network interfaces to configure. On laptop computers and other computers with hot-swappable I/O buses, it is possible that a broadcast interface may be added after system startup. The -w flag can be used to cause the client not to exit when it doesn't find any such interfaces. The omshell (1) program can then be used to notify the client when a network interface has been added or removed, so that the client can attempt to configure an IP address on that interface. |
-n | The DHCP client can be directed not to attempt to configure any interfaces using the -n flag. This is most likely to be useful in combination with the -w flag. |
-nw | The client can also be instructed to become a daemon immediately, rather than waiting until it has acquired an IP address. This can be done by supplying the -nw flag. |
-e | The client runs child processes (scripts) with a clean environment. Use the -e flag to specify additional environment variables to pass to child processes. |
linux dhclient 的演示示例:
dhclient eth0
Renews the IP address.
Linux renew ip command
$ sudo dhclient -r //release ip 释放IP
$ sudo dhclient //获取IP
busybox提供的udhcpc命令的使用
# udhcpc --help
BusyBox v1.16.1 (-- :: 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,--vendorclass=CLASSID Vendor class identifier
-i,--interface=INTERFACE Interface to use (default eth0)
-H,-h,--hostname=HOSTNAME Client hostname
-c,--clientid=CLIENTID Client identifier
-C,--clientid-none Suppress default client identifier
-p,--pidfile=FILE Create pidfile
-r,--request=IP IP address to request
-s,--script=FILE Run FILE at DHCP events (default /usr/share/udhcpc/default.script)
-t,--retries=N Send up to N discover packets
-T,--timeout=N Pause between packets (default seconds)
-A,--tryagain=N Wait N seconds (default ) after failure
-O,--request-option=OPT Request DHCP option OPT (cumulative)
-o,--no-default-options Don't request any options (unless -O is also given)
-f,--foreground Run in foreground
-b,--background Background if lease is not immediately obtained
-S,--syslog Log to syslog too
-n,--now Exit with failure if lease is not immediately obtained
-q,--quit Quit after obtaining lease
-R,--release Release IP on quit
-P,--client-port N Use port N instead of default
-a,--arping Use arping to validate offered address
如何使用Linux命令dhclient的更多相关文章
- linux命令dhclient
linux命令 dhclient 背景 多台服务器(CentOS7 系统)设置静态IP,其中有台服务器设置了静态IP后,只要重启就变更为其他的,但是配置文件并无改动. 使用命令 #自动获取IP dhc ...
- 一天一个Linux命令--dhclient
dhclient -r #用于释放ip地址2 dhclient #获取IP地址 主要针对只有命令行的Linux机器,临时改变了网络环境,事先手动设置的ip地址 看一下自带的解释 root@ubuntu ...
- Linux命令整理中...
Linux命令整理中... 最常用命令(我最近最常用的一般放在前面tipsbychsry) clear 清屏 date 显示日期 cal 显示日历 cal 2014 显示2014年的日历 shutdo ...
- wpa_supplicant 移植及 linux 命令行模式配置无线上网
本文涉及内容为linux 命令行模式配置无线上网 及 wpa_supplicant 移植到开发板的过程,仅供参考. 1.源码下载 wpa_supplicant 源码下载地址 :http://hosta ...
- 这些Linux命令,让你的工作事半功倍!
这些Linux命令,让你的工作事半功倍! 最近都在和Linux打交道,感觉还不错.我觉得Linux相比windows比较麻烦的就是很多东西都要用命令来控制,当然,这也是很多人喜欢linux的原因,比较 ...
- 《Linux命令学习手册》系列分享专栏
<Linux命令学习手册>系列分享专栏 <Linux命令学习手册>已整理成PDF文档,点击可直接下载至本地查阅https://www.webfalse.com/read/207 ...
- Linux命令——pgrep
参考:Linux pgrep Command Tutorial for Beginners (10 Examples) Linux命令——ps.pstree bash基础——grep.基本正则表达式. ...
- linux命令截取文件最后n行(所有命令)
linux命令截取文件最后n行(所有命令) tail -n a.txt > b.txt 联想:系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) una ...
- 软件测试从业者必备的Linux命令(完整篇)
观点: 关于Linux,测试从业者,看这篇文章就够了 . 具体,往下看 : 网上关于Linux资料太多.太杂,学习没有重点,特别是对于没有基础的从业者,期望通过那些文档,去自学掌握Linux,可能性太 ...
随机推荐
- python学习之self,cls,staticmethod,classmethod
一.总体说明 python类里会出现这三个单词,self和cls都可以用别的单词代替,类的方法有三种, 一是通过def定义的 普通的一般的,需要至少传递一个参数,一般用self,这样的方法必须通过一个 ...
- Kindle Paperwhite 2使用体验
博客开通后一懒就扔下了几十天,着实自惭.鉴于是第一篇,先说点题外话. 一转眼读研的生活已经过去一年有余.曾经的同学已经在职场拼搏,同龄人的生活状态也自然地带给自己一份紧迫感:不敢再贪恋校园生活的安逸, ...
- C++读取、旋转和保存bmp图像文件编程实现
以前也遇到过bmp文件的读写.这篇博客很好,写的其他内容也值得学习. 参考:http://blog.csdn.net/xiajun07061225/article/details/6633938 学 ...
- JAVA WEB SQLHelper类的封装
在这次做项目中,我对自己最满意的就是封装了一下SQLHelper类,我对自己感到骄傲主要是 我是初学者,我刚开始不知道可以这样做,我只是想着试着去这样做了,结果真的可以,所以我 在我的模块就自己封装了 ...
- HDU4861:Couple doubi(费马小定理)
题意: 给出k个球和质数p,对每个球以公式val(i)=1^i+2^i+...+(p-1)^i (mod p)计算出它的价值,然后两个人轮流拿,最后拿到的球的总价值大的获胜,问我们先手是否获胜. 我们 ...
- 第二百四十四、五天 how can I 坚持
昨天忘了.不知咋忘的,加班加迷糊了? 昨天联调接口,又加班了,好歹基本调通了. 今天,下午,开会,有点被领导批的意思,不是批我,是批我们团队. 团队. 不懂自己. 这样做有意义嘛. 睡觉.好烦. 到底 ...
- Spring SimpleJdbcTemplate Querying examples
Here are few examples to show how to use SimpleJdbcTemplate query() methods to query or extract data ...
- [C语言 - 10] C语言保留字
一 数据类型关键字 12 个: 1 . char 2 . short 3 . int 4 . long 5. enum 6. float 7. dou ...
- Altium Desiger自定义BOM导出格式
用Excel做一个xx.xlt的2003的模版文件,如名为:AltiumDesiger PCB BOM Template.xlt 将AltiumDesiger PCB BOM Template.xlt ...
- mysql删除重复记录语句,删除除了 id 号不同,其他都相同的学生冗余信息
/** 在Mysql下执行: delete from my.stu where id not in( select min(id) id from my.stu group by code) ; 用途 ...