[Solved] No Internet Connection on Fresh CentOS Install

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.

2. Become root user.


3. Enter the following command in terminal:

dhclient -v

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 port 67 interval 8 (xid=0x24d39d2e)
DHCPREQUEST on enp0s3 to port 67 (xid=0x24d39d2e)
DHCPACK from (xid=0x24d39d2e)
bound to -- 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 enp0s3.

ip a

ip a command in CentOS terminal

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.

nano /etc/sysconfig/network-scripts/ifcfg-enp0s3

3. Make sure that these two settings are configured in the file.


Network interface settings

4. Save your changes to the file and exit. Now, the interface will seek an IP address via DHCP upon each reboot.

Leave a Comment

Your email address will not be published.