You’ve just finished installing CentOS in a virtual machine or physical computer. But when you try to access the internet, you can’t. Does this sound familiar? It’s because the network interface doesn’t have an IP address, but there’s a simple command you can use to remedy this instantly.
To instruct the network interface to pull a new IP address via DHCP (most likely your router), follow these steps:
1. Open a terminal.
3. Enter the following command in terminal:
You’ll see some output similar to the below text, and your internet woes are now cured.
[root@localhost ddt]# dhclient -v 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/enp0s3/08:00:27:42:ab:87 Sending on LPF/enp0s3/08:00:27:42:ab:87 Sending on Socket/fallback DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 8 (xid=0x24d39d2e) DHCPREQUEST on enp0s3 to 255.255.255.255 port 67 (xid=0x24d39d2e) DHCPOFFER from 10.0.2.2 DHCPACK from 10.0.2.2 (xid=0x24d39d2e) bound to 10.0.2.15 -- renewal in 39646 seconds.
Configure dhclient to Work on Reboot
The only problem with the command above is that you’ll need to enter it every time the system is rebooted. To make this change persistent, we’ll need to configure our network interface to use DHCP automatically. Don’t worry, it’s pretty easy to do.
1. Start by finding the name of your network interface. In our case, it’s
2. Next, edit the following file with nano or some other text editor. Be sure to substitute the name of your own network interface, if necessary.
3. Make sure that these two settings are configured in the file.
4. Save your changes to the file and exit. Now, the interface will seek an IP address via DHCP upon each reboot.