00. 目录


文章目录


​00. 目录​​​​01. 命令概述​​​​02. 命令格式​​​​03. 常用选项​​​​04. 参考示例​​​​05. 附录​


01. 命令概述

dhclient命令​使用动态主机配置协议动态的配置网络接口的网络参数,也支持BOOTP协议。

02. 命令格式

dhclient [参数] [网络接口]

03. 常用选项

-4 : 使用DHCPv4
-6 : 使用DHCPv6
-p 指定dhcp客户端监听的端口号(默认端口号86)
-d 总是以前台方式运行程序
-q 安静模式,不打印任何错误的提示信息
-r 释放ip地址
-n 不配置任何接口
-x 停止正在运行的DHCP客户端,而不释放当前租约,杀死现有的dhclient
-s 在获取ip地址之前指定DHCP服务器
-w 即使没有找到广播接口,也继续运行

04. 参考示例

4.1 动态获取IP

[root@localhost ~]# dhclient

4.2 释放IP

[root@localhost ~]# dhclient -r

4.3 动态获取IP,并且显示过程

[root@localhost ~]# dhclient -v ens33
dhclient(71545) is already running - exiting.

This version of ISC DHCP is based on the release available
on ftp.isc.org. Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.

Please report for this software via the CentOS Bugs Database:
http://bugs.centos.org/

exiting.
[root@localhost ~]#

4.4 释放IP,显示过程

[root@localhost ~]# dhclient -r -v ens33
Internet Systems Consortium DHCP Client 4.2.5
Copyright 2004-2013 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ens33/00:50:56:26:d8:88
Sending on LPF/ens33/00:50:56:26:d8:88
Sending on Socket/fallback
DHCPRELEASE on ens33 to 192.168.12.2 port 67 (xid=0x254c08e2)

4.5 从指定的服务器获取ip地址

[root@localhost ~]# dhclient -s 192.168.12.2

4.6 停止运行dhclient

[root@localhost ~]# dhclient -x

05. 附录

参考:​​【Linux】一步一步学Linux系列教程汇总​