How can I add a FQDN to a Centos VM running on VirtualBox?

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!

l--''''''---------''''''''''''

Posted 2013-06-18T18:09:50.900

Reputation: 713

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

Abhinav Maheshwari

Posted 2013-06-18T18:09:50.900

Reputation: 21

I had to do service network restart after. – claptimes – 2014-10-10T14:22:42.193

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.

spuder

Posted 2013-06-18T18:09:50.900

Reputation: 8 755