I have installed a fresh CentOS Linux on a virtual machine and I try to work. But it does not have access to the Internet by default.
ping google.com
with the result:
ping: google.com: Name or service not known
How to enable the Internet access for the first time?
I assume you have no access to a proper editor and you cannot install any package either due to the lack of internet access.
The first step is to know what is your Internet interface:
nmcli d
The second step is to enable the interface. Let's say your interface (device) is enp0s3
. In the terminal, type:
nmcli con up enp0s3
You should receive an output like:
Connection successfully activated. ...
if so, your internet is now connected. But, this is a temporary solution. Upon another restart, again your Internet will not be enabled. Therefore, you need to enable the Internet upon booting by default.
Edit the file /etc/sysconfig/network-scripts/ifcfg-enp0s3
file
sudo nano /etc/sysconfig/network-scripts/ifcfg-enp0s3
and change
ONBOOT=yes
Then, reboot your system.