How To Configure Static IP On CentOS 7. M.el Khamlichi-August 20, 2014. Question: How to switch from Dynamic to static in my CentOS 7? ‘Ifconfig’ Command Not Found In CentOS 7 Minimal Installation – A. August 11, 2014. Setting Up DNS Server On CentOS 7. August 20, 2014.
The DHCP client in Linux is called dhclient. It requests dynamic IP addresses from the DHCP server, which 'leases' addresses to clients for a set amount of time. dhclient can be invoked manually to 'release' the client's currently assigned IP address, and get another address from the DHCP server.
Normally, dhclient produces no output, to see what it's doing, we need to give it the -v (verbose) option. We also need to run dhclient as root with the sudo command, because changing the system networking configuration requires escalated privileges.
Let's start by running dhclient verbosely, without any other options. It should reach out and say 'hello' to our DHCP server, which, in this case, is a simple home router.
Command:
Output:
The above output tells us that dhclient requested an address from the DHCP server (DHCPREQUEST). It sent this request from our wireless Internet interface (wlan0). The DHCP server responded with a simple acknowledgement of our request (DHCPACK). In this case, that's about all that happened, because we already had an IP address assigned to us, so the DHCP server didn't have anything to do. Note that the DHCP server also told us how long our dynamic IP address will last: 42516 seconds (about 12 hours from now, at which point it will be renewed automatically).
So let's manually release our address with -r. Let's keep the -v option in there so we can see what's going on:
In the above example, the command tells the DHCP server to release the IP address.
WarningOn some variants of Linux or Unix, releasing your IP address this way may also inherently bring down your network interface. In this case, use your network manager to re-connect to your network. This process varies from OS to OS; if you're not sure how to connect to your network, consult the documentation of your specific OS. If you're using the X Window System, you can usually reconnect by clicking on the network icon in your system tray, and selecting the Connect option.
Additional information
- dhclient — documentation of the dhclient command and its options.
- ifconfig — documentation of the ifconfig command, a system administration tool used to configure network interfaces.