Configure CentOS network running on a VirtualBox

If you had recently installed CentOS on a VirtualBox and unable to connect to the internet, this simple step would come in handy for you to get your OS connected to the internet.

Steps: Using a Bridged Adapter or NAT (Network Address Translation) would achieve the same result. Difference between the two options is:

[quote style=”boxed”]NAT: This enables the guest machine to access the Internet, but via a private IP address that cannot be seen from the host or the rest of your physical network.  What this means is the outside world will never be able to communicate with the guest machine directly. The assigned private address starts from and incremental.[/quote]

[quote style=”boxed”]Bridge: The VM behave as any other computer on the network where the hosting system resides. The outside world can directly communicate with the guest machine as it will be seen as another physical machine on the network.[/quote]

– Open your VirtualBox Manager, click on the virtual machine and click on Settings


– Click on Network, ensure the network adapter is enabled. Click the Attached to drop-down, select Bridged Adapter and select the appropriate host network card or select NAT



– Start up the VM, log into the server using the root account. First try and ping outside the server, you will notice that the ping fails


– Now type in the following command [highlight]vi  /etc/sysconfig/network-scripts/ifcfg-eth0[/highlight]press the Insert key on your keyboard, change the line ONBOOT=no to ONBOOT=yes. Press esc key, type in :wq to save and exit the edit screen


– Now type /etc/init.d/network restart to restart the network so the changes takes effect


– Now try pinging an external address and you should now get a response or reply


Its as easy as anything. Feel free to comment if you have a different configuration and would like some help on it if the above steps does not work for you.

comments powered by Disqus