如何使用Linux命令 自动获取IP
2013-12-20 06:13
781 查看
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 ] ]
linux dhclient 的演示示例:
dhclient eth0
Renews the IP address.
Linux renew ip command
$ sudo dhclient -r //release ip 释放IP
$ sudo dhclient //获取I
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. |
dhclient eth0
Renews the IP address.
Linux renew ip command
$ sudo dhclient -r //release ip 释放IP
$ sudo dhclient //获取I
相关文章推荐
- Linux网络编程----bind自动获取自己的IP和PORT,端口使用的注意事项
- linux如何用命令获取本机ip呢?
- linux下的shell命令的编写,以及java如何调用linux的shell命令(java如何获取linux上的网卡的ip信息)
- linux使用dhclient自动获取IP
- 程序内执行shell命令自动获取局域网内所有在线IP和开放端口(Linux)
- 使用 python 获取 Linux 的 IP 信息(通过 ifconfig 命令)
- Linux如何获取命令使用帮助说明
- linux下的shell命令的编写,以及java如何调用linux的shell命令(java如何获取linux上的网卡的ip信息)
- linux命令使用规则及如何获取帮助
- 浅析如何使用busybox的udhcpc实现开发板ip和dns自动获取
- Linux如何获取命令的使用帮助
- 在Linux下如何获取命令的使用帮助
- linux下如何从自动获取ip转到手动配置ip
- linux使用dhclient自动获取IP
- linux中如何使用find命令查找文件
- linux下如何使用sftp命令
- 如何在使用 scp 命令时递归地排除文件 | Linux 中国
- 系统无ifconfig,一条命令获取本机ip并将其赋值给指定变量来使用
- 在linux系统中如何使用命令行获取本机的公网IP
- linux下获取占用CPU资源最多的10个进程,可以使用如下命令组合: ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head linux下