I installed CentOS as a Virtual Machine using VirtualBox on my Ubuntu machine. The only problem is that there is no Internet connection. Why is it like that? What can I do to solve the problem?
Many things might cause this problem, but I will share with you two methods that might help you solve it at once. When you try to connect a virtual machine to the Internet through the host computer, things are different depending on the operating system installed on the virtual machine.
You should first check the status of your network card.
The problem is most likely hidden right here. Run the following command to see the settings of your network card.
Here you should look for the first line to see if the network is enabled or disabled. If it says “enp0s3: disconnected” that is the problem. What can you do to solve this problem? It is most likely hidden in the configuration of the network card. You can check this by running the following command.
Now you will see approximately fifteen lines of text. Look for the following at the end of the text:
If you see such a line, that is what’s causing the problem. To fix it, run the following command.
sudo vi /cat/sysconfig/network-scripts/ifcfg/enp0s3
This will open the file in a text editor installed on your system. There are better and easier text editors available, but since you do not have any network available, you cannot install them. As a result, you will have to solve this problem in the VI editor. Do it in the following way.
The VI editor operates in two modes; command and insert mode. As you open the file, it is in command mode, and you cannot make any changes. To enter insert mode, click the I button (the letter, not the number). To leave the insert mode, click the ESC button. This will take you back to the command mode, where you can run commands such as save, quit, search, and other useful things.
- Move using your cursor to the bottom of the file where you see the text onboot=no.
- Move your cursor to the end of the line and click I (to enter insert mode).
- Remove the no text and type yes.
- Click ESC to leave insert mode and enter command mode.
- Type the following: :wq (colon-w-q). This will write/save the file and then quit the file.
If you mess something up and just want to get out of the VI editor, click ESC to enter command mode and run the command :q. This will leave the file without saving any changes you have made.
If you want to see if you can successfully make the changes, rerun the following command.
Did you have success? The Internet still isn’t working because you haven’t applied the new settings. This can be done by running the following command.
sudo systemctl restart network.service
This will restart the network service and apply the new settings. An easy way to see if things now work properly is by running the following commands.
ping www.ipaddressguide.org ping 18.104.22.168
Any of the commands above will get the job done. If you can ping the website or the IP address, you have solved the problem, and you can now access the Internet on your virtual machine.
Wasn’t this your problem? You can try the following instead.
The next step is to check the network settings for your virtual machine with CentOS installed.
Start by going to the network settings and choose “Bridged adapter” and your network card. If you use a wireless network, it is most likely called wlp3s0. If you use a normal ethernet connection, it is called enp2s0.
By default, it should also work with NAT selected, but if it doesn’t, you can change it to Bridged Adapter (as seen in the image above).
When this is done, you can return to your virtual machine and see if the changes have been made any changes.
I hope these instructions have helped you and that you can connect to the Internet with your Virtual Machine with CentOS installed.