I would like to add a fully qualified domain name to my Centos 6 VM that is running on virtualbox.

The virtualbox is set to be in bridged mode.

I'm a windows programmer, and I am as far as they get from networking / linux.

I would be most grateful if you could point me into the right direction on how to do this.

I understand that the best way to do this is through a DNS server, but I want to go the quickest/easiest route for the purposes of learning by setting it up in /etc/hosts? I don't know if thats the right area, but I am open to your feedback.

update: I have been able to ping this VM using my host machine using its IP (I'm not sure whether it's internal or external) however, I haven't been able to ping it using its hostname!

2 Answers 2


You can also do the following:

Check the IP address on the CentOS VM by running the command ifconfig. It should be something like Now modify the file /etc/hosts on CentOS, add the following line  virtualCentOS.local virtualCentOS
  • I had to do service network restart after.
    – claptimes
    Oct 10, 2014 at 14:22

Typically setting up a dns record in your dns server is the best way to do this.

You will need to edit the following file c:\windows\system32\drivers\etc\hosts

Do the following

Start -> Run notepad c:\windows\system32\drivers\etc\hosts

In notepad, add the following line to the end of the file (change to the ip address of your vm, change 'foo' to the domain name you would like to refer to your vm as) foo

Here is a link that has screenshots of how to do this.


This will only work as long as your vm has the same ip address. If your vm gets a new ip address, you will have to repeat these steps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .