Linux Force DHCP Client (dhclient) to Renew IP Address

Source: Internet
Author: User

http://www.cyberciti.biz/faq/howto-linux-renew-dhcp-client-ip-address/' m using Ubuntu Linux. How to force Linux to reacquire a new IP address from the DHCP server? What's the command in Linux equivalent to Windows ' " ipconfig /renew command?

You need to use the Dynamic Host Configuration Protocol Client i.e. dhclient command. The client normally doesn ' t release the current lease as it isn't required by the DHCP protocol. Some cable ISPs require their clients to notify the server if they wish to release an assigned IP address.

dhclientthe command, provides a means for configuring one or more network interfaces using the Dynamic Host Configuration Pr Otocol, BOOTP protocol, or if these protocols fail, by statically assigning an address.

Linux Renew IP Command

-rthe flag explicitly releases the current lease, and once the lease have been released, the client exits. For example, open terminal and type the command:
$ sudo dhclient -r
Now obtain fresh IP:
$ sudo dhclient

How can I renew or release a IP in Linux for eth0?

To renew or release a IP address for the Eth0 interface, enter:
$ sudo dhclient -r eth0
$ sudo dhclient eth0

In this example, I am renewing a IP address for my wireless interface:

sudo dhclient-v-R eth0sudo dhclient-v eth0

Sample outputs:

Fig.01:renew DHCP Address Example


The -v option shows information on screens about DHCP server and obtained lease.

Other options on Linux to renew DHCP

There is the no need to restart Network service. Above command should work with any Linux distro such as RHEL, Fedora, CentOS, Ubuntu and others. On a related note You can also try out the following commands:
# ifdown eth0
# ifup eth0
### RHEL/CentOS/Fedora specific command ###
# /etc/init.d/network restart

OR
### Debian / Ubuntu Linux specific command ###
# /etc/init.d/networking restart

NMCLI command (NetworkManager) to renew IP address in Linux

The NetworkManager daemon attempts to make networking configuration and operation as painless and automatic as possible by Managing the primary network connection and other network interfaces, like Ethernet, WiFi, and Mobile Broadband devices C Ommand-line tool for controlling NetworkManager. The is nmcli a command-line tool for controlling NetworkManager and getting its status. To renew the IP address using nmcli for connection named ' nixcraft_5g ' (use " nmcli con command to get list of all connections"):

Nmcli connmcli con down id ' nixcraft_5g ' nmcli con up id ' nixcraft_5g '

Sample outputs:

FIG.02:NMCLI command in action

See Also
    • Man Pages:nmcli (1), dhclient (8)

Linux Force DHCP Client (dhclient) to Renew IP Address

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.