How to enable internet connection on a fresh centos linux distro?

centos
linux
Category Software and digital electronics / IT
2023-01-04 04:19

Setup

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

Question

How to enable the Internet access for the first time?

Answered by robin
2023-01-04 04:56

A robust but a temporary solution

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.

A permanent solution

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.

×

Login

No account?
Terms of use
Forgot password?