Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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!

share|improve this question

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 10.0.2.15. Now modify the file /etc/hosts on CentOS, add the following line

10.0.2.15  virtualCentOS.local virtualCentOS
share|improve this answer
    
I had to do service network restart after. –  claptimes Oct 10 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 192.168.10.10 to the ip address of your vm, change 'foo' to the domain name you would like to refer to your vm as)

192.168.10.10 foo

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

http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

Important
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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.