2

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

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
1
  • I had to do service network restart after.
    – claptimes
    Oct 10, 2014 at 14:22
1

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.

You must log in to answer this question.

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