Configuring Network in CentOS 6.3 Virtual Box + Screenshots

Posted: May 23, 2013 in Uncategorized
Tags: , , , , , , , , ,

This is a guide on configuring network in CentOS 6.x in Virtual Box with screenshots (using terminal).

[UPDATE: This guide can also be used to configure network on CentOS 6.5]

So, here I have used CentOS 6.3 minimal and will be discussing on configuring the Virtual Box and CentOS for network access. If you need help installing CentOS minimal in the Virtual Box, you can find the instructions in my earlier post here.


  1. Virtual Box
  2. CentOS 6.3 or 6.5 (I have tested this on CentOS 6.3 and CentOS 6.5, you can use it on other 6.x versions too)

Step 1: Configure Virtual Box Network Settings:

There are different modes or ways you can configure your Virtual box network settings.

  1. Not Attached
  2. NAT
  3. Bridged Adapter
  4. Internal Network
  5. Host-Only Adapter
  6. Generic Driver

You can find more details about the different modes here.

I will be using the Bridged Adapter mode for this guide. It is faster as it treat the VM as an individual host within the network.

Open Virtual Box and right click on  your CentOS VM, and click on “Settings“.

vbox settings

Now, go to the tab Network and change the “Attached to” field to “Bridged Adapter”. Then choose the “Name” to your network interface. For example, I have a dell wireless adapter, so I choose the Name as “Dell Wireless” from the drop down menu. And finally check the field “Cable Connected.  Finally, click on OK when you are done.

network settings

So, you have now configured the Virtual Box. Now, you can start your CentOS VM by selecting you VM and clicking on “Start”.

start vm

Step 2: Configure CentOS network settings:

You can configure your network either by using Dynamic IP addressing assigned by your DHCP server or you can manually configure your IP Address statically. You can choose either static or dynamic method and can do so by editing the file /etc/sysconfig/network-scripts/ifcfg-eth0.

Method 1: Dynamic IP 

We can configure the network by using Dynamic IP address which are assigned automatically by the DHCP server. This is the simplest way to configure your network.

NOTE: You will have a line that starts with HWADDR in the your config file, do not change or modify that line.

In your terminal, type the following:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Now, add/modify the file as follows (DO NOT CHANGE the HWADDR line your config file):






Now, save the file by pressing “ESC” and typing :wq and hit ENTER.

To view your network config file. type the following in the terminal:

cat /etc/sysconfig/network-scripts/ifcfg-eth0

dynamic ip config

Now, you will have to restart your network. You can do so by typing the following in the terminal:

                service network restart

service network restart

To view your IP address, type the following in your terminal:

                ifconfig eth0

You can see your IP Address of the interface eth0 next to the field “inet addr:” as shown below:

ifconfig eth0

Now, if you have internet access, then you can check if you are able to ping any website. And you should be able to get the reply. For example, in your terminal type:


ping results

You can press CTRL+ C to stop the ping command.

So, Hurray! you have successfully setup up your network in your CentOS Virtual Box.

Method 2: Static IP

We can also assign the network information manually by assigning the IP Address, NETMASK , GATEWAY in the network interface config file.

NOTE: You will have a line that starts with HWADDR in your config file, do not change or modify that line.

Step1 : In you terminal, type:

vi  /etc/sysconfig/network-scripts/ifcfg-eth0

Now, edit/merge the file to the following









Now, press ESC and type :wq and hit ENTER to save and exit the configuration file.

To view the config file. type the following in the terminal:

cat /etc/sysconfig/network-scripts/ifcfg-eth0

view configuration

Step 2: Change Host name: 

To change host name , you have to edit the config file /etc/sysconfig/network. If you want to know to change the host name manually, you can follow the guide I have posted earlier here.

Step 3: Assign DNS Server IP

To manually assign primary and secondary DNS Server IP addresses, in your terminal type: 

vi /etc/resolv.conf

Now, edit this file to the following:



Now, press ESC and type :wq and hit ENTER to save and exit the configuration file.

Now, if you want you can make sure you have entered and saved the correct configuration(It is a good practice to double check 😀 ). To view your dns config file, in your terminal type:

cat  /etc/resolv.conf


Step 4: Restart network:

Finally, all you have to do is to restart your network service. To so so, type the following in the terminal:

                service network restart

service network restart

Now, you can check your Current IP configuration, by typing the following in the terminal:

ifconfig eth0

ifconfig eth0

Now, if you have internet access, then you can check if you are able to ping any website. And you should be able to get the reply. For example, In your terminal type:


 ping results

You can press CTRL+ C to stop the ping command.

So, Hurray! you have successfully setup up your network manually in your CentOS Virtual Box.

Hope this guide helped you to configure network in your CentOS Virtual Machine.

If you have any queries or suggestions regarding this guide, feel free to leave a comment and will get back at you. Don’t forget to follow my blog to get future updates! :D


  1. Deepak says:

    These steps are perfect!!! Thank you so much EXTR3ME

  2. Gaetan de Speville says:

    Thank you for a very straight forward explanation that works.

  3. Anand says:

    Nice tutorial buddy
    I have installed this on a dedicated server, is there any way I can connect to the system via ssh from a remote machine.
    In fact, I have been trying to figure this out since 3 hours but have failed to achieve.

    • ΞXΤЯ3МΞ says:

      @Anand, you need to install openssh server in your dedicated server and make sure port 22 is open and the service is started. For your information, the config file will be located in /etc/ssh/sshd_config

      In the client, install the ssh client and you should be able to connect to the server.

      Let me know if you need any further help. You also can subscribe to get future updates.


  4. moscardo says:

    Hi, i’d like to thanks for your great effort to help and explain step by step with excellent text with pictures.

  5. Pedro says:

    This was exactly what I needed!

  6. Pavel says:

    Thanks a lot.

  7. Nofear says:

    Thank you very much for this outstanding work.

  8. Marcio says:

    Thanks, very helpful!

  9. Albert says:

    hi. I have 2 boxes with fedora ( for development) and CentOS 6.4. I am going to use wireless. if you are using wireless instead of eth0, would the process be the same?.
    Thank you

    • ΞXΤЯ3МΞ says:

      @Albert , It should work. As you can see , I have used my Dell wireless connection in my virutal box setup as shown in the image .I simply edited the default interface name eth0 for simplicity. If you want , you can also create another interface like wlan0 and edit it instead of editing eth0. Let me know about your experience with setting it up and post here if you need any further help. Hope this helps!


  10. Doãn Son says:

    Thanks you very much !

  11. Fachim says:

    Hey man, it is amazing, we use it for web development server, and you save us a lot. thanks 🙂

  12. Patrick says:

    when i try service network restart it says: Device eth0 does not seem to be present, delaying intialization [FAILED]

  13. Calcifer says:

    Gracias amigo estupendo tutorial me servio mucho.saludos

  14. Zerox says:

    what i have to type in my local machine to enter in the web config?

  15. Dinesh says:

    Thank you Its really Useful.

  16. Nice one, saved me hours of head scratching as a CentOS newbie.

  17. Thanks..It is a great post

  18. Eric says:

    If I choose dhcp, my network address becomes a private address, like I get internet connection, so it works fine. Is there a possibility to give centos the same ip as the external (static) ip address of the internet connection?

    (I have a Airport Extreme router between them inside my network.)

    I have tried the static option you described and set the ip address as the external address (62.x.x.x) and filled in the subnet mask and router address and dns. But when I try this the internet connection gets lost.

  19. Frosty says:

    Extremely Helpful

  20. Hermione says:

    Brilliant! you saved my life

  21. Irvan Wahyu says:

    nice tutorial this work perfectly
    can you add some tutorial about how to add repository in centOS.. it will be so helpfull..

  22. Adam Cooper says:

    Just what I needed. Thanks!

  23. Paul says:

    The MAC address in your screen shot is different than the HWADDR in your config file. Is that a mistake? Most resources on the net say those need to be in sync.

    • ΞXΤЯ3МΞ says:

      @Paul, When you initially edit the file, there would be a HWADDR already in the config file which would be already in sync with the MAC address mentioned under network settings of the Virtual Box. I have mentioned in the section “Method 1: Dynamic IP”, to keep the default MAC address in your config file as it is, as it would be already in sync. (In the screenshot, the MAC is different, I had changed the MAC address for testing purposes). And yes Paul, these settings must be in sync. Hope I have clarified all your quires. Leave a comment if you have any further queries. Hope this helps!


  24. Karadeniz says:

    Nice tutorial. I was failed to install Centos 64-bit using all DVD/CD iso’s other than the minimal install I did not why, Therefore this tut is very usefull

  25. zmozmo says:

    I would like to see GUI for CentOS. could you kindly explain me please how to do that?

  26. Thank Extreme… Good luck for you 🙂

  27. Periklis says:

    just wanted to say thanks for the detailed guide, it helped me!

  28. Thanks for posting this, it helped tremendously!

  29. luismalamoc says:

    thank you very much…

  30. Nepiddd says:

    Awesome post and very helpful. Thank you.

  31. Quan says:

    Thanks very much! 🙂

  32. SPR says:

    Hi ..i have configured Oracle virtual box and ontop of it ihave installed oracle linux6.4 ..i want to connect inter through my virtual machine but i can’t.Eeven i have configured everything what you have mentioned but i can’t please assist me on this. Here i have configured DNS and hostaname and all..please find the below

    Its all configured Bridged adaptor in virtual box.

    [root@oraclelinux6 ~]# cat /etc/hosts oraclelinux6.localdomain
    [root@oraclelinux6 ~]# route
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    default UG 0 0 0 eth1 * U 1 0 0 eth1 * U 0 0 0 virbr0
    [root@oraclelinux6 ~]# cat /etc/resolv.conf
    # Generated by NetworkManager
    search localdomain
    [root@oraclelinux6 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
    NAME=”System eth1″
    [root@oraclelinux6 ~]# cat /etc/sysconfig/network
    [root@oraclelinux6 ~]# ping
    ping: unknown host
    [root@oraclelinux6 ~]# ping
    ping: unknown host

    Can you please help me where i did wrong??

  33. SPR says:

    ..typo error on the above

    “I want to Connect internet*” through my Virtual machine(OEL 6.4)

  34. John says:

    Excelent!!, thank you!! very util!!

  35. Pablo says:

    Thanks a lot! I read a bunch of posts on other websites, everyone of them over complicated this stuff and I still wasn’t able to provide connectivity to the box. Your steps worked to perfection for me.

  36. A lot of thanksgiving around, but couldn’t help but not adding to these! Very helpful step-by-step indeed!

  37. This made my life easier, thanks.

  38. Zero says:

    Thanks A Lot

  39. satria says:

    thanks a lot. its working 🙂

  40. A really good tutorial! 🙂 How would I be able to connect to that CentOS-Server with a virtual (let’s say Fedora) Client within Virtualbox? Will I have to do this via the bridged connection?

    • ΞXΤЯ3МΞ says:

      @Kenneth Plasa, Thanks! Yes, you can connect your Centos VM with another linux vm using bridged connection if you have setup CentOS in bridged mode as mentioned in the above tutorial. There are also other methods you can use to connect/network your VMs together and you can read more about them by using this link:

      Hope this helps.


  41. jc says:

    Thank you for taking the time to post this. The steps were perfect and worked well for me.

  42. babkamen says:

    Thanks very very much, man. I spent almost 4 hours before have found this tutorial!

  43. ade says:

    Thank you so much. Very usefull

  44. Meg says:

    Dynamic IP worked perfectly for me for CentOS 6.6 🙂 thanks!

  45. dude says:

    Thanks, working here too on centos 6.7

  46. Sean says:

    I’m getting “unknown host” when I try to ping. I went through this tutorial in full. Any suggestions on what the problem could be? I’m running VirtualBox on a system of machines that is connected to our companies internal network, but also has a network switch for the system of machines to be able to talk to one another directly.

    Any type of help/feedback is appreciated!

    • ΞXΤЯ3МΞ says:

      Hi Sean,

      Are you behind a company firewall? Did you restart your network after configuration? Also, did you change your virtual box network setting to “Bridged Adapter”?

      It would be great if you could post output of the following :

      # cat /etc/redhat-release

      # ifconfig

      # cat /etc/resolv.conf

      # cat /etc/sysconfig/network-scripts/ifcfg-eth0

      # ping


  47. works great brother thnku……

  48. Viraj says:

    Excellent guide thanks a ton!!!

  49. Albert Tusky says:

    Thanks a lot i am now able to work. my vm can connect to internet

  50. Dipankar says:

    I am using ClouderaVM for centos6.7. Recently, i tried to update centos 6.7 using ‘yum update’ command and stopped it without completing the update. Now I am able to ping ‘’ but while using firefox, I am not able to connect to internet and getting error ‘Server not found’. Also yum is also not working now and giving error [Errno 14] PYCURL ERROR 6 : ”Could not resolve host ‘mum-bluecoat01” . Could you please help me here?

  51. Ben says:

    Hello Anoop. Thanks for your step by step guide.

    I was able to configure static ip for centos 7 running on a virtualbox using your steps.

    However, the static ip often change to dynamic ip during a long-running scp job to another centos. Static ip would then return with network restart.

    Any idea on how to avoid this ip change?

  52. Shashikant Mahajan says:

    Good Article! Really helpful..

  53. Sagar Shinde says:

    Hi, when i try to assign static ip to centos VM virtual Box.static ip successfully configured but need to connect internet connection not able to connect
    kindly help on this

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s