如何强制linux DHCP 客户端重新获取IP

如何强制linux DHCP 客户端重新获取IP,第1张

强制linux DHCP 客户端重新获取IP的方法和详细的 *** 作步骤如下:

1、首先,连接到相应的Linux主机,进入Linux命令行状态,然后等待输入shell指令,如下图所示。

2、其次,在Linux命令行上输入:dhclient,如下图所示。

3、最后,按键盘上的“ Enter”键运行shell指令,您将看到DHCP服务重新获取IP为192.168.6.2,如下图所示。

如何使用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

可用指令如下:

1、service network restart:重启服务

2、ifconfig eth0 down  ifconfig eth0 up:对网卡进行 *** 作

3、sudo dhclient -r//release ip:释放IP

4、sudo dhclient//:获取IP

扩展资料:

linux常用命令及技巧

1、date :print or set the system date and time

2、 stty -a: 可以查看或者打印控制字符(Ctrl-C, Ctrl-D, Ctrl-Z等)

3、passwd: print or set the system date and time (用passwd -h查看)

4、logout, login: 登录shell的登录和注销命令

5、pwd: print working directory

6、more, less, head tail: 显示或部分显示文件内容.

7、lp/lpstat/cancel, lpr/lpq/lprm: 打印文件.

8、更改文件权限: chmod u+x..

9、删除非空目录:rm -fr dir

10、拷贝目录: cp -R dir

11、fg jobid :可以将一个后台进程放到前台。

参考资料来源:百度百科_linux


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/yw/7243787.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-03
下一篇2023-04-03

发表评论

登录后才能评论

评论列表(0条)

    保存